From 76495e034313cff0c01ed69b3f147e82293d30ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jelmer=20Vernoo=C4=B3?= Date: Mon, 13 Jan 2025 12:58:02 +0000 Subject: [PATCH] Bump ruff to 0.9.1 --- pyproject.toml | 2 +- testtools/tests/matchers/test_dict.py | 29 ++++++------------- testtools/tests/matchers/test_doctest.py | 2 +- testtools/tests/matchers/test_higherorder.py | 4 +-- testtools/tests/matchers/test_impl.py | 4 +-- testtools/tests/test_assert_that.py | 15 ++++------ testtools/tests/test_testcase.py | 15 ++++------ testtools/tests/test_testresult.py | 12 ++------ .../tests/twistedsupport/test_matchers.py | 2 +- testtools/twistedsupport/_deferred.py | 2 +- testtools/twistedsupport/_matchers.py | 2 +- 11 files changed, 30 insertions(+), 59 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6de4d9cf..f78d9d4f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,4 +71,4 @@ __version__ = {version_tuple!r} [project.optional-dependencies] test = ["testscenarios", "testresources"] twisted = ["Twisted", "fixtures"] -dev = ["ruff==0.8.6"] +dev = ["ruff==0.9.1"] diff --git a/testtools/tests/matchers/test_dict.py b/testtools/tests/matchers/test_dict.py index 6d159681..1e5a7aef 100644 --- a/testtools/tests/matchers/test_dict.py +++ b/testtools/tests/matchers/test_dict.py @@ -127,15 +127,12 @@ class TestMatchesDict(TestCase, TestMatchersInterface): describe_examples = [ ( - "Missing: {\n" - " 'baz': Not(Equals('qux')),\n" - " 'foo': Equals('bar'),\n" - "}", + "Missing: {\n 'baz': Not(Equals('qux')),\n 'foo': Equals('bar'),\n}", {}, matches_matcher, ), ( - "Differences: {\n" " 'baz': 'qux' matches Equals('qux'),\n" "}", + "Differences: {\n 'baz': 'qux' matches Equals('qux'),\n}", {"foo": "bar", "baz": "qux"}, matches_matcher, ), @@ -148,17 +145,12 @@ class TestMatchesDict(TestCase, TestMatchersInterface): matches_matcher, ), ( - "Extra: {\n" " 'cat': 'dog',\n" "}", + "Extra: {\n 'cat': 'dog',\n}", {"foo": "bar", "baz": "quux", "cat": "dog"}, matches_matcher, ), ( - "Extra: {\n" - " 'cat': 'dog',\n" - "}\n" - "Missing: {\n" - " 'baz': Not(Equals('qux')),\n" - "}", + "Extra: {\n 'cat': 'dog',\n}\nMissing: {\n 'baz': Not(Equals('qux')),\n}", {"foo": "bar", "cat": "dog"}, matches_matcher, ), @@ -192,15 +184,12 @@ class TestContainsDict(TestCase, TestMatchersInterface): describe_examples = [ ( - "Missing: {\n" - " 'baz': Not(Equals('qux')),\n" - " 'foo': Equals('bar'),\n" - "}", + "Missing: {\n 'baz': Not(Equals('qux')),\n 'foo': Equals('bar'),\n}", {}, matches_matcher, ), ( - "Differences: {\n" " 'baz': 'qux' matches Equals('qux'),\n" "}", + "Differences: {\n 'baz': 'qux' matches Equals('qux'),\n}", {"foo": "bar", "baz": "qux"}, matches_matcher, ), @@ -213,7 +202,7 @@ class TestContainsDict(TestCase, TestMatchersInterface): matches_matcher, ), ( - "Missing: {\n" " 'baz': Not(Equals('qux')),\n" "}", + "Missing: {\n 'baz': Not(Equals('qux')),\n}", {"foo": "bar", "cat": "dog"}, matches_matcher, ), @@ -247,7 +236,7 @@ class TestContainedByDict(TestCase, TestMatchersInterface): describe_examples = [ ( - "Differences: {\n" " 'baz': 'qux' matches Equals('qux'),\n" "}", + "Differences: {\n 'baz': 'qux' matches Equals('qux'),\n}", {"foo": "bar", "baz": "qux"}, matches_matcher, ), @@ -260,7 +249,7 @@ class TestContainedByDict(TestCase, TestMatchersInterface): matches_matcher, ), ( - "Extra: {\n" " 'cat': 'dog',\n" "}", + "Extra: {\n 'cat': 'dog',\n}", {"foo": "bar", "cat": "dog"}, matches_matcher, ), diff --git a/testtools/tests/matchers/test_doctest.py b/testtools/tests/matchers/test_doctest.py index ceceef17..3d443af4 100644 --- a/testtools/tests/matchers/test_doctest.py +++ b/testtools/tests/matchers/test_doctest.py @@ -26,7 +26,7 @@ class TestDocTestMatchesInterface(TestCase, TestMatchersInterface): describe_examples = [ ( - "Expected:\n Ran 1 tests in ...s\nGot:\n" " Ran 1 test in 0.123s\n", + "Expected:\n Ran 1 tests in ...s\nGot:\n Ran 1 test in 0.123s\n", "Ran 1 test in 0.123s", DocTestMatches("Ran 1 tests in ...s", doctest.ELLIPSIS), ) diff --git a/testtools/tests/matchers/test_higherorder.py b/testtools/tests/matchers/test_higherorder.py index 44a25e59..1bebe1a5 100644 --- a/testtools/tests/matchers/test_higherorder.py +++ b/testtools/tests/matchers/test_higherorder.py @@ -43,7 +43,7 @@ class TestAllMatch(TestCase, TestMatchersInterface): describe_examples = [ ( - "Differences: [\n" "11 >= 10\n" "10 >= 10\n" "]", + "Differences: [\n11 >= 10\n10 >= 10\n]", [11, 9, 10], AllMatch(LessThan(10)), ), @@ -72,7 +72,7 @@ class TestAnyMatch(TestCase, TestMatchersInterface): describe_examples = [ ( - "Differences: [\n" "11 != 7\n" "9 != 7\n" "10 != 7\n" "]", + "Differences: [\n11 != 7\n9 != 7\n10 != 7\n]", [11, 9, 10], AnyMatch(Equals(7)), ), diff --git a/testtools/tests/matchers/test_impl.py b/testtools/tests/matchers/test_impl.py index 942335c7..eb534ee3 100644 --- a/testtools/tests/matchers/test_impl.py +++ b/testtools/tests/matchers/test_impl.py @@ -67,7 +67,7 @@ def test_verbose_description(self): matcher = Equals(3) mismatch = matcher.match(2) e = MismatchError(matchee, matcher, mismatch, True) - expected = "Match failed. Matchee: %r\n" "Matcher: %s\n" "Difference: %s\n" % ( + expected = "Match failed. Matchee: %r\nMatcher: %s\nDifference: %s\n" % ( matchee, matcher, matcher.match(matchee).describe(), @@ -80,7 +80,7 @@ def test_verbose_unicode(self): matchee = "\xa7" matcher = Equals("a") mismatch = matcher.match(matchee) - expected = "Match failed. Matchee: %s\n" "Matcher: %s\n" "Difference: %s\n" % ( + expected = "Match failed. Matchee: %s\nMatcher: %s\nDifference: %s\n" % ( text_repr(matchee), matcher, mismatch.describe(), diff --git a/testtools/tests/test_assert_that.py b/testtools/tests/test_assert_that.py index 8dae8618..4dce0376 100644 --- a/testtools/tests/test_assert_that.py +++ b/testtools/tests/test_assert_that.py @@ -86,7 +86,7 @@ def test_assertThat_message_is_annotated(self): def test_assertThat_verbose_output(self): matchee = "foo" matcher = Equals("bar") - expected = "Match failed. Matchee: %r\n" "Matcher: %s\n" "Difference: %s\n" % ( + expected = "Match failed. Matchee: %r\nMatcher: %s\nDifference: %s\n" % ( matchee, matcher, matcher.match(matchee).describe(), @@ -124,15 +124,10 @@ def test_assertThat_verbose_unicode(self): # unicode strings, we can still provide a meaningful error. matchee = "\xa7" matcher = Equals("a") - expected = ( - "Match failed. Matchee: %s\n" - "Matcher: %s\n" - "Difference: %s\n\n" - % ( - repr(matchee).replace("\\xa7", matchee), - matcher, - matcher.match(matchee).describe(), - ) + expected = "Match failed. Matchee: %s\nMatcher: %s\nDifference: %s\n\n" % ( + repr(matchee).replace("\\xa7", matchee), + matcher, + matcher.match(matchee).describe(), ) e = self.assertRaises( self.failureException, diff --git a/testtools/tests/test_testcase.py b/testtools/tests/test_testcase.py index 37dc825d..644537bd 100644 --- a/testtools/tests/test_testcase.py +++ b/testtools/tests/test_testcase.py @@ -692,7 +692,7 @@ def test_assertThat_message_is_annotated(self): def test_assertThat_verbose_output(self): matchee = "foo" matcher = Equals("bar") - expected = "Match failed. Matchee: %r\n" "Matcher: %s\n" "Difference: %s\n" % ( + expected = "Match failed. Matchee: %r\nMatcher: %s\nDifference: %s\n" % ( matchee, matcher, matcher.match(matchee).describe(), @@ -776,15 +776,10 @@ def test_assertThat_verbose_unicode(self): # unicode strings, we can still provide a meaningful error. matchee = "\xa7" matcher = Equals("a") - expected = ( - "Match failed. Matchee: %s\n" - "Matcher: %s\n" - "Difference: %s\n\n" - % ( - repr(matchee).replace("\\xa7", matchee), - matcher, - matcher.match(matchee).describe(), - ) + expected = "Match failed. Matchee: %s\nMatcher: %s\nDifference: %s\n\n" % ( + repr(matchee).replace("\\xa7", matchee), + matcher, + matcher.match(matchee).describe(), ) e = self.assertRaises( self.failureException, self.assertThat, matchee, matcher, verbose=True diff --git a/testtools/tests/test_testresult.py b/testtools/tests/test_testresult.py index 2cf240f3..429df27b 100644 --- a/testtools/tests/test_testresult.py +++ b/testtools/tests/test_testresult.py @@ -3042,7 +3042,7 @@ def test_syntax_error_line_iso_8859_1(self): self.assertIn( self._as_output( #'bad.py", line 2\n' - " ! = 0 # %s\n" " ^\n" "SyntaxError: " % (text,) + " ! = 0 # %s\n ^\nSyntaxError: " % (text,) ), textoutput, ) @@ -3176,15 +3176,7 @@ def test_multiple_text_content(self): self.assertThat( string, Equals( - "attachment: {{{\n" - "foo\n" - "foo\n" - "}}}\n" - "\n" - "attachment-1: {{{\n" - "bar\n" - "bar\n" - "}}}\n" + "attachment: {{{\nfoo\nfoo\n}}}\n\nattachment-1: {{{\nbar\nbar\n}}}\n" ), ) diff --git a/testtools/tests/twistedsupport/test_matchers.py b/testtools/tests/twistedsupport/test_matchers.py index 3dac008e..689cafd4 100644 --- a/testtools/tests/twistedsupport/test_matchers.py +++ b/testtools/tests/twistedsupport/test_matchers.py @@ -139,7 +139,7 @@ def test_not_fired_fails(self): self.match(arbitrary_matcher, deferred), mismatches( Equals( - ("Success result expected on %r, found no result " "instead") + ("Success result expected on %r, found no result instead") % (deferred,) ) ), diff --git a/testtools/twistedsupport/_deferred.py b/testtools/twistedsupport/_deferred.py index 909e2f8f..50fdaa40 100644 --- a/testtools/twistedsupport/_deferred.py +++ b/testtools/twistedsupport/_deferred.py @@ -50,7 +50,7 @@ class ImpossibleDeferredError(Exception): """Raised if a Deferred somehow triggers both a success and a failure.""" def __init__(self, deferred, successes, failures): - msg = "Impossible condition on %r, got both success (%r) and " "failure (%r)" + msg = "Impossible condition on %r, got both success (%r) and failure (%r)" super().__init__(msg % (deferred, successes, failures)) diff --git a/testtools/twistedsupport/_matchers.py b/testtools/twistedsupport/_matchers.py index 3b2923f2..2b7cc9cf 100644 --- a/testtools/twistedsupport/_matchers.py +++ b/testtools/twistedsupport/_matchers.py @@ -88,7 +88,7 @@ def _got_failure(deferred, failure): @staticmethod def _got_no_result(deferred): return Mismatch( - "Success result expected on %r, found no result " "instead" % (deferred,) + "Success result expected on %r, found no result instead" % (deferred,) ) def match(self, deferred):