mirror of
https://github.com/python/cpython.git
synced 2025-07-29 06:05:00 +00:00
test_py3kwarn had been overlooked when test.test_support.catch_warning() was
re-implemented to use warnings.catch_warnings() and had its API improved. Closes issue #3768. Code review by Benjamin Peterson.
This commit is contained in:
parent
c585df9476
commit
a0b7444f68
2 changed files with 15 additions and 10 deletions
|
@ -220,28 +220,28 @@ class TestPy3KWarnings(unittest.TestCase):
|
||||||
# With object as the base class
|
# With object as the base class
|
||||||
class WarnOnlyCmp(object):
|
class WarnOnlyCmp(object):
|
||||||
def __cmp__(self, other): pass
|
def __cmp__(self, other): pass
|
||||||
self.assertEqual(len(w.warnings), 1)
|
self.assertEqual(len(w), 1)
|
||||||
self.assertWarning(None, w,
|
self.assertWarning(None, w,
|
||||||
"Overriding __cmp__ blocks inheritance of __hash__ in 3.x")
|
"Overriding __cmp__ blocks inheritance of __hash__ in 3.x")
|
||||||
w.reset()
|
w.reset()
|
||||||
class WarnOnlyEq(object):
|
class WarnOnlyEq(object):
|
||||||
def __eq__(self, other): pass
|
def __eq__(self, other): pass
|
||||||
self.assertEqual(len(w.warnings), 1)
|
self.assertEqual(len(w), 1)
|
||||||
self.assertWarning(None, w,
|
self.assertWarning(None, w,
|
||||||
"Overriding __eq__ blocks inheritance of __hash__ in 3.x")
|
"Overriding __eq__ blocks inheritance of __hash__ in 3.x")
|
||||||
w.reset()
|
w.reset()
|
||||||
class WarnCmpAndEq(object):
|
class WarnCmpAndEq(object):
|
||||||
def __cmp__(self, other): pass
|
def __cmp__(self, other): pass
|
||||||
def __eq__(self, other): pass
|
def __eq__(self, other): pass
|
||||||
self.assertEqual(len(w.warnings), 2)
|
self.assertEqual(len(w), 2)
|
||||||
self.assertWarning(None, w.warnings[-2],
|
self.assertWarning(None, w[-2],
|
||||||
"Overriding __cmp__ blocks inheritance of __hash__ in 3.x")
|
"Overriding __cmp__ blocks inheritance of __hash__ in 3.x")
|
||||||
self.assertWarning(None, w,
|
self.assertWarning(None, w,
|
||||||
"Overriding __eq__ blocks inheritance of __hash__ in 3.x")
|
"Overriding __eq__ blocks inheritance of __hash__ in 3.x")
|
||||||
w.reset()
|
w.reset()
|
||||||
class NoWarningOnlyHash(object):
|
class NoWarningOnlyHash(object):
|
||||||
def __hash__(self): pass
|
def __hash__(self): pass
|
||||||
self.assertEqual(len(w.warnings), 0)
|
self.assertEqual(len(w), 0)
|
||||||
# With an intermediate class in the heirarchy
|
# With an intermediate class in the heirarchy
|
||||||
class DefinesAllThree(object):
|
class DefinesAllThree(object):
|
||||||
def __cmp__(self, other): pass
|
def __cmp__(self, other): pass
|
||||||
|
@ -249,28 +249,28 @@ class TestPy3KWarnings(unittest.TestCase):
|
||||||
def __hash__(self): pass
|
def __hash__(self): pass
|
||||||
class WarnOnlyCmp(DefinesAllThree):
|
class WarnOnlyCmp(DefinesAllThree):
|
||||||
def __cmp__(self, other): pass
|
def __cmp__(self, other): pass
|
||||||
self.assertEqual(len(w.warnings), 1)
|
self.assertEqual(len(w), 1)
|
||||||
self.assertWarning(None, w,
|
self.assertWarning(None, w,
|
||||||
"Overriding __cmp__ blocks inheritance of __hash__ in 3.x")
|
"Overriding __cmp__ blocks inheritance of __hash__ in 3.x")
|
||||||
w.reset()
|
w.reset()
|
||||||
class WarnOnlyEq(DefinesAllThree):
|
class WarnOnlyEq(DefinesAllThree):
|
||||||
def __eq__(self, other): pass
|
def __eq__(self, other): pass
|
||||||
self.assertEqual(len(w.warnings), 1)
|
self.assertEqual(len(w), 1)
|
||||||
self.assertWarning(None, w,
|
self.assertWarning(None, w,
|
||||||
"Overriding __eq__ blocks inheritance of __hash__ in 3.x")
|
"Overriding __eq__ blocks inheritance of __hash__ in 3.x")
|
||||||
w.reset()
|
w.reset()
|
||||||
class WarnCmpAndEq(DefinesAllThree):
|
class WarnCmpAndEq(DefinesAllThree):
|
||||||
def __cmp__(self, other): pass
|
def __cmp__(self, other): pass
|
||||||
def __eq__(self, other): pass
|
def __eq__(self, other): pass
|
||||||
self.assertEqual(len(w.warnings), 2)
|
self.assertEqual(len(w), 2)
|
||||||
self.assertWarning(None, w.warnings[-2],
|
self.assertWarning(None, w[-2],
|
||||||
"Overriding __cmp__ blocks inheritance of __hash__ in 3.x")
|
"Overriding __cmp__ blocks inheritance of __hash__ in 3.x")
|
||||||
self.assertWarning(None, w,
|
self.assertWarning(None, w,
|
||||||
"Overriding __eq__ blocks inheritance of __hash__ in 3.x")
|
"Overriding __eq__ blocks inheritance of __hash__ in 3.x")
|
||||||
w.reset()
|
w.reset()
|
||||||
class NoWarningOnlyHash(DefinesAllThree):
|
class NoWarningOnlyHash(DefinesAllThree):
|
||||||
def __hash__(self): pass
|
def __hash__(self): pass
|
||||||
self.assertEqual(len(w.warnings), 0)
|
self.assertEqual(len(w), 0)
|
||||||
|
|
||||||
|
|
||||||
class TestStdlibRemovals(unittest.TestCase):
|
class TestStdlibRemovals(unittest.TestCase):
|
||||||
|
|
|
@ -100,6 +100,11 @@ Extension Modules
|
||||||
- Issue #3643: Added a few more checks to _testcapi to prevent segfaults by
|
- Issue #3643: Added a few more checks to _testcapi to prevent segfaults by
|
||||||
exploitation of poor argument checking.
|
exploitation of poor argument checking.
|
||||||
|
|
||||||
|
Tests
|
||||||
|
-----
|
||||||
|
|
||||||
|
- Issue 3768: Move test_py3kwarn over to the new API for catch_warnings().
|
||||||
|
|
||||||
|
|
||||||
What's New in Python 2.6 beta 3?
|
What's New in Python 2.6 beta 3?
|
||||||
================================
|
================================
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue