summaryrefslogtreecommitdiff
path: root/tests/coveragetest.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/coveragetest.py')
-rw-r--r--tests/coveragetest.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/tests/coveragetest.py b/tests/coveragetest.py
index dbadd226..ed3f1839 100644
--- a/tests/coveragetest.py
+++ b/tests/coveragetest.py
@@ -139,7 +139,7 @@ class CoverageTest(
# Make them into multi-line strings so we can see what's going wrong.
s1 = arcs_to_arcz_repr(a1)
s2 = arcs_to_arcz_repr(a2)
- self.assertMultiLineEqual(s1, s2, msg)
+ assert s1 == s2, msg
def check_coverage(
self, text, lines=None, missing="", report="",
@@ -198,7 +198,7 @@ class CoverageTest(
if isinstance(lines[0], int):
# lines is just a list of numbers, it must match the statements
# found in the code.
- self.assertEqual(statements, lines)
+ assert statements == lines
else:
# lines is a list of possible line number lists, one of them
# must match.
@@ -210,7 +210,7 @@ class CoverageTest(
missing_formatted = analysis.missing_formatted()
if isinstance(missing, string_class):
- self.assertEqual(missing_formatted, missing)
+ assert missing_formatted == missing
else:
for missing_list in missing:
if missing_formatted == missing_list:
@@ -244,7 +244,7 @@ class CoverageTest(
frep = StringIO()
cov.report(mod, file=frep, show_missing=True)
rep = " ".join(frep.getvalue().split("\n")[2].split()[1:])
- self.assertEqual(report, rep)
+ assert report == rep
return cov
@@ -313,19 +313,19 @@ class CoverageTest(
def assert_exists(self, fname):
"""Assert that `fname` is a file that exists."""
msg = "File %r should exist" % fname
- self.assertTrue(os.path.exists(fname), msg)
+ assert os.path.exists(fname), msg
def assert_doesnt_exist(self, fname):
"""Assert that `fname` is a file that doesn't exist."""
msg = "File %r shouldn't exist" % fname
- self.assertTrue(not os.path.exists(fname), msg)
+ assert not os.path.exists(fname), msg
def assert_file_count(self, pattern, count):
"""Assert that there are `count` files matching `pattern`."""
files = sorted(glob.glob(pattern))
msg = "There should be {} files matching {!r}, but there are these: {}"
msg = msg.format(count, pattern, files)
- self.assertEqual(len(files), count, msg)
+ assert len(files) == count, msg
def assert_starts_with(self, s, prefix, msg=None):
"""Assert that `s` starts with `prefix`."""
@@ -335,8 +335,8 @@ class CoverageTest(
def assert_recent_datetime(self, dt, seconds=10, msg=None):
"""Assert that `dt` marks a time at most `seconds` seconds ago."""
age = datetime.datetime.now() - dt
- self.assertGreaterEqual(age.total_seconds(), 0, msg)
- self.assertLessEqual(age.total_seconds(), seconds, msg)
+ assert age.total_seconds() >= 0, msg
+ assert age.total_seconds() <= seconds, msg
def command_line(self, args, ret=OK):
"""Run `args` through the command line.
@@ -351,7 +351,7 @@ class CoverageTest(
"""
ret_actual = command_line(args)
- self.assertEqual(ret_actual, ret)
+ assert ret_actual == ret
# Some distros rename the coverage command, and need a way to indicate
# their new command name to the tests. This is here for them to override,
@@ -454,13 +454,13 @@ class CoverageTest(
def report_from_command(self, cmd):
"""Return the report from the `cmd`, with some convenience added."""
report = self.run_command(cmd).replace('\\', '/')
- self.assertNotIn("error", report.lower())
+ assert "error" not in report.lower()
return report
def report_lines(self, report):
"""Return the lines of the report, as a list."""
lines = report.split('\n')
- self.assertEqual(lines[-1], "")
+ assert lines[-1] == ""
return lines[:-1]
def line_count(self, report):