diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py index c189b4a36e5aa54..5c6154a347d3321 100644 --- a/Lib/test/test_regrtest.py +++ b/Lib/test/test_regrtest.py @@ -825,6 +825,23 @@ def test_list_tests(self): self.assertEqual(output.rstrip().splitlines(), tests) + def test_list_cases(self): + # test --list-cases + code = textwrap.dedent(""" + import unittest + + class Tests(unittest.TestCase): + def test_method1(self): + pass + def test_method2(self): + pass + """) + testname = self.create_test(code=code) + all_methods = ['%s.Tests.test_method1' % testname, + '%s.Tests.test_method2' % testname] + output = self.run_tests('--list-cases', testname) + self.assertEqual(output.splitlines(), all_methods) + def test_crashed(self): # Any code which causes a crash code = 'import faulthandler; faulthandler._sigsegv()' @@ -841,7 +858,6 @@ def parse_methods(self, output): return [match.group(1) for match in regex.finditer(output)] def test_matchfile(self): - # Any code which causes a crash code = textwrap.dedent(""" import unittest