Skip to content

Commit 8aa3393

Browse files
committed
Reformat code with black
[poetry] Move dev dependencies to "group.dev"
1 parent 5ec3083 commit 8aa3393

File tree

5 files changed

+212
-39
lines changed

5 files changed

+212
-39
lines changed

asserts/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,5 +1501,6 @@ def append(self, item):
15011501

15021502
class Exists:
15031503
"""Helper class for existence checks in assert_json_subset()."""
1504+
15041505
def __init__(self, member_name: str) -> None:
15051506
self.member_name = member_name

asserts/__init__.pyi

Lines changed: 100 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ class AssertRaisesContext(Generic[_E]):
2727
def __init__(self, exception: Type[_E], msg_fmt: Text = ...) -> None: ...
2828
def __enter__(self: _S) -> _S: ...
2929
def __exit__(
30-
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
30+
self,
31+
exc_type: Optional[Type[BaseException]],
32+
exc_val: Optional[BaseException],
33+
exc_tb: Optional[TracebackType],
3134
) -> bool: ...
3235
def format_message(self, default_msg: Text) -> Text: ...
3336
def add_test(self, cb: Callable[[_E], Any]) -> None: ...
@@ -36,24 +39,35 @@ class AssertRaisesContext(Generic[_E]):
3639

3740
class AssertRaisesErrnoContext(AssertRaisesContext[_E]):
3841
expected_errno: int
39-
def __init__(self, exception: Type[_E], expected_errno: int, msg_fmt: Text = ...) -> None: ...
42+
def __init__(
43+
self, exception: Type[_E], expected_errno: int, msg_fmt: Text = ...
44+
) -> None: ...
4045

4146
class AssertRaisesRegexContext(AssertRaisesContext[_E]):
4247
pattern: Text
43-
def __init__(self, exception: Type[_E], pattern: Text, msg_fmt: Text = ...) -> None: ...
48+
def __init__(
49+
self, exception: Type[_E], pattern: Text, msg_fmt: Text = ...
50+
) -> None: ...
4451

4552
class AssertWarnsContext:
46-
def __init__(self, warning_class: Type[Warning], msg_fmt: Text = ...) -> None: ...
53+
def __init__(
54+
self, warning_class: Type[Warning], msg_fmt: Text = ...
55+
) -> None: ...
4756
def __enter__(self: _S) -> _S: ...
4857
def __exit__(
49-
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType],
58+
self,
59+
exc_type: Optional[Type[BaseException]],
60+
exc_val: Optional[BaseException],
61+
exc_tb: Optional[TracebackType],
5062
) -> None: ...
5163
def format_message(self) -> Text: ...
5264
def add_test(self, cb: Callable[[Warning], bool]) -> None: ...
5365

5466
class AssertWarnsRegexContext(AssertWarnsContext):
5567
pattern: Text
56-
def __init__(self, warning_class: Type[Warning], msg_fmt: Text = ...) -> None: ...
68+
def __init__(
69+
self, warning_class: Type[Warning], msg_fmt: Text = ...
70+
) -> None: ...
5771

5872
def fail(msg: Text = ...) -> NoReturn: ...
5973
def assert_true(expr: Any, msg_fmt: Text = ...) -> None: ...
@@ -64,35 +78,93 @@ def assert_is_none(expr: Any, msg_fmt: Text = ...) -> None: ...
6478
def assert_is_not_none(expr: Any, msg_fmt: Text = ...) -> None: ...
6579
def assert_equal(first: Any, second: Any, msg_fmt: Text = ...) -> None: ...
6680
def assert_not_equal(first: Any, second: Any, msg_fmt: Text = ...) -> None: ...
67-
def assert_almost_equal(first: float, second: float, msg_fmt: Text = ..., places: int = ..., delta: float = ...) -> None: ...
68-
def assert_not_almost_equal(first: float, second: float, msg_fmt: Text = ..., places: int = ..., delta: float = ...) -> None: ...
69-
def assert_dict_equal(first: dict, second: dict, key_msg_fmt: Text = ..., value_msg_fmt: Text = ...) -> None: ...
70-
def assert_dict_superset(first: dict, second: dict, key_msg_fmt: Text = ..., value_msg_fmt: Text = ...) -> None: ...
81+
def assert_almost_equal(
82+
first: float,
83+
second: float,
84+
msg_fmt: Text = ...,
85+
places: int = ...,
86+
delta: float = ...,
87+
) -> None: ...
88+
def assert_not_almost_equal(
89+
first: float,
90+
second: float,
91+
msg_fmt: Text = ...,
92+
places: int = ...,
93+
delta: float = ...,
94+
) -> None: ...
95+
def assert_dict_equal(
96+
first: dict,
97+
second: dict,
98+
key_msg_fmt: Text = ...,
99+
value_msg_fmt: Text = ...,
100+
) -> None: ...
101+
def assert_dict_superset(
102+
first: dict,
103+
second: dict,
104+
key_msg_fmt: Text = ...,
105+
value_msg_fmt: Text = ...,
106+
) -> None: ...
71107
def assert_less(first: Any, second: Any, msg_fmt: Text = ...) -> None: ...
72-
def assert_less_equal(first: Any, second: Any, msg_fmt: Text = ...) -> None: ...
108+
def assert_less_equal(
109+
first: Any, second: Any, msg_fmt: Text = ...
110+
) -> None: ...
73111
def assert_greater(first: Any, second: Any, msg_fmt: Text = ...) -> None: ...
74-
def assert_greater_equal(first: Any, second: Any, msg_fmt: Text = ...) -> None: ...
75-
def assert_regex(text: Text, regex: Union[Text, Pattern[Text]], msg_fmt: Text = ...) -> None: ...
112+
def assert_greater_equal(
113+
first: Any, second: Any, msg_fmt: Text = ...
114+
) -> None: ...
115+
def assert_regex(
116+
text: Text, regex: Union[Text, Pattern[Text]], msg_fmt: Text = ...
117+
) -> None: ...
76118
def assert_is(first: Any, second: Any, msg_fmt: Text = ...) -> None: ...
77119
def assert_is_not(first: Any, second: Any, msg_fmt: Text = ...) -> None: ...
78-
def assert_in(first: Any, second: Container[Any], msg_fmt: Text = ...) -> None: ...
79-
def assert_not_in(first: Any, second: Container[Any], msg_fmt: Text = ...) -> None: ...
80-
def assert_between(lower_bound: Any, upper_bound: Any, expr: Any, msg_fmt: Text = ...) -> None: ...
81-
def assert_is_instance(obj: Any, cls: Union[type, Tuple[type, ...]], msg_fmt: Text = ...) -> None: ...
82-
def assert_not_is_instance(obj: Any, cls: Union[type, Tuple[type, ...]], msg_fmt: Text = ...) -> None: ...
83-
def assert_count_equal(sequence1: Iterable[Any], sequence2: Iterable[Any], msg_fmt: Text = ...) -> None: ...
120+
def assert_in(
121+
first: Any, second: Container[Any], msg_fmt: Text = ...
122+
) -> None: ...
123+
def assert_not_in(
124+
first: Any, second: Container[Any], msg_fmt: Text = ...
125+
) -> None: ...
126+
def assert_between(
127+
lower_bound: Any, upper_bound: Any, expr: Any, msg_fmt: Text = ...
128+
) -> None: ...
129+
def assert_is_instance(
130+
obj: Any, cls: Union[type, Tuple[type, ...]], msg_fmt: Text = ...
131+
) -> None: ...
132+
def assert_not_is_instance(
133+
obj: Any, cls: Union[type, Tuple[type, ...]], msg_fmt: Text = ...
134+
) -> None: ...
135+
def assert_count_equal(
136+
sequence1: Iterable[Any], sequence2: Iterable[Any], msg_fmt: Text = ...
137+
) -> None: ...
84138
def assert_has_attr(obj: Any, attribute: str, msg_fmt: Text = ...) -> None: ...
85-
def assert_datetime_about_now(actual: Optional[datetime.datetime], msg_fmt: Text = ...) -> None: ...
86-
def assert_datetime_about_now_utc(actual: Optional[datetime.datetime], msg_fmt: Text = ...) -> None: ...
87-
def assert_raises(exception: Type[BaseException], msg_fmt: Text = ...) -> AssertRaisesContext: ...
139+
def assert_datetime_about_now(
140+
actual: Optional[datetime.datetime], msg_fmt: Text = ...
141+
) -> None: ...
142+
def assert_datetime_about_now_utc(
143+
actual: Optional[datetime.datetime], msg_fmt: Text = ...
144+
) -> None: ...
145+
def assert_raises(
146+
exception: Type[BaseException], msg_fmt: Text = ...
147+
) -> AssertRaisesContext: ...
88148
def assert_raises_regex(
89-
exception: Type[BaseException], regex: Union[Text, Pattern[Text]], msg_fmt: Text = ...
149+
exception: Type[BaseException],
150+
regex: Union[Text, Pattern[Text]],
151+
msg_fmt: Text = ...,
152+
) -> AssertRaisesContext: ...
153+
def assert_raises_errno(
154+
exception: Type[BaseException], errno: int, msg_fmt: Text = ...
90155
) -> AssertRaisesContext: ...
91-
def assert_raises_errno(exception: Type[BaseException], errno: int, msg_fmt: Text = ...) -> AssertRaisesContext: ...
92-
def assert_succeeds(exception: Type[BaseException], msg_fmt: Text = ...) -> ContextManager: ...
93-
def assert_warns(warning_type: Type[Warning], msg_fmt: Text = ...) -> AssertWarnsContext: ...
94-
def assert_warns_regex(warning_type: Type[Warning], regex: Text, msg_fmt: Text = ...) -> AssertWarnsContext: ...
95-
def assert_json_subset(first: Union[dict, list], second: Union[dict, list, str, bytes]) -> None: ...
156+
def assert_succeeds(
157+
exception: Type[BaseException], msg_fmt: Text = ...
158+
) -> ContextManager: ...
159+
def assert_warns(
160+
warning_type: Type[Warning], msg_fmt: Text = ...
161+
) -> AssertWarnsContext: ...
162+
def assert_warns_regex(
163+
warning_type: Type[Warning], regex: Text, msg_fmt: Text = ...
164+
) -> AssertWarnsContext: ...
165+
def assert_json_subset(
166+
first: Union[dict, list], second: Union[dict, list, str, bytes]
167+
) -> None: ...
96168

97169
class Exists:
98170
member_name: str

poetry.lock

Lines changed: 94 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ include = ["*/py.typed", "*.pyi"]
1919
[tool.poetry.dependencies]
2020
python = ">=3.7"
2121

22-
[tool.poetry.dev-dependencies]
22+
[tool.poetry.group.dev.dependencies]
23+
black = "^22.10.0"
2324
flake8 = "~5.0.4"
2425
mypy = "0.982"
2526

test_asserts.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
assert_succeeds,
4444
assert_warns,
4545
assert_warns_regex,
46-
assert_json_subset, Exists,
46+
assert_json_subset,
47+
Exists,
4748
)
4849

4950

@@ -732,8 +733,10 @@ def test_assert_between__too_high__custom_message(self):
732733
# assert_is_instance()
733734

734735
def _is_instance_message(self, expr, expected_type, real_type):
735-
expected_message = "{!r} is an instance of <class {}>, expected {}".format(
736-
expr, real_type, expected_type
736+
expected_message = (
737+
"{!r} is an instance of <class {}>, expected {}".format(
738+
expr, real_type, expected_type
739+
)
737740
)
738741
if sys.version_info[0] < 3:
739742
return expected_message.replace("class", "type")
@@ -1345,7 +1348,7 @@ def test_assert_json_subset__one_key_missing_from_second_object(self):
13451348
assert_json_subset({"foo": 3, "bar": 3}, {"foo": 3})
13461349

13471350
def test_assert_json_subset__multiple_keys_missing_from_second_object(
1348-
self
1351+
self,
13491352
):
13501353
with _assert_raises_assertion(
13511354
"elements 'bar', 'baz', and 'foo' missing from element $"
@@ -1422,11 +1425,11 @@ def test_assert_json_subset__second_is_invalid_json_string(self):
14221425

14231426
def test_assert_json_subset__second_is_bytes(self):
14241427
with assert_succeeds(AssertionError):
1425-
assert_json_subset([u"föo"], u'["föo"]'.encode("utf-8"))
1428+
assert_json_subset(["föo"], '["föo"]'.encode("utf-8"))
14261429

14271430
def test_assert_json_subset__second_is_latin1_bytes(self):
14281431
with assert_raises(UnicodeDecodeError):
1429-
assert_json_subset([u"föo"], u'["föo"]'.encode("iso-8859-1"))
1432+
assert_json_subset(["föo"], '["föo"]'.encode("iso-8859-1"))
14301433

14311434
def test_assert_json_subset__invalid_type(self):
14321435
with assert_raises_regex(
@@ -1436,20 +1439,23 @@ def test_assert_json_subset__invalid_type(self):
14361439

14371440
def test_assert_json_subset__element_name_not_str(self) -> None:
14381441
with assert_raises_regex(
1439-
TypeError, "12 is not a valid object member name",
1442+
TypeError,
1443+
"12 is not a valid object member name",
14401444
):
14411445
assert_json_subset({12: 34}, "{}")
14421446

14431447
def test_assert_json_subset__existence_check(self) -> None:
14441448
with assert_succeeds(AssertionError):
14451449
assert_json_subset({Exists("foo"): True}, {"foo": "bar"})
14461450
with assert_raises_regex(
1447-
AssertionError, r"element 'foo' missing from element \$",
1451+
AssertionError,
1452+
r"element 'foo' missing from element \$",
14481453
):
14491454
assert_json_subset({Exists("foo"): True}, {})
14501455
with assert_succeeds(AssertionError):
14511456
assert_json_subset({Exists("foo"): False}, {})
14521457
with assert_raises_regex(
1453-
AssertionError, r"spurious member 'foo' in object \$",
1458+
AssertionError,
1459+
r"spurious member 'foo' in object \$",
14541460
):
14551461
assert_json_subset({Exists("foo"): False}, {"foo": "bar"})

0 commit comments

Comments
 (0)