From 4d9624f5221972d3ae05617b332437818772562d Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Mon, 7 Feb 2022 09:55:47 +0000 Subject: doc: Remove references to unittest2 Signed-off-by: Stephen Finucane --- doc/for-framework-folk.rst | 5 +---- doc/for-test-authors.rst | 2 -- setup.cfg | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/doc/for-framework-folk.rst b/doc/for-framework-folk.rst index 2fd6804..fb55ce1 100644 --- a/doc/for-framework-folk.rst +++ b/doc/for-framework-folk.rst @@ -133,10 +133,7 @@ DecorateTestCaseResult This object calls out to your code when ``run`` / ``__call__`` are called and allows the result object that will be used to run the test to be altered. This is very useful when working with a test runner that doesn't know your test case -requirements. For instance, it can be used to inject a ``unittest2`` compatible -adapter when someone attempts to run your test suite with a ``TestResult`` that -does not support ``addSkip`` or other ``unittest2`` methods. Similarly it can -aid the migration to ``StreamResult``. +requirements. For instance, it can aid the migration to ``StreamResult``. e.g.:: diff --git a/doc/for-test-authors.rst b/doc/for-test-authors.rst index 5261154..27ea212 100644 --- a/doc/for-test-authors.rst +++ b/doc/for-test-authors.rst @@ -84,7 +84,6 @@ of them will happily run testtools tests. In particular: * testrepository_ * Trial_ * nose_ -* unittest2_ * `zope.testrunner`_ (aka zope.testing) From now on, we'll assume that you know how to run your tests. @@ -1463,7 +1462,6 @@ Here, ``repr(nullary)`` will be the same as ``repr(f)``. .. _testrepository: https://launchpad.net/testrepository .. _Trial: http://twistedmatrix.com/documents/current/core/howto/testing.html .. _nose: http://somethingaboutorange.com/mrl/projects/nose/ -.. _unittest2: http://pypi.python.org/pypi/unittest2 .. _zope.testrunner: http://pypi.python.org/pypi/zope.testrunner/ .. _xUnit test patterns: http://xunitpatterns.com/ .. _fixtures: http://pypi.python.org/pypi/fixtures diff --git a/setup.cfg b/setup.cfg index c31f8f3..822b098 100644 --- a/setup.cfg +++ b/setup.cfg @@ -5,7 +5,7 @@ home_page = https://github.com/testing-cabal/testtools description_file = doc/overview.rst author = Jonathan M. Lange author_email = jml+testtools@mumak.net -classifier = +classifier = Development Status :: 5 - Production/Stable Intended Audience :: Developers License :: OSI Approved :: MIT License -- cgit v1.2.1 From b39e940949cbff28aa5aabbac4ddaf53c8a8c351 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Mon, 10 Jan 2022 18:58:44 +0200 Subject: Upgrade asserts with teyit for Python 3.11 compatibility --- testtools/tests/test_content.py | 2 +- testtools/tests/test_monkey.py | 50 +++++++++++++++++++++------------------- testtools/tests/test_testcase.py | 18 ++++++++------- 3 files changed, 37 insertions(+), 33 deletions(-) diff --git a/testtools/tests/test_content.py b/testtools/tests/test_content.py index 35231b6..f507f3f 100644 --- a/testtools/tests/test_content.py +++ b/testtools/tests/test_content.py @@ -287,7 +287,7 @@ class TestStacktraceContent(TestCase): def test_top_frame_is_skipped_when_no_stack_is_specified(self): actual = StacktraceContent().as_text() - self.assertTrue('testtools/content.py' not in actual) + self.assertNotIn('testtools/content.py', actual) class TestAttachFile(TestCase): diff --git a/testtools/tests/test_monkey.py b/testtools/tests/test_monkey.py index ceae685..2196be3 100644 --- a/testtools/tests/test_monkey.py +++ b/testtools/tests/test_monkey.py @@ -33,9 +33,9 @@ class MonkeyPatcherTest(TestCase): # We can't assert that all state is unchanged, but at least we can # check our test object. - self.assertEquals(self.original_object.foo, self.test_object.foo) - self.assertEquals(self.original_object.bar, self.test_object.bar) - self.assertEquals(self.original_object.baz, self.test_object.baz) + self.assertEqual(self.original_object.foo, self.test_object.foo) + self.assertEqual(self.original_object.bar, self.test_object.bar) + self.assertEqual(self.original_object.baz, self.test_object.baz) def test_construct_with_patches(self): # Constructing a 'MonkeyPatcher' with patches adds all of the given @@ -43,23 +43,23 @@ class MonkeyPatcherTest(TestCase): patcher = MonkeyPatcher((self.test_object, 'foo', 'haha'), (self.test_object, 'bar', 'hehe')) patcher.patch() - self.assertEquals('haha', self.test_object.foo) - self.assertEquals('hehe', self.test_object.bar) - self.assertEquals(self.original_object.baz, self.test_object.baz) + self.assertEqual('haha', self.test_object.foo) + self.assertEqual('hehe', self.test_object.bar) + self.assertEqual(self.original_object.baz, self.test_object.baz) def test_patch_existing(self): # Patching an attribute that exists sets it to the value defined in the # patch. self.monkey_patcher.add_patch(self.test_object, 'foo', 'haha') self.monkey_patcher.patch() - self.assertEquals(self.test_object.foo, 'haha') + self.assertEqual(self.test_object.foo, 'haha') def test_patch_non_existing(self): # Patching a non-existing attribute sets it to the value defined in # the patch. self.monkey_patcher.add_patch(self.test_object, 'doesntexist', 'value') self.monkey_patcher.patch() - self.assertEquals(self.test_object.doesntexist, 'value') + self.assertEqual(self.test_object.doesntexist, 'value') def test_restore_non_existing(self): # Restoring a value that didn't exist before the patch deletes the @@ -76,18 +76,18 @@ class MonkeyPatcherTest(TestCase): self.monkey_patcher.add_patch(self.test_object, 'foo', 'blah') self.monkey_patcher.add_patch(self.test_object, 'foo', 'BLAH') self.monkey_patcher.patch() - self.assertEquals(self.test_object.foo, 'BLAH') + self.assertEqual(self.test_object.foo, 'BLAH') self.monkey_patcher.restore() - self.assertEquals(self.test_object.foo, self.original_object.foo) + self.assertEqual(self.test_object.foo, self.original_object.foo) def test_restore_twice_is_a_no_op(self): # Restoring an already-restored monkey patch is a no-op. self.monkey_patcher.add_patch(self.test_object, 'foo', 'blah') self.monkey_patcher.patch() self.monkey_patcher.restore() - self.assertEquals(self.test_object.foo, self.original_object.foo) + self.assertEqual(self.test_object.foo, self.original_object.foo) self.monkey_patcher.restore() - self.assertEquals(self.test_object.foo, self.original_object.foo) + self.assertEqual(self.test_object.foo, self.original_object.foo) def test_run_with_patches_decoration(self): # run_with_patches runs the given callable, passing in all arguments @@ -99,8 +99,8 @@ class MonkeyPatcherTest(TestCase): return 'foo' result = self.monkey_patcher.run_with_patches(f, 1, 2, c=10) - self.assertEquals('foo', result) - self.assertEquals([(1, 2, 10)], log) + self.assertEqual('foo', result) + self.assertEqual([(1, 2, 10)], log) def test_repeated_run_with_patches(self): # We can call the same function with run_with_patches more than @@ -111,28 +111,30 @@ class MonkeyPatcherTest(TestCase): self.monkey_patcher.add_patch(self.test_object, 'foo', 'haha') result = self.monkey_patcher.run_with_patches(f) - self.assertEquals( + self.assertEqual( ('haha', self.original_object.bar, self.original_object.baz), - result) + result + ) result = self.monkey_patcher.run_with_patches(f) - self.assertEquals( + self.assertEqual( ('haha', self.original_object.bar, self.original_object.baz), - result) + result + ) def test_run_with_patches_restores(self): # run_with_patches restores the original values after the function has # executed. self.monkey_patcher.add_patch(self.test_object, 'foo', 'haha') - self.assertEquals(self.original_object.foo, self.test_object.foo) + self.assertEqual(self.original_object.foo, self.test_object.foo) self.monkey_patcher.run_with_patches(lambda: None) - self.assertEquals(self.original_object.foo, self.test_object.foo) + self.assertEqual(self.original_object.foo, self.test_object.foo) def test_run_with_patches_restores_on_exception(self): # run_with_patches restores the original values even when the function # raises an exception. def _(): - self.assertEquals(self.test_object.foo, 'haha') - self.assertEquals(self.test_object.bar, 'blahblah') + self.assertEqual(self.test_object.foo, 'haha') + self.assertEqual(self.test_object.bar, 'blahblah') raise RuntimeError("Something went wrong!") self.monkey_patcher.add_patch(self.test_object, 'foo', 'haha') @@ -140,8 +142,8 @@ class MonkeyPatcherTest(TestCase): self.assertThat(lambda:self.monkey_patcher.run_with_patches(_), Raises(MatchesException(RuntimeError("Something went wrong!")))) - self.assertEquals(self.test_object.foo, self.original_object.foo) - self.assertEquals(self.test_object.bar, self.original_object.bar) + self.assertEqual(self.test_object.foo, self.original_object.foo) + self.assertEqual(self.test_object.bar, self.original_object.bar) class TestPatchHelper(TestCase): diff --git a/testtools/tests/test_testcase.py b/testtools/tests/test_testcase.py index 014f680..9f8d194 100644 --- a/testtools/tests/test_testcase.py +++ b/testtools/tests/test_testcase.py @@ -349,9 +349,11 @@ class TestAssertions(TestCase): exception = self.assertRaises(RuntimeError, raiseError) self.assertEqual(1, len(raisedExceptions)) - self.assertTrue( - exception is raisedExceptions[0], - "{!r} is not {!r}".format(exception, raisedExceptions[0])) + self.assertIs( + exception, + raisedExceptions[0], + '{!r} is not {!r}'.format(exception, raisedExceptions[0]) + ) def test_assertRaises_with_multiple_exceptions(self): # assertRaises((ExceptionOne, ExceptionTwo), function) asserts that @@ -516,7 +518,7 @@ class TestAssertions(TestCase): def test_assertIs(self): # assertIs asserts that an object is identical to another object. - self.assertIs(None, None) + self.assertIsNone(None) some_list = [42] self.assertIs(some_list, some_list) some_object = object() @@ -645,7 +647,7 @@ class TestAssertions(TestCase): test = Test("test") result = test.run() details = test.getDetails() - self.assertTrue("Failed expectation" in details) + self.assertIn('Failed expectation', details) def test__force_failure_fails_test(self): class Test(TestCase): @@ -1097,7 +1099,7 @@ class TestExpectedFailure(TestWithDetails): class ReferenceTest(TestCase): @unittest.expectedFailure def test_fails_expectedly(self): - self.assertEquals(1, 0) + self.assertEqual(1, 0) test = ReferenceTest('test_fails_expectedly') result = test.run() @@ -1107,7 +1109,7 @@ class TestExpectedFailure(TestWithDetails): class ReferenceTest(TestCase): @unittest.expectedFailure def test_passes_unexpectedly(self): - self.assertEquals(1, 1) + self.assertEqual(1, 1) test = ReferenceTest('test_passes_unexpectedly') result = test.run() @@ -1687,7 +1689,7 @@ class TestSkipping(TestCase): def check_test_does_not_run_setup(self, test, reason): result = test.run() self.assertTrue(result.wasSuccessful()) - self.assertTrue(reason in result.skip_reasons, result.skip_reasons) + self.assertIn(reason, result.skip_reasons, result.skip_reasons) self.assertFalse(test.setup_ran) def test_testtools_skip_decorator_does_not_run_setUp(self): -- cgit v1.2.1 From b68af1b04c78e60cb8c8cc722ced6ab6db50833c Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Mon, 25 Apr 2022 15:57:13 +0100 Subject: Fix inclusion of NEWS in Sphinx documentation `make html-sphinx` previously warned: .../doc/index.rst:20: WARNING: toctree contains reference to nonexisting document 'news' --- doc/news.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/news.rst diff --git a/doc/news.rst b/doc/news.rst new file mode 100644 index 0000000..4264fd6 --- /dev/null +++ b/doc/news.rst @@ -0,0 +1 @@ +.. include:: ../NEWS -- cgit v1.2.1