summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2020-12-20 20:19:49 -0500
committerNed Batchelder <ned@nedbatchelder.com>2021-01-03 06:26:21 -0500
commit7ff93a9740da5dec4eba6c6cad288d25a472d75a (patch)
treeb81243f1508e4727dc28094c48be84ac6ae07706 /tests
parent12c5fcd57fd1cce3bc3563732f5502f5e943c0e0 (diff)
downloadpython-coveragepy-git-7ff93a9740da5dec4eba6c6cad288d25a472d75a.tar.gz
Use set literals
Diffstat (limited to 'tests')
-rw-r--r--tests/plugin1.py2
-rw-r--r--tests/test_collector.py2
-rw-r--r--tests/test_parser.py12
-rw-r--r--tests/test_plugins.py6
-rw-r--r--tests/test_results.py6
-rw-r--r--tests/test_testing.py6
6 files changed, 17 insertions, 17 deletions
diff --git a/tests/plugin1.py b/tests/plugin1.py
index a070af36..3283fbda 100644
--- a/tests/plugin1.py
+++ b/tests/plugin1.py
@@ -44,7 +44,7 @@ class FileTracer(coverage.FileTracer):
class FileReporter(coverage.FileReporter):
"""Dead-simple FileReporter."""
def lines(self):
- return set([105, 106, 107, 205, 206, 207])
+ return {105, 106, 107, 205, 206, 207}
def coverage_init(reg, options): # pylint: disable=unused-argument
diff --git a/tests/test_collector.py b/tests/test_collector.py
index 9989b229..f7e8a4c4 100644
--- a/tests/test_collector.py
+++ b/tests/test_collector.py
@@ -45,6 +45,6 @@ class CollectorTest(CoverageTest):
self.start_import_stop(cov, "f2")
# Double-check that our files were checked.
- abs_files = set(os.path.abspath(f) for f in should_trace_hook.filenames)
+ abs_files = {os.path.abspath(f) for f in should_trace_hook.filenames}
self.assertIn(os.path.abspath("f1.py"), abs_files)
self.assertIn(os.path.abspath("f2.py"), abs_files)
diff --git a/tests/test_parser.py b/tests/test_parser.py
index 0e6a0859..5fb3bc1f 100644
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -171,11 +171,11 @@ class PythonParserTest(CoverageTest):
def func(x=25):
return 26
""")
- raw_statements = set([3, 4, 5, 6, 8, 9, 10, 13, 15, 16, 17, 20, 22, 23, 25, 26])
+ raw_statements = {3, 4, 5, 6, 8, 9, 10, 13, 15, 16, 17, 20, 22, 23, 25, 26}
if env.PYBEHAVIOR.trace_decorated_def:
raw_statements.update([11, 19])
self.assertEqual(parser.raw_statements, raw_statements)
- self.assertEqual(parser.statements, set([8]))
+ self.assertEqual(parser.statements, {8})
def test_class_decorator_pragmas(self):
parser = self.parse_source("""\
@@ -188,8 +188,8 @@ class PythonParserTest(CoverageTest):
def __init__(self):
self.x = 8
""")
- self.assertEqual(parser.raw_statements, set([1, 2, 3, 5, 6, 7, 8]))
- self.assertEqual(parser.statements, set([1, 2, 3]))
+ self.assertEqual(parser.raw_statements, {1, 2, 3, 5, 6, 7, 8})
+ self.assertEqual(parser.statements, {1, 2, 3})
def test_empty_decorated_function(self):
parser = self.parse_source("""\
@@ -463,7 +463,7 @@ class ParserFileTest(CoverageTest):
""")
parser = self.parse_file("normal.py")
- self.assertEqual(parser.statements, set([1]))
+ self.assertEqual(parser.statements, {1})
self.make_file("abrupt.py", """\
out, err = subprocess.Popen(
@@ -476,4 +476,4 @@ class ParserFileTest(CoverageTest):
self.assertEqual(f.read()[-1], ")")
parser = self.parse_file("abrupt.py")
- self.assertEqual(parser.statements, set([1]))
+ self.assertEqual(parser.statements, {1})
diff --git a/tests/test_plugins.py b/tests/test_plugins.py
index d14f5c47..1f224695 100644
--- a/tests/test_plugins.py
+++ b/tests/test_plugins.py
@@ -400,12 +400,12 @@ class GoodFileTracerTest(FileTracerTest):
# have 7 lines in it. If render() was called with line number 4,
# then the plugin will claim that lines 4 and 5 were executed.
analysis = cov._analyze("foo_7.html")
- self.assertEqual(analysis.statements, set([1, 2, 3, 4, 5, 6, 7]))
+ self.assertEqual(analysis.statements, {1, 2, 3, 4, 5, 6, 7})
# Plugins don't do branch coverage yet.
self.assertEqual(analysis.has_arcs(), True)
self.assertEqual(analysis.arc_possibilities(), [])
- self.assertEqual(analysis.missing, set([1, 2, 3, 6, 7]))
+ self.assertEqual(analysis.missing, {1, 2, 3, 6, 7})
def test_plugin2_with_text_report(self):
self.make_render_and_caller()
@@ -553,7 +553,7 @@ class GoodFileTracerTest(FileTracerTest):
class MyReporter(coverage.FileReporter):
def lines(self):
- return set([99, 999, 9999])
+ return {99, 999, 9999}
def coverage_init(reg, options):
reg.add_file_tracer(Plugin())
diff --git a/tests/test_results.py b/tests/test_results.py
index 86806cfd..377c150b 100644
--- a/tests/test_results.py
+++ b/tests/test_results.py
@@ -114,7 +114,7 @@ def test_should_fail_under_invalid_value():
@pytest.mark.parametrize("statements, lines, result", [
- (set([1,2,3,4,5,10,11,12,13,14]), set([1,2,5,10,11,13,14]), "1-2, 5-11, 13-14"),
+ ({1,2,3,4,5,10,11,12,13,14}, {1,2,5,10,11,13,14}, "1-2, 5-11, 13-14"),
([1,2,3,4,5,10,11,12,13,14,98,99], [1,2,5,10,11,13,14,99], "1-2, 5-11, 13-14, 99"),
([1,2,3,4,98,99,100,101,102,103,104], [1,2,99,102,103,104], "1-2, 99, 102-104"),
([17], [17], "17"),
@@ -128,8 +128,8 @@ def test_format_lines(statements, lines, result):
@pytest.mark.parametrize("statements, lines, arcs, result", [
(
- set([1,2,3,4,5,10,11,12,13,14]),
- set([1,2,5,10,11,13,14]),
+ {1,2,3,4,5,10,11,12,13,14},
+ {1,2,5,10,11,13,14},
(),
"1-2, 5-11, 13-14"
),
diff --git a/tests/test_testing.py b/tests/test_testing.py
index 2fda956b..c5d46430 100644
--- a/tests/test_testing.py
+++ b/tests/test_testing.py
@@ -33,11 +33,11 @@ class TestingTest(TestCase):
def test_assert_count_equal(self):
self.assertCountEqual(set(), set())
- self.assertCountEqual(set([1,2,3]), set([3,1,2]))
+ self.assertCountEqual({1,2,3}, {3,1,2})
with self.assertRaises(AssertionError):
- self.assertCountEqual(set([1,2,3]), set())
+ self.assertCountEqual({1,2,3}, set())
with self.assertRaises(AssertionError):
- self.assertCountEqual(set([1,2,3]), set([4,5,6]))
+ self.assertCountEqual({1,2,3}, {4,5,6})
class CoverageTestTest(CoverageTest):