summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-03-06 09:11:26 -0500
committerNed Batchelder <ned@nedbatchelder.com>2021-03-06 09:11:26 -0500
commit26e2f9b6f22fd29efe3e4bd7df63acc144950c80 (patch)
tree09da3a29fa3a555233ea445c35e32f95413b3156
parent4ce893437c9e777216cac981c5909572fa10d9df (diff)
downloadpython-coveragepy-git-26e2f9b6f22fd29efe3e4bd7df63acc144950c80.tar.gz
refactor: no need for specialized assert_starts_with method
-rw-r--r--tests/coveragetest.py5
-rw-r--r--tests/test_process.py2
-rw-r--r--tests/test_setup.py2
-rw-r--r--tests/test_testing.py11
4 files changed, 2 insertions, 18 deletions
diff --git a/tests/coveragetest.py b/tests/coveragetest.py
index 906886f2..0bfc7123 100644
--- a/tests/coveragetest.py
+++ b/tests/coveragetest.py
@@ -302,11 +302,6 @@ class CoverageTest(
msg = msg.format(count, pattern, files)
assert len(files) == count, msg
- def assert_starts_with(self, s, prefix, msg=None):
- """Assert that `s` starts with `prefix`."""
- if not s.startswith(prefix):
- self.fail(msg or ("%r doesn't start with %r" % (s, prefix)))
-
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
diff --git a/tests/test_process.py b/tests/test_process.py
index 9f07b9cc..548f3dd7 100644
--- a/tests/test_process.py
+++ b/tests/test_process.py
@@ -1208,7 +1208,7 @@ class PydocTest(CoverageTest):
# Run pydoc.
out = self.run_command("python -m pydoc " + name)
# It should say "Help on..", and not have a traceback
- self.assert_starts_with(out, "Help on ")
+ assert out.startswith("Help on ")
assert "Traceback" not in out
# All of the lines in the docstring should be there somewhere.
diff --git a/tests/test_setup.py b/tests/test_setup.py
index febc383e..30456191 100644
--- a/tests/test_setup.py
+++ b/tests/test_setup.py
@@ -39,7 +39,7 @@ class SetupPyTest(CoverageTest):
classifiers = setup_args['classifiers']
assert len(classifiers) > 7
- self.assert_starts_with(classifiers[-1], "Development Status ::")
+ assert classifiers[-1].startswith("Development Status ::")
assert "Programming Language :: Python :: %d" % sys.version_info[:1] in classifiers
assert "Programming Language :: Python :: %d.%d" % sys.version_info[:2] in classifiers
diff --git a/tests/test_testing.py b/tests/test_testing.py
index f5d9f942..1e30fa2f 100644
--- a/tests/test_testing.py
+++ b/tests/test_testing.py
@@ -86,17 +86,6 @@ class CoverageTestTest(CoverageTest):
with pytest.raises(AssertionError, match=msg):
self.assert_file_count("*.q", 10)
- def test_assert_startwith(self):
- self.assert_starts_with("xyzzy", "xy")
- self.assert_starts_with("xyz\nabc", "xy")
- self.assert_starts_with("xyzzy", ("x", "z"))
- msg = re.escape("'xyz' doesn't start with 'a'")
- with pytest.raises(AssertionError, match=msg):
- self.assert_starts_with("xyz", "a")
- msg = re.escape("'xyz\\nabc' doesn't start with 'a'")
- with pytest.raises(AssertionError, match=msg):
- self.assert_starts_with("xyz\nabc", "a")
-
def test_assert_recent_datetime(self):
def now_delta(seconds):
"""Make a datetime `seconds` seconds from now."""