GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-71339: Use new assertion methods in tests (GH-129046) · miss-islington/cpython@1b9bb43

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Lib/test
    • _test_embed_structseq.py
    • datetimetester.py
    • mapping_tests.py
    • pickletester.py
    • support
      • warnings_helper.py
    • test__osx_support.py
    • test_abstract_numbers.py
    • test_argparse.py
    • test_ast
      • test_ast.py
    • test_audit.py
    • test_base64.py
    • test_baseexception.py
    • test_binascii.py
    • test_binop.py
    • test_buffer.py
    • test_builtin.py
    • test_bytes.py
    • test_bz2.py
    • test_calendar.py
    • test_call.py
    • test_clinic.py
    • test_cmd_line.py
    • test_cmd_line_script.py
    • test_code_module.py
    • test_codecs.py
    • test_compileall.py
    • test_compiler_assemble.py
    • test_contextlib.py
    • test_contextlib_async.py
    • test_copy.py
    • test_coroutines.py
    • test_curses.py
    • test_dataclasses
      • __init__.py
    • test_dbm.py
    • test_dbm_sqlite3.py
    • test_deque.py
    • test_descr.py
    • test_dict.py
    • test_dynamicclassattribute.py
    • test_enum.py
    • test_errno.py
    • test_exception_group.py
    • test_exceptions.py
    • test_fileinput.py
    • test_gc.py
    • test_genericalias.py
    • test_genericpath.py
    • test_gzip.py
    • test_hashlib.py
    • test_inspect
      • test_inspect.py
    • test_int.py
    • test_io.py
    • test_json
      • test_fail.py
      • test_tool.py
    • test_launcher.py
    • test_lzma.py
    • test_memoryio.py
    • test_ordered_dict.py
    • test_os.py
    • test_pathlib
      • test_pathlib.py
    • test_peepholer.py
    • test_peg_generator
      • test_c_parser.py
      • test_pegen.py
    • test_perf_profiler.py
    • test_pickle.py
    • test_platform.py
    • test_posix.py
    • test_property.py
    • test_pulldom.py
    • test_pyclbr.py
    • test_pydoc
      • test_pydoc.py
    • test_random.py
    • test_re.py
    • test_reprlib.py
    • test_rlcompleter.py
    • test_runpy.py
    • test_scope.py
    • test_script_helper.py
    • test_set.py
    • test_shutil.py
    • test_site.py
    • test_socket.py
    • test_source_encoding.py
    • test_ssl.py
    • test_stat.py
    • test_statistics.py
    • test_structseq.py
    • test_subprocess.py
    • test_super.py
    • test_support.py
    • test_sys.py
    • test_sysconfig.py
    • test_tarfile.py
    • test_tempfile.py
    • test_termios.py
    • test_time.py
    • test_timeit.py
    • test_tkinter
      • support.py
      • test_misc.py
    • test_type_comments.py
    • test_types.py
    • test_unittest
      • test_case.py
    • test_userdict.py
    • test_venv.py
    • test_warnings
      • __init__.py
    • test_weakref.py
    • test_weakset.py
    • test_winconsoleio.py
    • test_with.py
    • test_wmi.py
    • test_wsgiref.py
    • test_xml_etree.py
    • test_xxlimited.py
    • test_zipapp.py
    • test_zipfile
      • test_core.py
    • test_zipimport.py
    • test_zoneinfo
      • test_zoneinfo.py

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Lib/test/_test_embed_structseq.py‎

Copy file name to clipboardExpand all lines: Lib/test/_test_embed_structseq.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def check_structseq(self, obj_type):
1111
# ob_refcnt
1212
self.assertGreaterEqual(sys.getrefcount(obj_type), 1)
1313
# tp_base
14-
self.assertTrue(issubclass(obj_type, tuple))
14+
self.assertIsSubclass(obj_type, tuple)
1515
# tp_bases
1616
self.assertEqual(obj_type.__bases__, (tuple,))
1717
# tp_dict
Collapse file

‎Lib/test/datetimetester.py‎

Copy file name to clipboardExpand all lines: Lib/test/datetimetester.py
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ class NotEnough(tzinfo):
183183
def __init__(self, offset, name):
184184
self.__offset = offset
185185
self.__name = name
186-
self.assertTrue(issubclass(NotEnough, tzinfo))
186+
self.assertIsSubclass(NotEnough, tzinfo)
187187
ne = NotEnough(3, "NotByALongShot")
188188
self.assertIsInstance(ne, tzinfo)
189189

@@ -232,7 +232,7 @@ def test_pickling_subclass(self):
232232
self.assertIs(type(derived), otype)
233233
self.assertEqual(derived.utcoffset(None), offset)
234234
self.assertEqual(derived.tzname(None), oname)
235-
self.assertFalse(hasattr(derived, 'spam'))
235+
self.assertNotHasAttr(derived, 'spam')
236236

237237
def test_issue23600(self):
238238
DSTDIFF = DSTOFFSET = timedelta(hours=1)
@@ -813,7 +813,7 @@ def test_roundtrip(self):
813813

814814
# Verify td -> string -> td identity.
815815
s = repr(td)
816-
self.assertTrue(s.startswith('datetime.'))
816+
self.assertStartsWith(s, 'datetime.')
817817
s = s[9:]
818818
td2 = eval(s)
819819
self.assertEqual(td, td2)
@@ -1231,7 +1231,7 @@ def test_roundtrip(self):
12311231
self.theclass.today()):
12321232
# Verify dt -> string -> date identity.
12331233
s = repr(dt)
1234-
self.assertTrue(s.startswith('datetime.'))
1234+
self.assertStartsWith(s, 'datetime.')
12351235
s = s[9:]
12361236
dt2 = eval(s)
12371237
self.assertEqual(dt, dt2)
@@ -2218,7 +2218,7 @@ def test_roundtrip(self):
22182218
self.theclass.now()):
22192219
# Verify dt -> string -> datetime identity.
22202220
s = repr(dt)
2221-
self.assertTrue(s.startswith('datetime.'))
2221+
self.assertStartsWith(s, 'datetime.')
22222222
s = s[9:]
22232223
dt2 = eval(s)
22242224
self.assertEqual(dt, dt2)
@@ -3672,7 +3672,7 @@ def test_roundtrip(self):
36723672

36733673
# Verify t -> string -> time identity.
36743674
s = repr(t)
3675-
self.assertTrue(s.startswith('datetime.'))
3675+
self.assertStartsWith(s, 'datetime.')
36763676
s = s[9:]
36773677
t2 = eval(s)
36783678
self.assertEqual(t, t2)
Collapse file

‎Lib/test/mapping_tests.py‎

Copy file name to clipboardExpand all lines: Lib/test/mapping_tests.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ def test_read(self):
7070
if not d: self.fail("Full mapping must compare to True")
7171
# keys(), items(), iterkeys() ...
7272
def check_iterandlist(iter, lst, ref):
73-
self.assertTrue(hasattr(iter, '__next__'))
74-
self.assertTrue(hasattr(iter, '__iter__'))
73+
self.assertHasAttr(iter, '__next__')
74+
self.assertHasAttr(iter, '__iter__')
7575
x = list(iter)
7676
self.assertTrue(set(x)==set(lst)==set(ref))
7777
check_iterandlist(iter(d.keys()), list(d.keys()),
Collapse file

‎Lib/test/pickletester.py‎

Copy file name to clipboardExpand all lines: Lib/test/pickletester.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3068,7 +3068,7 @@ def test_proto(self):
30683068
pickled = self.dumps(None, proto)
30693069
if proto >= 2:
30703070
proto_header = pickle.PROTO + bytes([proto])
3071-
self.assertTrue(pickled.startswith(proto_header))
3071+
self.assertStartsWith(pickled, proto_header)
30723072
else:
30733073
self.assertEqual(count_opcode(pickle.PROTO, pickled), 0)
30743074

@@ -5007,7 +5007,7 @@ def test_default_dispatch_table(self):
50075007
p = self.pickler_class(f, 0)
50085008
with self.assertRaises(AttributeError):
50095009
p.dispatch_table
5010-
self.assertFalse(hasattr(p, 'dispatch_table'))
5010+
self.assertNotHasAttr(p, 'dispatch_table')
50115011

50125012
def test_class_dispatch_table(self):
50135013
# A dispatch_table attribute can be specified class-wide
Collapse file

‎Lib/test/support/warnings_helper.py‎

Copy file name to clipboardExpand all lines: Lib/test/support/warnings_helper.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ def check_syntax_warning(testcase, statement, errtext='',
2323
testcase.assertEqual(len(warns), 1, warns)
2424

2525
warn, = warns
26-
testcase.assertTrue(issubclass(warn.category, SyntaxWarning),
27-
warn.category)
26+
testcase.assertIsSubclass(warn.category, SyntaxWarning)
2827
if errtext:
2928
testcase.assertRegex(str(warn.message), errtext)
3029
testcase.assertEqual(warn.filename, '<testcase>')
Collapse file

‎Lib/test/test__osx_support.py‎

Copy file name to clipboardExpand all lines: Lib/test/test__osx_support.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ def test__find_build_tool(self):
6666
'cc not found - check xcode-select')
6767

6868
def test__get_system_version(self):
69-
self.assertTrue(platform.mac_ver()[0].startswith(
70-
_osx_support._get_system_version()))
69+
self.assertStartsWith(platform.mac_ver()[0],
70+
_osx_support._get_system_version())
7171

7272
def test__remove_original_values(self):
7373
config_vars = {
Collapse file

‎Lib/test/test_abstract_numbers.py‎

Copy file name to clipboardExpand all lines: Lib/test/test_abstract_numbers.py
+15-15Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ def not_implemented(*args, **kwargs):
2424

2525
class TestNumbers(unittest.TestCase):
2626
def test_int(self):
27-
self.assertTrue(issubclass(int, Integral))
28-
self.assertTrue(issubclass(int, Rational))
29-
self.assertTrue(issubclass(int, Real))
30-
self.assertTrue(issubclass(int, Complex))
31-
self.assertTrue(issubclass(int, Number))
27+
self.assertIsSubclass(int, Integral)
28+
self.assertIsSubclass(int, Rational)
29+
self.assertIsSubclass(int, Real)
30+
self.assertIsSubclass(int, Complex)
31+
self.assertIsSubclass(int, Number)
3232

3333
self.assertEqual(7, int(7).real)
3434
self.assertEqual(0, int(7).imag)
@@ -38,23 +38,23 @@ def test_int(self):
3838
self.assertEqual(1, int(7).denominator)
3939

4040
def test_float(self):
41-
self.assertFalse(issubclass(float, Integral))
42-
self.assertFalse(issubclass(float, Rational))
43-
self.assertTrue(issubclass(float, Real))
44-
self.assertTrue(issubclass(float, Complex))
45-
self.assertTrue(issubclass(float, Number))
41+
self.assertNotIsSubclass(float, Integral)
42+
self.assertNotIsSubclass(float, Rational)
43+
self.assertIsSubclass(float, Real)
44+
self.assertIsSubclass(float, Complex)
45+
self.assertIsSubclass(float, Number)
4646

4747
self.assertEqual(7.3, float(7.3).real)
4848
self.assertEqual(0, float(7.3).imag)
4949
self.assertEqual(7.3, float(7.3).conjugate())
5050
self.assertEqual(-7.3, float(-7.3).conjugate())
5151

5252
def test_complex(self):
53-
self.assertFalse(issubclass(complex, Integral))
54-
self.assertFalse(issubclass(complex, Rational))
55-
self.assertFalse(issubclass(complex, Real))
56-
self.assertTrue(issubclass(complex, Complex))
57-
self.assertTrue(issubclass(complex, Number))
53+
self.assertNotIsSubclass(complex, Integral)
54+
self.assertNotIsSubclass(complex, Rational)
55+
self.assertNotIsSubclass(complex, Real)
56+
self.assertIsSubclass(complex, Complex)
57+
self.assertIsSubclass(complex, Number)
5858

5959
c1, c2 = complex(3, 2), complex(4,1)
6060
# XXX: This is not ideal, but see the comment in math_trunc().
Collapse file

‎Lib/test/test_argparse.py‎

Copy file name to clipboardExpand all lines: Lib/test/test_argparse.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6805,7 +6805,7 @@ class TestImportStar(TestCase):
68056805

68066806
def test(self):
68076807
for name in argparse.__all__:
6808-
self.assertTrue(hasattr(argparse, name))
6808+
self.assertHasAttr(argparse, name)
68096809

68106810
def test_all_exports_everything_but_modules(self):
68116811
items = [
Collapse file

‎Lib/test/test_ast/test_ast.py‎

Copy file name to clipboardExpand all lines: Lib/test/test_ast/test_ast.py
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -275,12 +275,12 @@ def test_alias(self):
275275
self.assertEqual(alias.end_col_offset, 17)
276276

277277
def test_base_classes(self):
278-
self.assertTrue(issubclass(ast.For, ast.stmt))
279-
self.assertTrue(issubclass(ast.Name, ast.expr))
280-
self.assertTrue(issubclass(ast.stmt, ast.AST))
281-
self.assertTrue(issubclass(ast.expr, ast.AST))
282-
self.assertTrue(issubclass(ast.comprehension, ast.AST))
283-
self.assertTrue(issubclass(ast.Gt, ast.AST))
278+
self.assertIsSubclass(ast.For, ast.stmt)
279+
self.assertIsSubclass(ast.Name, ast.expr)
280+
self.assertIsSubclass(ast.stmt, ast.AST)
281+
self.assertIsSubclass(ast.expr, ast.AST)
282+
self.assertIsSubclass(ast.comprehension, ast.AST)
283+
self.assertIsSubclass(ast.Gt, ast.AST)
284284

285285
def test_field_attr_existence(self):
286286
for name, item in ast.__dict__.items():
@@ -1101,7 +1101,7 @@ def test_copy_with_parents(self):
11011101
def test_replace_interface(self):
11021102
for klass in self.iter_ast_classes():
11031103
with self.subTest(klass=klass):
1104-
self.assertTrue(hasattr(klass, '__replace__'))
1104+
self.assertHasAttr(klass, '__replace__')
11051105

11061106
fields = set(klass._fields)
11071107
with self.subTest(klass=klass, fields=fields):
@@ -1330,7 +1330,7 @@ def test_replace_reject_known_custom_instance_fields_commits(self):
13301330
context = node.ctx
13311331

13321332
# explicit rejection of known instance fields
1333-
self.assertTrue(hasattr(node, 'extra'))
1333+
self.assertHasAttr(node, 'extra')
13341334
msg = "Name.__replace__ got an unexpected keyword argument 'extra'."
13351335
with self.assertRaisesRegex(TypeError, re.escape(msg)):
13361336
copy.replace(node, extra=1)
@@ -3071,7 +3071,7 @@ def test_FunctionDef(self):
30713071
with self.assertWarnsRegex(DeprecationWarning,
30723072
r"FunctionDef\.__init__ missing 1 required positional argument: 'name'"):
30733073
node = ast.FunctionDef(args=args)
3074-
self.assertFalse(hasattr(node, "name"))
3074+
self.assertNotHasAttr(node, "name")
30753075
self.assertEqual(node.decorator_list, [])
30763076
node = ast.FunctionDef(name='foo', args=args)
30773077
self.assertEqual(node.name, 'foo')
Collapse file

‎Lib/test/test_audit.py‎

Copy file name to clipboardExpand all lines: Lib/test/test_audit.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def test_socket(self):
134134
self.assertEqual(events[0][0], "socket.gethostname")
135135
self.assertEqual(events[1][0], "socket.__new__")
136136
self.assertEqual(events[2][0], "socket.bind")
137-
self.assertTrue(events[2][2].endswith("('127.0.0.1', 8080)"))
137+
self.assertEndsWith(events[2][2], "('127.0.0.1', 8080)")
138138

139139
def test_gc(self):
140140
returncode, events, stderr = self.run_python("test_gc")

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.