Skip to content

Commit

Permalink
Merge pull request #418 from testing-cabal/ruff-0.9.1
Browse files Browse the repository at this point in the history
Bump ruff to 0.9.1
  • Loading branch information
jelmer authored Jan 13, 2025
2 parents a6d205d + 76495e0 commit 6a902e7
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 59 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
29 changes: 9 additions & 20 deletions testtools/tests/matchers/test_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
Expand All @@ -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,
),
Expand Down Expand Up @@ -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,
),
Expand All @@ -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,
),
Expand Down Expand Up @@ -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,
),
Expand All @@ -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,
),
Expand Down
2 changes: 1 addition & 1 deletion testtools/tests/matchers/test_doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
Expand Down
4 changes: 2 additions & 2 deletions testtools/tests/matchers/test_higherorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
),
Expand Down Expand Up @@ -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)),
),
Expand Down
4 changes: 2 additions & 2 deletions testtools/tests/matchers/test_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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(),
Expand Down
15 changes: 5 additions & 10 deletions testtools/tests/test_assert_that.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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,
Expand Down
15 changes: 5 additions & 10 deletions testtools/tests/test_testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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
Expand Down
12 changes: 2 additions & 10 deletions testtools/tests/test_testresult.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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"
),
)

Expand Down
2 changes: 1 addition & 1 deletion testtools/tests/twistedsupport/test_matchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,)
)
),
Expand Down
2 changes: 1 addition & 1 deletion testtools/twistedsupport/_deferred.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))


Expand Down
2 changes: 1 addition & 1 deletion testtools/twistedsupport/_matchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 6a902e7

Please sign in to comment.