Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated assertRaisesRegexp with assertRaisesRegex #335

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:

- name: Tests
run: |
python -m testtools.run testtools.tests.test_suite
python -W once -m testtools.run testtools.tests.test_suite

- name: Docs
run: |
Expand Down
2 changes: 1 addition & 1 deletion testtools/tests/matchers/test_filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def test_real_path(self):
try:
os.symlink(source, target)
except (AttributeError, NotImplementedError):
self.skip("No symlink support")
self.skipTest("No symlink support")
self.assertThat(source, SamePath(target))
self.assertThat(target, SamePath(source))

Expand Down
2 changes: 1 addition & 1 deletion testtools/tests/samplecases.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def _failure(case):


def _skip(case):
case.skip('arbitrary skip message')
case.skipTest('arbitrary skip message')


def _expected_failure(case):
Expand Down
2 changes: 1 addition & 1 deletion testtools/tests/test_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class TestUnicodeOutputStream(testtools.TestCase):
def setUp(self):
super().setUp()
if sys.platform == "cli":
self.skip("IronPython shouldn't wrap streams to do encoding")
self.skipTest("IronPython shouldn't wrap streams to do encoding")

def test_no_encoding_becomes_ascii(self):
"""A stream with no encoding attribute gets ascii/replace strings"""
Expand Down
22 changes: 11 additions & 11 deletions testtools/tests/test_testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,24 +386,24 @@ def foo():
Raises(
MatchesException(self.failureException, '.*{!r}.*'.format(foo))))

def test_assertRaisesRegexp(self):
# assertRaisesRegexp asserts that function raises particular exception
def test_assertRaisesRegex(self):
# assertRaisesRegex asserts that function raises particular exception
# with particular message.
self.assertRaisesRegexp(RuntimeError, r"M\w*e", self.raiseError,
RuntimeError, "Message")
self.assertRaisesRegex(RuntimeError, r"M\w*e", self.raiseError,
RuntimeError, "Message")

def test_assertRaisesRegexp_wrong_error_type(self):
def test_assertRaisesRegex_wrong_error_type(self):
# If function raises an exception of unexpected type,
# assertRaisesRegexp re-raises it.
self.assertRaises(ValueError, self.assertRaisesRegexp, RuntimeError,
# assertRaisesRegex re-raises it.
self.assertRaises(ValueError, self.assertRaisesRegex, RuntimeError,
r"M\w*e", self.raiseError, ValueError, "Message")

def test_assertRaisesRegexp_wrong_message(self):
def test_assertRaisesRegex_wrong_message(self):
# If function raises an exception with unexpected message
# assertRaisesRegexp fails.
# assertRaisesRegex fails.
self.assertFails(
'"Expected" does not match "Observed"',
self.assertRaisesRegexp, RuntimeError, "Expected",
self.assertRaisesRegex, RuntimeError, "Expected",
self.raiseError, RuntimeError, "Observed")

def assertFails(self, message, function, *args, **kwargs):
Expand Down Expand Up @@ -1455,7 +1455,7 @@ class TestSkipping(TestCase):

def test_skip_causes_skipException(self):
self.assertThat(
lambda: self.skip("Skip this test"),
lambda: self.skipTest("Skip this test"),
Raises(MatchesException(self.skipException)))

def test_can_use_skipTest(self):
Expand Down
6 changes: 3 additions & 3 deletions testtools/tests/test_testresult.py
Original file line number Diff line number Diff line change
Expand Up @@ -1566,7 +1566,7 @@ def test_stopTestRun_not_successful_unexpected_success(self):
DocTestMatches("...\nFAILED (failures=1)\n", doctest.ELLIPSIS))

def test_stopTestRun_shows_details(self):
self.skip("Disabled per bug 1188420")
self.skipTest("Disabled per bug 1188420")
def run_tests():
self.result.startTestRun()
make_erroring_test().run(self.result)
Expand Down Expand Up @@ -2518,7 +2518,7 @@ def _write_module(self, name, encoding, contents):
# the file without closing it which breaks non-refcounted pythons
codecs.lookup(encoding)
except LookupError:
self.skip("Encoding unsupported by implementation: %r" % encoding)
self.skipTest("Encoding unsupported by implementation: %r" % encoding)
f = codecs.open(os.path.join(self.dir, name + ".py"), "w", encoding)
try:
f.write(contents)
Expand Down Expand Up @@ -2568,7 +2568,7 @@ def _get_sample_text(self, encoding="unicode_internal"):
return u, u
except (LookupError, UnicodeError):
pass
self.skip("Could not find a sample text for encoding: %r" % encoding)
self.skipTest("Could not find a sample text for encoding: %r" % encoding)

def _as_output(self, text):
return text
Expand Down
2 changes: 1 addition & 1 deletion testtools/tests/test_testsuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class TestFixtureSuite(TestCase):
def setUp(self):
super().setUp()
if FunctionFixture is None:
self.skip("Need fixtures")
self.skipTest("Need fixtures")

def test_fixture_suite(self):
log = []
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ deps =
extras =
test
commands =
python -m testtools.run testtools.tests.test_suite
python -W once -m testtools.run testtools.tests.test_suite