|
3 | 3 | import glob |
4 | 4 | import StringIO |
5 | 5 | import unittest |
6 | | -import new |
7 | | - |
8 | | -sys.path.insert(0, os.path.split(os.path.abspath(__file__))[0]) |
9 | | -from test_parser import parseTestcase |
10 | 6 |
|
11 | 7 | #RELEASE remove |
12 | | -# XXX Allow us to import the sibling module |
13 | | -os.chdir(os.path.split(os.path.abspath(__file__))[0]) |
14 | | -sys.path.insert(0, os.path.abspath(os.path.join(os.pardir, "src"))) |
| 8 | +if __name__ == '__main__': |
| 9 | + # XXX Allow us to import the sibling module |
| 10 | + os.chdir(os.path.split(os.path.abspath(__file__))[0]) |
| 11 | + sys.path.insert(0, os.path.abspath(os.path.join(os.pardir, "src"))) |
15 | 12 |
|
16 | 13 | import html5parser |
17 | 14 | #Run tests over all treewalkers/treebuilders pairs |
|
28 | 25 | #from html5lib.filters.lint import Filter as LintFilter, LintError |
29 | 26 | #END RELEASE |
30 | 27 |
|
| 28 | +from test_parser import parseTestcase |
| 29 | + |
31 | 30 | def PullDOMAdapter(node): |
32 | 31 | from xml.dom import Node |
33 | 32 | from xml.dom.pulldom import START_ELEMENT, END_ELEMENT, COMMENT, CHARACTERS |
@@ -252,11 +251,11 @@ def buildTestSuite(): |
252 | 251 | for func, innerHTML, input, expected, errors, treeName, treeCls in test_treewalker(): |
253 | 252 | tests += 1 |
254 | 253 | testName = 'test%d' % tests |
255 | | - testFunc = lambda self, method=func, innerHTML=innerHTML, input=input, expected=expected, \ |
256 | | - errors=errors, treeCls=treeCls: method(self, innerHTML, input, expected, errors, treeCls) |
| 254 | + def testFunc(self, method=func, innerHTML=innerHTML, input=input, |
| 255 | + expected=expected, errors=errors, treeCls=treeCls): |
| 256 | + method(self, innerHTML, input, expected, errors, treeCls) |
257 | 257 | testFunc.__doc__ = 'Parser %s Tree %s Input: %s'%(testName, treeName, input) |
258 | | - instanceMethod = new.instancemethod(testFunc, None, TestCase) |
259 | | - setattr(TestCase, testName, instanceMethod) |
| 258 | + setattr(TestCase, testName, testFunc) |
260 | 259 | return unittest.TestLoader().loadTestsFromTestCase(TestCase) |
261 | 260 |
|
262 | 261 | def main(): |
|
0 commit comments