diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2013-02-15 17:17:53 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2013-02-15 17:17:53 (GMT) |
commit | 3a03d2eaef63955c9f1c74a13f0e4fb791a7f42d (patch) | |
tree | cb14c8b468b2dff4d169a8db7748c0caf5a6a9b0 /Lib | |
parent | a90b7132b7e15009d2d747e4d843dc8422907e18 (diff) | |
download | cpython-3a03d2eaef63955c9f1c74a13f0e4fb791a7f42d.zip cpython-3a03d2eaef63955c9f1c74a13f0e4fb791a7f42d.tar.gz cpython-3a03d2eaef63955c9f1c74a13f0e4fb791a7f42d.tar.bz2 |
#17163: test_file now works with unittest test discovery. Patch by Zachary Ware.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_file.py | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/Lib/test/test_file.py b/Lib/test/test_file.py index bb0da79..a78ddf3 100644 --- a/Lib/test/test_file.py +++ b/Lib/test/test_file.py @@ -10,7 +10,7 @@ import _pyio as pyio from test.support import TESTFN, run_unittest from collections import UserList -class AutoFileTests(unittest.TestCase): +class AutoFileTests: # file tests for which a test file is automatically set up def setUp(self): @@ -128,14 +128,14 @@ class AutoFileTests(unittest.TestCase): def testReadWhenWriting(self): self.assertRaises(IOError, self.f.read) -class CAutoFileTests(AutoFileTests): +class CAutoFileTests(AutoFileTests, unittest.TestCase): open = io.open -class PyAutoFileTests(AutoFileTests): +class PyAutoFileTests(AutoFileTests, unittest.TestCase): open = staticmethod(pyio.open) -class OtherFileTests(unittest.TestCase): +class OtherFileTests: def testModeStrings(self): # check invalid mode strings @@ -322,22 +322,18 @@ class OtherFileTests(unittest.TestCase): finally: os.unlink(TESTFN) -class COtherFileTests(OtherFileTests): +class COtherFileTests(OtherFileTests, unittest.TestCase): open = io.open -class PyOtherFileTests(OtherFileTests): +class PyOtherFileTests(OtherFileTests, unittest.TestCase): open = staticmethod(pyio.open) -def test_main(): +def tearDownModule(): # Historically, these tests have been sloppy about removing TESTFN. # So get rid of it no matter what. - try: - run_unittest(CAutoFileTests, PyAutoFileTests, - COtherFileTests, PyOtherFileTests) - finally: - if os.path.exists(TESTFN): - os.unlink(TESTFN) + if os.path.exists(TESTFN): + os.unlink(TESTFN) if __name__ == '__main__': - test_main() + unittest.main() |