[Python-checkins] cpython (3.3): #17163: test_file now works with unittest test discovery. Patch by Zachary

ezio.melotti python-checkins at python.org
Fri Feb 15 18:19:37 CET 2013


http://hg.python.org/cpython/rev/9b3c5085b4a4
changeset: 82207:9b3c5085b4a4
branch: 3.3
parent: 82204:85e646f7fce3
user: Ezio Melotti <ezio.melotti at gmail.com>
date: Fri Feb 15 19:17:53 2013 +0200
summary:
 #17163: test_file now works with unittest test discovery. Patch by Zachary Ware.
files:
 Lib/test/test_file.py | 24 ++++++++++--------------
 Misc/NEWS | 3 +++
 2 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/Lib/test/test_file.py b/Lib/test/test_file.py
--- a/Lib/test/test_file.py
+++ b/Lib/test/test_file.py
@@ -10,7 +10,7 @@
 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 @@
 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 @@
 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()
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -605,6 +605,9 @@
 
 - Issue #15539: Added regression tests for Tools/scripts/pindent.py.
 
+- Issue #17163: test_file now works with unittest test discovery.
+ Patch by Zachary Ware.
+
 - Issue #16925: test_configparser now works with unittest test discovery.
 Patch by Zachary Ware.
 
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /