diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2013-06-08 21:10:04 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2013-06-08 21:10:04 (GMT) |
commit | f103d55b2acb0ed0352e407249f2734b65c4b874 (patch) | |
tree | 1aa6626f35029df1d1077ae81846aa3c4dbd4450 | |
parent | a81dd6594067a9501f3ba65b7c05dd50accac5de (diff) | |
parent | 28b0d9d13e8c4a92e60341d4758f3f81a8cf15e5 (diff) | |
download | cpython-f103d55b2acb0ed0352e407249f2734b65c4b874.zip cpython-f103d55b2acb0ed0352e407249f2734b65c4b874.tar.gz cpython-f103d55b2acb0ed0352e407249f2734b65c4b874.tar.bz2 |
#17691: merge with 3.3.
-rw-r--r-- | Lib/test/test_univnewlines.py | 37 | ||||
-rw-r--r-- | Misc/NEWS | 3 |
2 files changed, 19 insertions, 21 deletions
diff --git a/Lib/test/test_univnewlines.py b/Lib/test/test_univnewlines.py index 183ae75..fd07539 100644 --- a/Lib/test/test_univnewlines.py +++ b/Lib/test/test_univnewlines.py @@ -30,7 +30,13 @@ DATA_CRLF = "\r\n".join(DATA_TEMPLATE) + "\r\n" DATA_MIXED = "\n".join(DATA_TEMPLATE) + "\r" DATA_SPLIT = [x + "\n" for x in DATA_TEMPLATE] -class TestGenericUnivNewlines(unittest.TestCase): +class CTest: + open = io.open + +class PyTest: + open = staticmethod(pyio.open) + +class TestGenericUnivNewlines: # use a class variable DATA to define the data to write to the file # and a class variable NEWLINE to set the expected newlines value READMODE = 'r' @@ -85,10 +91,14 @@ class TestGenericUnivNewlines(unittest.TestCase): class TestCRNewlines(TestGenericUnivNewlines): NEWLINE = '\r' DATA = DATA_CR +class CTestCRNewlines(CTest, TestCRNewlines, unittest.TestCase): pass +class PyTestCRNewlines(PyTest, TestCRNewlines, unittest.TestCase): pass class TestLFNewlines(TestGenericUnivNewlines): NEWLINE = '\n' DATA = DATA_LF +class CTestLFNewlines(CTest, TestLFNewlines, unittest.TestCase): pass +class PyTestLFNewlines(PyTest, TestLFNewlines, unittest.TestCase): pass class TestCRLFNewlines(TestGenericUnivNewlines): NEWLINE = '\r\n' @@ -100,29 +110,14 @@ class TestCRLFNewlines(TestGenericUnivNewlines): data = fp.readline() pos = fp.tell() self.assertEqual(repr(fp.newlines), repr(self.NEWLINE)) +class CTestCRLFNewlines(CTest, TestCRLFNewlines, unittest.TestCase): pass +class PyTestCRLFNewlines(PyTest, TestCRLFNewlines, unittest.TestCase): pass class TestMixedNewlines(TestGenericUnivNewlines): NEWLINE = ('\r', '\n') DATA = DATA_MIXED - - -def test_main(): - base_tests = (TestCRNewlines, - TestLFNewlines, - TestCRLFNewlines, - TestMixedNewlines) - tests = [] - # Test the C and Python implementations. - for test in base_tests: - class CTest(test): - open = io.open - CTest.__name__ = "C" + test.__name__ - class PyTest(test): - open = staticmethod(pyio.open) - PyTest.__name__ = "Py" + test.__name__ - tests.append(CTest) - tests.append(PyTest) - support.run_unittest(*tests) +class CTestMixedNewlines(CTest, TestMixedNewlines, unittest.TestCase): pass +class PyTestMixedNewlines(PyTest, TestMixedNewlines, unittest.TestCase): pass if __name__ == '__main__': - test_main() + unittest.main() @@ -379,6 +379,9 @@ Tests - Issue #12820: add tests for the xml.dom.minicompat module. Patch by John Chandler and Phil Connell. +- Issue #17691: test_univnewlines now works with unittest test discovery. + Patch by Zachary Ware. + - Issue #17790: test_set now works with unittest test discovery. Patch by Zachary Ware. |