Skip to content

gh-99430: Remove duplicated tests for old-styled classes #99432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 1 addition & 79 deletions Lib/test/pydocfodder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,85 +2,7 @@

import types

class A_classic:
"A classic class."
def A_method(self):
"Method defined in A."
def AB_method(self):
"Method defined in A and B."
def AC_method(self):
"Method defined in A and C."
def AD_method(self):
"Method defined in A and D."
def ABC_method(self):
"Method defined in A, B and C."
def ABD_method(self):
"Method defined in A, B and D."
def ACD_method(self):
"Method defined in A, C and D."
def ABCD_method(self):
"Method defined in A, B, C and D."


class B_classic(A_classic):
"A classic class, derived from A_classic."
def AB_method(self):
"Method defined in A and B."
def ABC_method(self):
"Method defined in A, B and C."
def ABD_method(self):
"Method defined in A, B and D."
def ABCD_method(self):
"Method defined in A, B, C and D."
def B_method(self):
"Method defined in B."
def BC_method(self):
"Method defined in B and C."
def BD_method(self):
"Method defined in B and D."
def BCD_method(self):
"Method defined in B, C and D."

class C_classic(A_classic):
"A classic class, derived from A_classic."
def AC_method(self):
"Method defined in A and C."
def ABC_method(self):
"Method defined in A, B and C."
def ACD_method(self):
"Method defined in A, C and D."
def ABCD_method(self):
"Method defined in A, B, C and D."
def BC_method(self):
"Method defined in B and C."
def BCD_method(self):
"Method defined in B, C and D."
def C_method(self):
"Method defined in C."
def CD_method(self):
"Method defined in C and D."

class D_classic(B_classic, C_classic):
"A classic class, derived from B_classic and C_classic."
def AD_method(self):
"Method defined in A and D."
def ABD_method(self):
"Method defined in A, B and D."
def ACD_method(self):
"Method defined in A, C and D."
def ABCD_method(self):
"Method defined in A, B, C and D."
def BD_method(self):
"Method defined in B and D."
def BCD_method(self):
"Method defined in B, C and D."
def CD_method(self):
"Method defined in C and D."
def D_method(self):
"Method defined in D."


class A_new(object):
class A_new:
"A new-style class."

def A_method(self):
Expand Down
12 changes: 4 additions & 8 deletions Lib/test/test_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ def __getattribute__(self, name):
# Type-specific _copy_xxx() methods

def test_copy_atomic(self):
class Classic:
pass
class NewStyle(object):
class NewStyle:
pass
def f():
pass
Expand All @@ -100,7 +98,7 @@ class WithMetaclass(metaclass=abc.ABCMeta):
42, 2**100, 3.14, True, False, 1j,
"hello", "hello\u1234", f.__code__,
b"world", bytes(range(256)), range(10), slice(1, 10, 2),
NewStyle, Classic, max, WithMetaclass, property()]
NewStyle, max, WithMetaclass, property()]
for x in tests:
self.assertIs(copy.copy(x), x)

Expand Down Expand Up @@ -350,15 +348,13 @@ def __getattribute__(self, name):
# Type-specific _deepcopy_xxx() methods

def test_deepcopy_atomic(self):
class Classic:
pass
class NewStyle(object):
class NewStyle:
pass
def f():
pass
tests = [None, 42, 2**100, 3.14, True, False, 1j,
"hello", "hello\u1234", f.__code__,
NewStyle, range(10), Classic, max, property()]
NewStyle, range(10), max, property()]
for x in tests:
self.assertIs(copy.deepcopy(x), x)

Expand Down
6 changes: 1 addition & 5 deletions Lib/test/test_descr.py
Original file line number Diff line number Diff line change
Expand Up @@ -3261,12 +3261,8 @@ def __get__(self, object, otype):
if otype:
otype = otype.__name__
return 'object=%s; type=%s' % (object, otype)
class OldClass:
class NewClass:
__doc__ = DocDescr()
class NewClass(object):
__doc__ = DocDescr()
self.assertEqual(OldClass.__doc__, 'object=None; type=OldClass')
self.assertEqual(OldClass().__doc__, 'object=OldClass instance; type=OldClass')
self.assertEqual(NewClass.__doc__, 'object=None; type=NewClass')
self.assertEqual(NewClass().__doc__, 'object=NewClass instance; type=NewClass')

Expand Down
42 changes: 0 additions & 42 deletions Lib/test/test_gc.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,48 +542,6 @@ def __getattr__(self, someattribute):
self.assertEqual(gc.collect(), 2)
self.assertEqual(len(gc.garbage), garbagelen)

def test_boom_new(self):
# boom__new and boom2_new are exactly like boom and boom2, except use
# new-style classes.

class Boom_New(object):
def __getattr__(self, someattribute):
del self.attr
raise AttributeError

a = Boom_New()
b = Boom_New()
a.attr = b
b.attr = a

gc.collect()
garbagelen = len(gc.garbage)
del a, b
self.assertEqual(gc.collect(), 2)
self.assertEqual(len(gc.garbage), garbagelen)

def test_boom2_new(self):
class Boom2_New(object):
def __init__(self):
self.x = 0

def __getattr__(self, someattribute):
self.x += 1
if self.x > 1:
del self.attr
raise AttributeError

a = Boom2_New()
b = Boom2_New()
a.attr = b
b.attr = a

gc.collect()
garbagelen = len(gc.garbage)
del a, b
self.assertEqual(gc.collect(), 2)
self.assertEqual(len(gc.garbage), garbagelen)

def test_get_referents(self):
alist = [1, 3, 5]
got = gc.get_referents(alist)
Expand Down
5 changes: 0 additions & 5 deletions Lib/test/test_unicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -2380,12 +2380,7 @@ class s1:
def __repr__(self):
return '\\n'

class s2:
def __repr__(self):
return '\\n'

self.assertEqual(repr(s1()), '\\n')
self.assertEqual(repr(s2()), '\\n')

def test_printable_repr(self):
self.assertEqual(repr('\U00010000'), "'%c'" % (0x10000,)) # printable
Expand Down