[Python-checkins] cpython (3.3): #17304: test_hash now works with unittest test discovery. Patch by Zachary
ezio.melotti
python-checkins at python.org
Wed Feb 27 09:10:03 CET 2013
http://hg.python.org/cpython/rev/619ed4ed7087
changeset: 82411:619ed4ed7087
branch: 3.3
parent: 82409:83ae10bf608c
user: Ezio Melotti <ezio.melotti at gmail.com>
date: Wed Feb 27 10:09:12 2013 +0200
summary:
#17304: test_hash now works with unittest test discovery. Patch by Zachary Ware.
files:
Lib/test/test_hash.py | 32 ++++++++++--------------------
Misc/NEWS | 3 ++
2 files changed, 14 insertions(+), 21 deletions(-)
diff --git a/Lib/test/test_hash.py b/Lib/test/test_hash.py
--- a/Lib/test/test_hash.py
+++ b/Lib/test/test_hash.py
@@ -7,7 +7,6 @@
import os
import sys
import unittest
-from test import support
from test.script_helper import assert_python_ok
from collections import Hashable
@@ -133,7 +132,7 @@
for obj in self.hashes_to_check:
self.assertEqual(hash(obj), _default_hash(obj))
-class HashRandomizationTests(unittest.TestCase):
+class HashRandomizationTests:
# Each subclass should define a field "repr_", containing the repr() of
# an object to be tested
@@ -190,19 +189,22 @@
h = -1024014457
self.assertEqual(self.get_hash(self.repr_, seed=42), h)
-class StrHashRandomizationTests(StringlikeHashRandomizationTests):
+class StrHashRandomizationTests(StringlikeHashRandomizationTests,
+ unittest.TestCase):
repr_ = repr('abc')
def test_empty_string(self):
self.assertEqual(hash(""), 0)
-class BytesHashRandomizationTests(StringlikeHashRandomizationTests):
+class BytesHashRandomizationTests(StringlikeHashRandomizationTests,
+ unittest.TestCase):
repr_ = repr(b'abc')
def test_empty_string(self):
self.assertEqual(hash(b""), 0)
-class MemoryviewHashRandomizationTests(StringlikeHashRandomizationTests):
+class MemoryviewHashRandomizationTests(StringlikeHashRandomizationTests,
+ unittest.TestCase):
repr_ = "memoryview(b'abc')"
def test_empty_string(self):
@@ -212,27 +214,15 @@
def get_hash_command(self, repr_):
return 'import datetime; print(hash(%s))' % repr_
-class DatetimeDateTests(DatetimeTests):
+class DatetimeDateTests(DatetimeTests, unittest.TestCase):
repr_ = repr(datetime.date(1066, 10, 14))
-class DatetimeDatetimeTests(DatetimeTests):
+class DatetimeDatetimeTests(DatetimeTests, unittest.TestCase):
repr_ = repr(datetime.datetime(1, 2, 3, 4, 5, 6, 7))
-class DatetimeTimeTests(DatetimeTests):
+class DatetimeTimeTests(DatetimeTests, unittest.TestCase):
repr_ = repr(datetime.time(0))
-def test_main():
- support.run_unittest(HashEqualityTestCase,
- HashInheritanceTestCase,
- HashBuiltinsTestCase,
- StrHashRandomizationTests,
- BytesHashRandomizationTests,
- MemoryviewHashRandomizationTests,
- DatetimeDateTests,
- DatetimeDatetimeTests,
- DatetimeTimeTests)
-
-
if __name__ == "__main__":
- test_main()
+ unittest.main()
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -644,6 +644,9 @@
- Issue #15539: Added regression tests for Tools/scripts/pindent.py.
+- Issue #17304: test_hash now works with unittest test discovery.
+ Patch by Zachary Ware.
+
- Issue #17303: test_future* now work with unittest test discovery.
Patch by Zachary Ware.
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list