summaryrefslogtreecommitdiff
path: root/tests/test_parser.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-11-11 07:46:11 -0500
committerNed Batchelder <ned@nedbatchelder.com>2021-11-11 07:55:10 -0500
commite30a444a623870f1f35450186c6fc26d464b49f3 (patch)
tree6018f7be2e1f35c10087af13d4145e59688be4d5 /tests/test_parser.py
parent1b94835aac3268a32bfa4ce0df585dbb97457a06 (diff)
downloadpython-coveragepy-git-e30a444a623870f1f35450186c6fc26d464b49f3.tar.gz
test(refactor): convert looping tests to parametrize
Diffstat (limited to 'tests/test_parser.py')
-rw-r--r--tests/test_parser.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/tests/test_parser.py b/tests/test_parser.py
index 6dcfc00a..1e509035 100644
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -444,7 +444,10 @@ class ParserFileTest(CoverageTest):
parser.parse_source()
return parser
- def test_line_endings(self):
+ @pytest.mark.parametrize("slug, newline", [
+ ("unix", "\n"), ("dos", "\r\n"), ("mac", "\r"),
+ ])
+ def test_line_endings(self, slug, newline):
text = """\
# check some basic branch counting
class Foo:
@@ -458,12 +461,10 @@ class ParserFileTest(CoverageTest):
pass
"""
counts = { 2:2, 3:1, 4:2, 5:1, 7:1, 9:2, 10:1 }
- name_endings = (("unix", "\n"), ("dos", "\r\n"), ("mac", "\r"))
- for fname, newline in name_endings:
- fname = fname + ".py"
- self.make_file(fname, text, newline=newline)
- parser = self.parse_file(fname)
- assert parser.exit_counts() == counts, f"Wrong for {fname!r}"
+ fname = slug + ".py"
+ self.make_file(fname, text, newline=newline)
+ parser = self.parse_file(fname)
+ assert parser.exit_counts() == counts, f"Wrong for {fname!r}"
def test_encoding(self):
self.make_file("encoded.py", """\