Skip to content

Commit df86fcb

Browse files
authored
Merge pull request #335 from hugovk/fix-assertRaisesRegexp-deprecation
Replace deprecated assertRaisesRegexp with assertRaisesRegex
2 parents 4fc915b + 8e3e360 commit df86fcb

File tree

8 files changed

+20
-20
lines changed

8 files changed

+20
-20
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
4040
- name: Tests
4141
run: |
42-
python -m testtools.run testtools.tests.test_suite
42+
python -W once -m testtools.run testtools.tests.test_suite
4343
4444
- name: Docs
4545
run: |

testtools/tests/matchers/test_filesystem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def test_real_path(self):
223223
try:
224224
os.symlink(source, target)
225225
except (AttributeError, NotImplementedError):
226-
self.skip("No symlink support")
226+
self.skipTest("No symlink support")
227227
self.assertThat(source, SamePath(target))
228228
self.assertThat(target, SamePath(source))
229229

testtools/tests/samplecases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def _failure(case):
9696

9797

9898
def _skip(case):
99-
case.skip('arbitrary skip message')
99+
case.skipTest('arbitrary skip message')
100100

101101

102102
def _expected_failure(case):

testtools/tests/test_compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class TestUnicodeOutputStream(testtools.TestCase):
3939
def setUp(self):
4040
super().setUp()
4141
if sys.platform == "cli":
42-
self.skip("IronPython shouldn't wrap streams to do encoding")
42+
self.skipTest("IronPython shouldn't wrap streams to do encoding")
4343

4444
def test_no_encoding_becomes_ascii(self):
4545
"""A stream with no encoding attribute gets ascii/replace strings"""

testtools/tests/test_testcase.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -386,24 +386,24 @@ def foo():
386386
Raises(
387387
MatchesException(self.failureException, '.*{!r}.*'.format(foo))))
388388

389-
def test_assertRaisesRegexp(self):
390-
# assertRaisesRegexp asserts that function raises particular exception
389+
def test_assertRaisesRegex(self):
390+
# assertRaisesRegex asserts that function raises particular exception
391391
# with particular message.
392-
self.assertRaisesRegexp(RuntimeError, r"M\w*e", self.raiseError,
393-
RuntimeError, "Message")
392+
self.assertRaisesRegex(RuntimeError, r"M\w*e", self.raiseError,
393+
RuntimeError, "Message")
394394

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

401-
def test_assertRaisesRegexp_wrong_message(self):
401+
def test_assertRaisesRegex_wrong_message(self):
402402
# If function raises an exception with unexpected message
403-
# assertRaisesRegexp fails.
403+
# assertRaisesRegex fails.
404404
self.assertFails(
405405
'"Expected" does not match "Observed"',
406-
self.assertRaisesRegexp, RuntimeError, "Expected",
406+
self.assertRaisesRegex, RuntimeError, "Expected",
407407
self.raiseError, RuntimeError, "Observed")
408408

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

14561456
def test_skip_causes_skipException(self):
14571457
self.assertThat(
1458-
lambda: self.skip("Skip this test"),
1458+
lambda: self.skipTest("Skip this test"),
14591459
Raises(MatchesException(self.skipException)))
14601460

14611461
def test_can_use_skipTest(self):

testtools/tests/test_testresult.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,7 +1566,7 @@ def test_stopTestRun_not_successful_unexpected_success(self):
15661566
DocTestMatches("...\nFAILED (failures=1)\n", doctest.ELLIPSIS))
15671567

15681568
def test_stopTestRun_shows_details(self):
1569-
self.skip("Disabled per bug 1188420")
1569+
self.skipTest("Disabled per bug 1188420")
15701570
def run_tests():
15711571
self.result.startTestRun()
15721572
make_erroring_test().run(self.result)
@@ -2518,7 +2518,7 @@ def _write_module(self, name, encoding, contents):
25182518
# the file without closing it which breaks non-refcounted pythons
25192519
codecs.lookup(encoding)
25202520
except LookupError:
2521-
self.skip("Encoding unsupported by implementation: %r" % encoding)
2521+
self.skipTest("Encoding unsupported by implementation: %r" % encoding)
25222522
f = codecs.open(os.path.join(self.dir, name + ".py"), "w", encoding)
25232523
try:
25242524
f.write(contents)
@@ -2568,7 +2568,7 @@ def _get_sample_text(self, encoding="unicode_internal"):
25682568
return u, u
25692569
except (LookupError, UnicodeError):
25702570
pass
2571-
self.skip("Could not find a sample text for encoding: %r" % encoding)
2571+
self.skipTest("Could not find a sample text for encoding: %r" % encoding)
25722572

25732573
def _as_output(self, text):
25742574
return text

testtools/tests/test_testsuite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ class TestFixtureSuite(TestCase):
253253
def setUp(self):
254254
super().setUp()
255255
if FunctionFixture is None:
256-
self.skip("Need fixtures")
256+
self.skipTest("Need fixtures")
257257

258258
def test_fixture_suite(self):
259259
log = []

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ deps =
1010
extras =
1111
test
1212
commands =
13-
python -m testtools.run testtools.tests.test_suite
13+
python -W once -m testtools.run testtools.tests.test_suite

0 commit comments

Comments
 (0)