Skip to content

Commit f01e860

Browse files
committed
Remove deprecated classes, methods
Signed-off-by: Stephen Finucane <stephen@that.guru>
1 parent 8dc76f8 commit f01e860

File tree

11 files changed

+35
-137
lines changed

11 files changed

+35
-137
lines changed

NEWS

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,29 @@ Changes
1111

1212
* Drop support for Python 3.8. (Stephen Finucane)
1313

14+
* Remove a number of deprecated classes and methods. (Stephen Finucane)
15+
16+
* ``testtools.matchers``
17+
18+
* ``AfterPreproccessing`` (use ``AfterPreprocessing``)
19+
20+
* ``testtools.testcase``
21+
22+
* ``TestSkipped`` (use ``unittest.SkipTest``)
23+
* ``TestCase.skip`` (use ``TestCase.skipTest``)
24+
* ``TestCase.failUnlessEqual`` (use ``TestCase.assertEqual``)
25+
* ``TestCase.assertEquals`` (use ``TestCase.assertEqual``)
26+
* ``TestCase.failUnlessRaises`` (use ``TestCase.assertRaises``)
27+
* ``TestCase.assertItemsEqual`` (use ``TestCase.assertCountEqual``)
28+
29+
* ``testtools.testresult.real``
30+
31+
* ``domap`` (no replacement)
32+
33+
* ``testtools.twistedsupport._runtest``
34+
35+
* ``run_with_log_observers`` (no replacement)
36+
1437
2.7.2
1538
~~~~~
1639

testtools/matchers/_basic.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import operator
1919
from pprint import pformat
2020
import re
21-
import warnings
2221

2322
from ..compat import (
2423
text_repr,
@@ -71,24 +70,6 @@ def __init__(self, actual, mismatch_string, reference, reference_on_right=True):
7170
self._reference = reference
7271
self._reference_on_right = reference_on_right
7372

74-
@property
75-
def expected(self):
76-
warnings.warn(
77-
f"{self.__class__.__name__}.expected deprecated after 1.8.1",
78-
DeprecationWarning,
79-
stacklevel=2,
80-
)
81-
return self._reference
82-
83-
@property
84-
def other(self):
85-
warnings.warn(
86-
f"{self.__class__.__name__}.other deprecated after 1.8.1",
87-
DeprecationWarning,
88-
stacklevel=2,
89-
)
90-
return self._actual
91-
9273
def describe(self):
9374
actual = repr(self._actual)
9475
reference = repr(self._reference)

testtools/matchers/_exception.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import sys
1010

1111
from ._basic import MatchesRegex
12-
from ._higherorder import AfterPreproccessing
12+
from ._higherorder import AfterPreprocessing
1313
from ._impl import (
1414
Matcher,
1515
Mismatch,
@@ -47,7 +47,7 @@ def __init__(self, exception, value_re=None):
4747
Matcher.__init__(self)
4848
self.expected = exception
4949
if isinstance(value_re, str):
50-
value_re = AfterPreproccessing(str, MatchesRegex(value_re), False)
50+
value_re = AfterPreprocessing(str, MatchesRegex(value_re), False)
5151
self.value_re = value_re
5252
expected_type = type(self.expected)
5353
self._is_instance = not any(

testtools/matchers/_higherorder.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,6 @@ def match(self, value):
212212
return matcher.match(after)
213213

214214

215-
# This is the old, deprecated. spelling of the name, kept for backwards
216-
# compatibility.
217-
AfterPreproccessing = AfterPreprocessing
218-
219-
220215
class AllMatch:
221216
"""Matches if all provided values match the given matcher."""
222217

testtools/testcase.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import types
2323
import unittest
2424
from unittest.case import SkipTest
25-
import warnings
2625

2726
from testtools.compat import reraise
2827
from testtools import content
@@ -50,18 +49,6 @@
5049
)
5150

5251

53-
class TestSkipped(SkipTest):
54-
"""Raised within TestCase.run() when a test is skipped."""
55-
56-
def __init__(self, *args, **kwargs):
57-
warnings.warn(
58-
"Use SkipTest from unittest instead.",
59-
DeprecationWarning,
60-
stacklevel=2,
61-
)
62-
super().__init__(*args, **kwargs)
63-
64-
6552
class _UnexpectedSuccess(Exception):
6653
"""An unexpected success was raised.
6754
@@ -293,17 +280,6 @@ def __repr__(self):
293280
# We add id to the repr because it makes testing testtools easier.
294281
return f"<{self.id()} id=0x{id(self):0x}>"
295282

296-
def _deprecate(original_func):
297-
def deprecated_func(*args, **kwargs):
298-
warnings.warn(
299-
"Please use {0} instead.".format(original_func.__name__),
300-
DeprecationWarning,
301-
stacklevel=2,
302-
)
303-
return original_func(*args, **kwargs)
304-
305-
return deprecated_func
306-
307283
def addDetail(self, name, content_object):
308284
"""Add a detail to be reported with this test's outcome.
309285
@@ -355,15 +331,6 @@ def skipTest(self, reason):
355331
"""
356332
raise self.skipException(reason)
357333

358-
def skip(self, reason):
359-
"""DEPRECATED: Use skipTest instead."""
360-
warnings.warn(
361-
"Only valid in 1.8.1 and earlier. Use skipTest instead.",
362-
DeprecationWarning,
363-
stacklevel=2,
364-
)
365-
self.skipTest(reason)
366-
367334
def _formatTypes(self, classOrIterable):
368335
"""Format a class or a bunch of classes for display in an error."""
369336
className = getattr(classOrIterable, "__name__", None)
@@ -418,8 +385,6 @@ def assertEqual(self, expected, observed, message=""):
418385
matcher = _FlippedEquals(expected)
419386
self.assertThat(observed, matcher, message)
420387

421-
failUnlessEqual = assertEquals = _deprecate(assertEqual)
422-
423388
def assertIn(self, needle, haystack, message=""):
424389
"""Assert that needle is in haystack."""
425390
self.assertThat(haystack, Contains(needle), message)
@@ -495,8 +460,6 @@ def match(self, matchee):
495460
self.assertThat(our_callable, matcher)
496461
return capture.matchee
497462

498-
failUnlessRaises = _deprecate(assertRaises)
499-
500463
def assertThat(self, matchee, matcher, message="", verbose=False):
501464
"""Assert that matchee is matched by matcher.
502465
@@ -508,8 +471,6 @@ def assertThat(self, matchee, matcher, message="", verbose=False):
508471
if mismatch_error is not None:
509472
raise mismatch_error
510473

511-
assertItemsEqual = _deprecate(unittest.TestCase.assertCountEqual)
512-
513474
def addDetailUniqueName(self, name, content_object):
514475
"""Add a detail to the test, but ensure it's name is unique.
515476

testtools/testresult/real.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
from operator import methodcaller
2929
import sys
3030
import unittest
31-
import warnings
3231

3332
from testtools.compat import _b
3433
from testtools.content import (
@@ -436,21 +435,6 @@ def status(
436435
"""
437436

438437

439-
def domap(function, *sequences):
440-
"""A strict version of 'map' that's guaranteed to run on all inputs.
441-
442-
DEPRECATED since testtools 1.8.1: Internal code should use _strict_map.
443-
External code should look for other solutions for their strict mapping
444-
needs.
445-
"""
446-
warnings.warn(
447-
"domap deprecated since 1.8.1. Please implement your own strict map.",
448-
DeprecationWarning,
449-
stacklevel=2,
450-
)
451-
return _strict_map(function, *sequences)
452-
453-
454438
def _strict_map(function, *sequences):
455439
return list(map(function, *sequences))
456440

testtools/tests/test_testcase.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
attr,
4242
Nullary,
4343
WithAttributes,
44-
TestSkipped,
4544
)
4645
from testtools.testresult.doubles import (
4746
Python26TestResult,
@@ -304,7 +303,7 @@ def test_identicalIsEqual(self):
304303

305304
def test_nonIdenticalInUnequal(self):
306305
# TestCase's are not equal if they are not identical.
307-
self.assertNotEqual(TestCase(methodName="run"), TestCase(methodName="skip"))
306+
self.assertNotEqual(TestCase(methodName="run"), TestCase(methodName="skipTest"))
308307

309308

310309
class TestAssertions(TestCase):
@@ -804,16 +803,12 @@ def test_assertEqual_nice_formatting(self):
804803
]
805804
)
806805
self.assertFails(expected_error, self.assertEqual, a, b, message)
807-
self.assertFails(expected_error, self.assertEquals, a, b, message)
808-
self.assertFails(expected_error, self.failUnlessEqual, a, b, message)
809806

810807
def test_assertEqual_formatting_no_message(self):
811808
a = "cat"
812809
b = "dog"
813810
expected_error = "'cat' != 'dog'"
814811
self.assertFails(expected_error, self.assertEqual, a, b)
815-
self.assertFails(expected_error, self.assertEquals, a, b)
816-
self.assertFails(expected_error, self.failUnlessEqual, a, b)
817812

818813
def test_assertEqual_non_ascii_str_with_newlines(self):
819814
message = "Be careful mixing unicode and bytes"
@@ -1817,8 +1812,8 @@ def test_that_is_decorated_with_skip(self):
18171812
result = Python26TestResult(events)
18181813
try:
18191814
test = SkippingTest("test_that_is_decorated_with_skip")
1820-
except TestSkipped:
1821-
self.fail("TestSkipped raised")
1815+
except unittest.SkipTest:
1816+
self.fail("SkipTest raised")
18221817
test.run(result)
18231818
self.assertEqual("addSuccess", events[1][0])
18241819

@@ -1832,8 +1827,8 @@ def test_that_is_decorated_with_skipIf(self):
18321827
result = Python26TestResult(events)
18331828
try:
18341829
test = SkippingTest("test_that_is_decorated_with_skipIf")
1835-
except TestSkipped:
1836-
self.fail("TestSkipped raised")
1830+
except unittest.SkipTest:
1831+
self.fail("SkipTest raised")
18371832
test.run(result)
18381833
self.assertEqual("addSuccess", events[1][0])
18391834

@@ -1847,8 +1842,8 @@ def test_that_is_decorated_with_skipUnless(self):
18471842
result = Python26TestResult(events)
18481843
try:
18491844
test = SkippingTest("test_that_is_decorated_with_skipUnless")
1850-
except TestSkipped:
1851-
self.fail("TestSkipped raised")
1845+
except unittest.SkipTest:
1846+
self.fail("SkipTest raised")
18521847
test.run(result)
18531848
self.assertEqual("addSuccess", events[1][0])
18541849

@@ -1882,8 +1877,8 @@ def test_skipped(self):
18821877

18831878
try:
18841879
test = SkippingTestCase("test_skipped")
1885-
except TestSkipped:
1886-
self.fail("TestSkipped raised")
1880+
except unittest.SkipTest:
1881+
self.fail("SkipTest raised")
18871882
self.check_test_does_not_run_setup(test, reason)
18881883

18891884
def check_test_does_not_run_setup(self, test, reason):

testtools/tests/twistedsupport/test_runtest.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -961,19 +961,6 @@ def check_result(failure):
961961
)
962962

963963

964-
class TestRunWithLogObservers(NeedsTwistedTestCase):
965-
def test_restores_observers(self):
966-
from testtools.twistedsupport._runtest import run_with_log_observers
967-
from twisted.python import log
968-
969-
# Make sure there's at least one observer. This reproduces bug
970-
# #926189.
971-
log.addObserver(lambda *args: None)
972-
observers = list(log.theLogPublisher.observers)
973-
run_with_log_observers([], lambda: None)
974-
self.assertEqual(observers, log.theLogPublisher.observers)
975-
976-
977964
class TestNoTwistedLogObservers(NeedsTwistedTestCase):
978965
"""Tests for _NoTwistedLogObservers."""
979966

testtools/tests/twistedsupport/test_spinner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def test_preserve_signal_handler(self):
155155
signal.signal(sig, hdlr)
156156
spinner = self.make_spinner()
157157
spinner.run(self.make_timeout(), lambda: None)
158-
self.assertItemsEqual(new_hdlrs, list(map(signal.getsignal, signals)))
158+
self.assertCountEqual(new_hdlrs, list(map(signal.getsignal, signals)))
159159

160160
def test_timeout(self):
161161
# If the function takes too long to run, we raise a

testtools/twistedsupport/_runtest.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ def test_something(self):
2727
]
2828

2929
import io
30-
import warnings
3130
import sys
3231

3332
from fixtures import CompoundFixture, Fixture
@@ -182,18 +181,6 @@ def _setUp(self):
182181
)
183182

184183

185-
def run_with_log_observers(observers, function, *args, **kwargs):
186-
"""Run 'function' with the given Twisted log observers."""
187-
warnings.warn(
188-
"run_with_log_observers is deprecated since 1.8.2.",
189-
DeprecationWarning,
190-
stacklevel=2,
191-
)
192-
with _NoTwistedLogObservers():
193-
with _TwistedLogObservers(observers):
194-
return function(*args, **kwargs)
195-
196-
197184
# Observer of the Twisted log that we install during tests.
198185
#
199186
# This is a global so that users can call flush_logged_errors errors in their

0 commit comments

Comments
 (0)