|
10 | 10 | from test.support import TESTFN, run_unittest |
11 | 11 | from collections import UserList |
12 | 12 |
|
13 | | -class AutoFileTests(unittest.TestCase): |
| 13 | +class AutoFileTests: |
14 | 14 | # file tests for which a test file is automatically set up |
15 | 15 |
|
16 | 16 | def setUp(self): |
@@ -128,14 +128,14 @@ def testMethods(self): |
128 | 128 | def testReadWhenWriting(self): |
129 | 129 | self.assertRaises(IOError, self.f.read) |
130 | 130 |
|
131 | | -class CAutoFileTests(AutoFileTests): |
| 131 | +class CAutoFileTests(AutoFileTests, unittest.TestCase): |
132 | 132 | open = io.open |
133 | 133 |
|
134 | | -class PyAutoFileTests(AutoFileTests): |
| 134 | +class PyAutoFileTests(AutoFileTests, unittest.TestCase): |
135 | 135 | open = staticmethod(pyio.open) |
136 | 136 |
|
137 | 137 |
|
138 | | -class OtherFileTests(unittest.TestCase): |
| 138 | +class OtherFileTests: |
139 | 139 |
|
140 | 140 | def testModeStrings(self): |
141 | 141 | # check invalid mode strings |
@@ -322,22 +322,18 @@ def testIteration(self): |
322 | 322 | finally: |
323 | 323 | os.unlink(TESTFN) |
324 | 324 |
|
325 | | -class COtherFileTests(OtherFileTests): |
| 325 | +class COtherFileTests(OtherFileTests, unittest.TestCase): |
326 | 326 | open = io.open |
327 | 327 |
|
328 | | -class PyOtherFileTests(OtherFileTests): |
| 328 | +class PyOtherFileTests(OtherFileTests, unittest.TestCase): |
329 | 329 | open = staticmethod(pyio.open) |
330 | 330 |
|
331 | 331 |
|
332 | | -def test_main(): |
| 332 | +def tearDownModule(): |
333 | 333 | # Historically, these tests have been sloppy about removing TESTFN. |
334 | 334 | # So get rid of it no matter what. |
335 | | - try: |
336 | | - run_unittest(CAutoFileTests, PyAutoFileTests, |
337 | | - COtherFileTests, PyOtherFileTests) |
338 | | - finally: |
339 | | - if os.path.exists(TESTFN): |
340 | | - os.unlink(TESTFN) |
| 335 | + if os.path.exists(TESTFN): |
| 336 | + os.unlink(TESTFN) |
341 | 337 |
|
342 | 338 | if __name__ == '__main__': |
343 | | - test_main() |
| 339 | + unittest.main() |
0 commit comments