Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ab078e9

Browse files
committed
Backed out changeset af29d89083b3 (closes #25548) (closes #27498)
1 parent fb4f825 commit ab078e9

20 files changed

Lines changed: 92 additions & 105 deletions

Lib/ctypes/test/test_structures.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -320,14 +320,14 @@ class Person(Structure):
320320

321321
cls, msg = self.get_except(Person, b"Someone", (1, 2))
322322
self.assertEqual(cls, RuntimeError)
323-
self.assertRegex(msg,
324-
r"\(Phone\) <class 'TypeError' at 0x.+>: "
325-
r"expected bytes, int found")
323+
self.assertEqual(msg,
324+
"(Phone) <class 'TypeError'>: "
325+
"expected bytes, int found")
326326

327327
cls, msg = self.get_except(Person, b"Someone", (b"a", b"b", b"c"))
328328
self.assertEqual(cls, RuntimeError)
329-
self.assertRegex(msg,
330-
r"\(Phone\) <class 'TypeError' at 0x.+>: too many initializers")
329+
self.assertEqual(msg,
330+
"(Phone) <class 'TypeError'>: too many initializers")
331331

332332
def test_huge_field_name(self):
333333
# issue12881: segfault with large structure field names

Lib/statistics.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,23 +131,23 @@ def _sum(data, start=0):
131131
--------
132132
133133
>>> _sum([3, 2.25, 4.5, -0.5, 1.0], 0.75)
134-
(<class 'float' ...>, Fraction(11, 1), 5)
134+
(<class 'float'>, Fraction(11, 1), 5)
135135
136136
Some sources of round-off error will be avoided:
137137
138138
>>> _sum([1e50, 1, -1e50] * 1000) # Built-in sum returns zero.
139-
(<class 'float' ...>, Fraction(1000, 1), 3000)
139+
(<class 'float'>, Fraction(1000, 1), 3000)
140140
141141
Fractions and Decimals are also supported:
142142
143143
>>> from fractions import Fraction as F
144144
>>> _sum([F(2, 3), F(7, 5), F(1, 4), F(5, 6)])
145-
(<class 'fractions.Fraction' ...>, Fraction(63, 20), 4)
145+
(<class 'fractions.Fraction'>, Fraction(63, 20), 4)
146146
147147
>>> from decimal import Decimal as D
148148
>>> data = [D("0.1375"), D("0.2108"), D("0.3061"), D("0.0419")]
149149
>>> _sum(data)
150-
(<class 'decimal.Decimal' ...>, Fraction(6963, 10000), 4)
150+
(<class 'decimal.Decimal'>, Fraction(6963, 10000), 4)
151151
152152
Mixed types are currently treated as an error, except that int is
153153
allowed.

Lib/test/test_class.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -568,15 +568,5 @@ class B(A):
568568
a = A(hash(A.f)^(-1))
569569
hash(a.f)
570570

571-
def test_class_repr(self):
572-
# We should get the address of the object
573-
class A:
574-
pass
575-
576-
result = repr(A)
577-
self.assertRegex(result,
578-
"<class 'test.test_class.ClassTests.test_class_repr.<locals>.A'"
579-
" at 0x.+>")
580-
581571
if __name__ == '__main__':
582572
unittest.main()

Lib/test/test_cmd_line_script.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,7 @@ def _check_output(self, script_name, exit_code, data,
127127
print(printed_package)
128128
print(printed_argv0)
129129
print(printed_cwd)
130-
expected = printed_loader.encode('utf-8')
131-
idx = expected.find(b"at 0x")
132-
expected = expected[:idx]
133-
self.assertIn(expected, data)
130+
self.assertIn(printed_loader.encode('utf-8'), data)
134131
self.assertIn(printed_file.encode('utf-8'), data)
135132
self.assertIn(printed_package.encode('utf-8'), data)
136133
self.assertIn(printed_argv0.encode('utf-8'), data)
@@ -161,8 +158,6 @@ def _check_import_error(self, script_name, expected_msg,
161158
def test_dash_c_loader(self):
162159
rc, out, err = assert_python_ok("-c", "print(__loader__)")
163160
expected = repr(importlib.machinery.BuiltinImporter).encode("utf-8")
164-
idx = expected.find(b"at 0x")
165-
expected = expected[:idx]
166161
self.assertIn(expected, out)
167162

168163
def test_stdin_loader(self):
@@ -176,8 +171,6 @@ def test_stdin_loader(self):
176171
finally:
177172
out = kill_python(p)
178173
expected = repr(importlib.machinery.BuiltinImporter).encode("utf-8")
179-
idx = expected.find(b"at 0x")
180-
expected = expected[:idx]
181174
self.assertIn(expected, out)
182175

183176
@contextlib.contextmanager

Lib/test/test_defaultdict.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def test_repr(self):
6565
d2 = defaultdict(int)
6666
self.assertEqual(d2.default_factory, int)
6767
d2[12] = 42
68-
self.assertRegex(repr(d2), r"defaultdict\(<class 'int' at 0x.+>, {12: 42}\)")
68+
self.assertEqual(repr(d2), "defaultdict(<class 'int'>, {12: 42})")
6969
def foo(): return 43
7070
d3 = defaultdict(foo)
7171
self.assertTrue(d3.default_factory is foo)

Lib/test/test_descr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4544,9 +4544,9 @@ def method(cls):
45444544
pass
45454545
foo = Foo()
45464546
self.assertRegex(repr(foo.method), # access via instance
4547-
r"<bound method .*Foo\.method of <class '.*Foo' at 0x.+>>")
4547+
r"<bound method .*Foo\.method of <class '.*Foo'>>")
45484548
self.assertRegex(repr(Foo.method), # access via the class
4549-
r"<bound method .*Foo\.method of <class '.*Foo' at 0x.+>>")
4549+
r"<bound method .*Foo\.method of <class '.*Foo'>>")
45504550

45514551

45524552
class MyCallable:

Lib/test/test_descrtut.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ def merge(self, other):
3737
Here's the new type at work:
3838
3939
>>> print(defaultdict) # show our type
40-
<class 'test.test_descrtut.defaultdict' ...>
40+
<class 'test.test_descrtut.defaultdict'>
4141
>>> print(type(defaultdict)) # its metatype
42-
<class 'type' ...>
42+
<class 'type'>
4343
>>> a = defaultdict(default=0.0) # create an instance
4444
>>> print(a) # show the instance
4545
{}
4646
>>> print(type(a)) # show its type
47-
<class 'test.test_descrtut.defaultdict' ...>
47+
<class 'test.test_descrtut.defaultdict'>
4848
>>> print(a.__class__) # show its class
49-
<class 'test.test_descrtut.defaultdict' ...>
49+
<class 'test.test_descrtut.defaultdict'>
5050
>>> print(type(a) is a.__class__) # its type is its class
5151
True
5252
>>> a[1] = 3.25 # modify the instance
@@ -149,11 +149,11 @@ def merge(self, other):
149149
For instance of built-in types, x.__class__ is now the same as type(x):
150150
151151
>>> type([])
152-
<class 'list' ...>
152+
<class 'list'>
153153
>>> [].__class__
154-
<class 'list' ...>
154+
<class 'list'>
155155
>>> list
156-
<class 'list' ...>
156+
<class 'list'>
157157
>>> isinstance([], list)
158158
True
159159
>>> isinstance([], dict)
@@ -258,19 +258,19 @@ def merge(self, other):
258258
... print("classmethod", cls, y)
259259
260260
>>> C.foo(1)
261-
classmethod <class 'test.test_descrtut.C' ...> 1
261+
classmethod <class 'test.test_descrtut.C'> 1
262262
>>> c = C()
263263
>>> c.foo(1)
264-
classmethod <class 'test.test_descrtut.C' ...> 1
264+
classmethod <class 'test.test_descrtut.C'> 1
265265
266266
>>> class D(C):
267267
... pass
268268
269269
>>> D.foo(1)
270-
classmethod <class 'test.test_descrtut.D' ...> 1
270+
classmethod <class 'test.test_descrtut.D'> 1
271271
>>> d = D()
272272
>>> d.foo(1)
273-
classmethod <class 'test.test_descrtut.D' ...> 1
273+
classmethod <class 'test.test_descrtut.D'> 1
274274
275275
This prints "classmethod __main__.D 1" both times; in other words, the
276276
class passed as the first argument of foo() is the class involved in the
@@ -286,11 +286,11 @@ class passed as the first argument of foo() is the class involved in the
286286
287287
>>> E.foo(1)
288288
E.foo() called
289-
classmethod <class 'test.test_descrtut.C' ...> 1
289+
classmethod <class 'test.test_descrtut.C'> 1
290290
>>> e = E()
291291
>>> e.foo(1)
292292
E.foo() called
293-
classmethod <class 'test.test_descrtut.C' ...> 1
293+
classmethod <class 'test.test_descrtut.C'> 1
294294
295295
In this example, the call to C.foo() from E.foo() will see class C as its
296296
first argument, not class E. This is to be expected, since the call
@@ -350,7 +350,7 @@ class passed as the first argument of foo() is the class involved in the
350350
351351
>>> del property # unmask the builtin
352352
>>> property
353-
<class 'property' ...>
353+
<class 'property'>
354354
355355
>>> class C(object):
356356
... def __init__(self):
@@ -478,8 +478,7 @@ def test_main(verbose=None):
478478
# business is used the name can change depending on how the test is
479479
# invoked.
480480
from test import support, test_descrtut
481-
import doctest
482-
support.run_doctest(test_descrtut, verbose, optionflags=doctest.ELLIPSIS)
481+
support.run_doctest(test_descrtut, verbose)
483482

484483
# This part isn't needed for regrtest, but for running the test directly.
485484
if __name__ == "__main__":

Lib/test/test_doctest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2338,7 +2338,7 @@ def test_DocFileSuite():
23382338
`__file__` global, which is set to the name of the file
23392339
containing the tests:
23402340
2341-
>>> suite = doctest.DocFileSuite('test_doctest3.txt', optionflags=doctest.ELLIPSIS)
2341+
>>> suite = doctest.DocFileSuite('test_doctest3.txt')
23422342
>>> suite.run(unittest.TestResult())
23432343
<unittest.result.TestResult run=1 errors=0 failures=0>
23442344

Lib/test/test_doctest3.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
Here we check that `__file__` is provided:
33

44
>>> type(__file__)
5-
<class 'str' ...>
5+
<class 'str'>

Lib/test/test_functools.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,10 +1758,13 @@ class P:
17581758
c.Container.register(P)
17591759
with self.assertRaises(RuntimeError) as re_one:
17601760
g(p)
1761-
self.assertIn("Ambiguous dispatch:", str(re_one.exception))
1762-
self.assertIn("<class 'collections.abc.Container'", str(re_one.exception))
1763-
self.assertIn("<class 'collections.abc.Iterable'", str(re_one.exception))
1764-
1761+
self.assertIn(
1762+
str(re_one.exception),
1763+
(("Ambiguous dispatch: <class 'collections.abc.Container'> "
1764+
"or <class 'collections.abc.Iterable'>"),
1765+
("Ambiguous dispatch: <class 'collections.abc.Iterable'> "
1766+
"or <class 'collections.abc.Container'>")),
1767+
)
17651768
class Q(c.Sized):
17661769
def __len__(self):
17671770
return 0
@@ -1787,10 +1790,13 @@ def _(arg):
17871790
# perspective.
17881791
with self.assertRaises(RuntimeError) as re_two:
17891792
h(c.defaultdict(lambda: 0))
1790-
self.assertIn("Ambiguous dispatch:", str(re_two.exception))
1791-
self.assertIn("<class 'collections.abc.Container'", str(re_two.exception))
1792-
self.assertIn("<class 'collections.abc.Sized'", str(re_two.exception))
1793-
1793+
self.assertIn(
1794+
str(re_two.exception),
1795+
(("Ambiguous dispatch: <class 'collections.abc.Container'> "
1796+
"or <class 'collections.abc.Sized'>"),
1797+
("Ambiguous dispatch: <class 'collections.abc.Sized'> "
1798+
"or <class 'collections.abc.Container'>")),
1799+
)
17941800
class R(c.defaultdict):
17951801
pass
17961802
c.MutableSequence.register(R)
@@ -1824,10 +1830,13 @@ def __len__(self):
18241830
# There is no preference for registered versus inferred ABCs.
18251831
with self.assertRaises(RuntimeError) as re_three:
18261832
h(u)
1827-
self.assertIn("Ambiguous dispatch:", str(re_three.exception))
1828-
self.assertIn("<class 'collections.abc.Container'", str(re_three.exception))
1829-
self.assertIn("<class 'collections.abc.Sized'", str(re_three.exception))
1830-
1833+
self.assertIn(
1834+
str(re_three.exception),
1835+
(("Ambiguous dispatch: <class 'collections.abc.Container'> "
1836+
"or <class 'collections.abc.Sized'>"),
1837+
("Ambiguous dispatch: <class 'collections.abc.Sized'> "
1838+
"or <class 'collections.abc.Container'>")),
1839+
)
18311840
class V(c.Sized, S):
18321841
def __len__(self):
18331842
return 0

0 commit comments

Comments
 (0)