本文整理汇总了Python中fit.Parse.Parse.last方法的典型用法代码示例。如果您正苦于以下问题:Python Parse.last方法的具体用法?Python Parse.last怎么用?Python Parse.last使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fit.Parse.Parse
的用法示例。
在下文中一共展示了Parse.last方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Test_ParseUtility
# 需要导入模块: from fit.Parse import Parse [as 别名]
# 或者: from fit.Parse.Parse import last [as 别名]
class Test_ParseUtility(unittest.TestCase):
html = ("<html><title>table</title><body>"
"t1<table><tr><td>Test</td></tr></table>t2"
"t3<table><tr><td>Test</td></tr></table>t4"
"</body></html>")
setUpHtml = ("<html><title>setup</title><body>"
"s1<table><tr><td>SetUp</td></tr></table>s2"
"s3<table><tr><td>SetUp</td></tr></table>s4"
"</body></html>")
tearDownHtml = ("<html><title>teardown</title><body>"
"front<table><tr><td>TearDown</td></tr></table>back"
"T3<table><tr><td>TearDown</td></tr></table>T4"
"</body></html>")
def setUp(self):
print '%s %s' % (self.id(), self.shortDescription())
self._tables = Parse(self.html)
self._setUp = Parse(self.setUpHtml)
self._tearDown = Parse(self.tearDownHtml)
def testAppend(self):
expected = ("<html><title>setup</title><body>"
"s1<table><tr><td>SetUp</td></tr></table>s2"
"s3<table><tr><td>SetUp</td></tr></table>s4"
"<br>front<table><tr><td>TearDown</td></tr></table>back"
"T3<table><tr><td>TearDown</td></tr></table>T4"
"</body></html>")
ParseUtility.append(self._setUp, self._tearDown)
self._assertEquals(expected, self._setUp)
def testAppendNone(self):
ParseUtility.append(self._setUp, None)
self._assertEquals(self.setUpHtml, self._setUp)
def testAppendSetUp(self):
expected = ("<html><title>table</title><body>"
"s1<table><tr><td>SetUp</td></tr></table>s2"
"s3<table><tr><td>SetUp</td></tr></table>"
"s4<br>t1<table><tr><td>Test</td></tr></table>t2"
"t3<table><tr><td>Test</td></tr></table>t4"
"</body></html>")
ParseUtility.appendToSetUp(self._setUp, self._tables)
self._assertEquals(expected, self._setUp)
def testAppendSetUpWithNull(self):
ParseUtility.appendToSetUp(self._setUp, None)
self._assertEquals(self.setUpHtml, self._setUp)
def testAppendAll(self):
expected = ("<html><title>table</title><body>"
"s1<table><tr><td>SetUp</td></tr></table>s2"
"s3<table><tr><td>SetUp</td></tr></table>"
"s4<br>t1<table><tr><td>Test</td></tr></table>t2"
"t3<table><tr><td>Test</td></tr></table>"
"t4<br>front<table><tr><td>TearDown</td></tr></table>back"
"T3<table><tr><td>TearDown</td></tr></table>T4"
"</body></html>")
ParseUtility.append(self._tables, self._tearDown)
ParseUtility.appendToSetUp(self._setUp, self._tables)
self._assertEquals(expected, self._setUp)
def _assertEquals(self, expected, tables2):
self.assertEquals(expected, ParseUtility.toString(tables2))
def testFixHeader(self):
result = ParseUtility.removeHeader(self._tables)
self.assertEquals("<html><title>table</title><body>", result)
self._assertEquals("t1<table><tr><td>Test</td></tr></table>t2"
"t3<table><tr><td>Test</td></tr></table>t4"
"</body></html>", self._tables)
def testInitialTable(self):
self._assertEquals("<html><title>table</title><body>"
"t1<table><tr><td>Test</td></tr></table>t2"
"t3<table><tr><td>Test</td></tr></table>t4"
"</body></html>", self._tables)
def testChangeHeader(self):
ParseUtility.changeHeader(self._tables,"<html><title>new</title><body><hr>")
self._assertEquals("<html><title>new</title><body><hr>"
"t1<table><tr><td>Test</td></tr></table>t2"
"t3<table><tr><td>Test</td></tr></table>t4"
"</body></html>", self._tables)
def testCompleteTrailerThatIsComplete(self):
ParseUtility.completeTrailer(self._tables)
self._assertEquals("<html><title>table</title><body>"
"t1<table><tr><td>Test</td></tr></table>t2"
"t3<table><tr><td>Test</td></tr></table>t4"
"</body></html>",self._tables)
def testCompleteTrailerThatIsInComplete(self):
self._tables.last().trailer = "JUNK"
ParseUtility.completeTrailer(self._tables)
self._assertEquals("<html><title>table</title><body>"
"t1<table><tr><td>Test</td></tr></table>t2"
"t3<table><tr><td>Test</td></tr></table>JUNK"
"\n</body></html>\n",self._tables)
#.........这里部分代码省略.........