Skip to content

Commit 8a9737a

Browse files
committed
hatch fmt tests
1 parent 5e10713 commit 8a9737a

File tree

15 files changed

+42
-41
lines changed

15 files changed

+42
-41
lines changed

tests/test_asgi/test_init.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def test_asgi_import_error():
1515
ModuleNotFoundError,
1616
match=r"ASGI executors require the 'reactpy\[asgi\]' extra to be installed",
1717
):
18-
import reactpy.executors.asgi
18+
import reactpy.executors.asgi # noqa: F401
1919

2020
# Clean up
2121
if "reactpy.executors.asgi" in sys.modules:

tests/test_asgi/test_middleware.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ async def homepage(request):
3737

3838

3939
def test_invalid_path_prefix():
40-
with pytest.raises(ValueError, match="Invalid `path_prefix`*"):
40+
with pytest.raises(ValueError, match=r"Invalid `path_prefix`*"):
4141

4242
async def app(scope, receive, send):
4343
pass
@@ -47,7 +47,7 @@ async def app(scope, receive, send):
4747

4848
def test_invalid_web_modules_dir():
4949
with pytest.raises(
50-
ValueError, match='Web modules directory "invalid" does not exist.'
50+
ValueError, match=r'Web modules directory "invalid" does not exist.'
5151
):
5252

5353
async def app(scope, receive, send):

tests/test_asgi/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ def test_process_settings():
1717

1818

1919
def test_invalid_setting():
20-
with pytest.raises(ValueError, match='Unknown ReactPy setting "foobar".'):
20+
with pytest.raises(ValueError, match=r'Unknown ReactPy setting "foobar".'):
2121
utils.process_settings({"foobar": True})

tests/test_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ async def test_slow_server_response_on_input_change(display: DisplayFixture):
111111

112112
@reactpy.component
113113
def SomeComponent():
114-
value, set_value = reactpy.hooks.use_state("")
114+
_value, set_value = reactpy.hooks.use_state("")
115115

116116
async def handle_change(event):
117117
await asyncio.sleep(delay)

tests/test_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def reset_options():
1515

1616
yield
1717

18-
for opt, val in zip(options, original_values):
18+
for opt, val in zip(options, original_values, strict=False):
1919
if val is should_unset:
2020
if opt.is_set():
2121
opt.unset()

tests/test_core/test_events.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def func(*args):
8686

8787

8888
async def test_merge_event_handler_empty_list():
89-
with pytest.raises(ValueError, match="No event handlers to merge"):
89+
with pytest.raises(ValueError, match=r"No event handlers to merge"):
9090
merge_event_handlers([])
9191

9292

@@ -102,7 +102,7 @@ async def test_merge_event_handlers_raises_on_mismatch(kwargs_1, kwargs_2):
102102
def func(data):
103103
return None
104104

105-
with pytest.raises(ValueError, match="Cannot merge handlers"):
105+
with pytest.raises(ValueError, match=r"Cannot merge handlers"):
106106
merge_event_handlers(
107107
[
108108
EventHandler(func, **kwargs_1),
@@ -127,7 +127,7 @@ async def test_merge_event_handlers():
127127

128128

129129
def test_merge_event_handler_funcs_empty_list():
130-
with pytest.raises(ValueError, match="No event handler functions to merge"):
130+
with pytest.raises(ValueError, match=r"No event handler functions to merge"):
131131
merge_event_handler_funcs([])
132132

133133

tests/test_core/test_hooks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def SimpleComponentWithHook():
2020
reactpy.hooks.use_state(None)
2121
return reactpy.html.div()
2222

23-
with pytest.raises(RuntimeError, match="No life cycle hook is active"):
23+
with pytest.raises(RuntimeError, match=r"No life cycle hook is active"):
2424
await SimpleComponentWithHook().render()
2525

2626
async with Layout(SimpleComponentWithHook()) as layout:

tests/test_core/test_layout.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ def MyComponent(): ...
5757

5858

5959
def test_layout_expects_abstract_component():
60-
with pytest.raises(TypeError, match="Expected a ReactPy component"):
60+
with pytest.raises(TypeError, match=r"Expected a ReactPy component"):
6161
Layout(None)
62-
with pytest.raises(TypeError, match="Expected a ReactPy component"):
62+
with pytest.raises(TypeError, match=r"Expected a ReactPy component"):
6363
Layout(reactpy.html.div())
6464

6565

@@ -449,7 +449,7 @@ def AnyComponent():
449449
layout.render(),
450450
timeout=0.1, # this should have been plenty of time
451451
)
452-
except asyncio.TimeoutError:
452+
except TimeoutError:
453453
pass # the render should still be rendering since we only update once
454454

455455
assert run_count.current == 2

tests/test_core/test_vdom.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def test_make_vdom_constructor():
117117

118118
no_children = Vdom("no-children", allow_children=False)
119119

120-
with pytest.raises(TypeError, match="cannot have children"):
120+
with pytest.raises(TypeError, match=r"cannot have children"):
121121
no_children([1, 2, 3])
122122

123123
assert no_children() == {"tagName": "no-children"}
@@ -127,7 +127,7 @@ def test_nested_html_access_raises_error():
127127
elmt = Vdom("div")
128128

129129
with pytest.raises(
130-
AttributeError, match="can only be accessed on web module components"
130+
AttributeError, match=r"can only be accessed on web module components"
131131
):
132132
elmt.fails()
133133

@@ -330,16 +330,16 @@ def MyComponent():
330330

331331
@pytest.mark.skipif(not REACTPY_DEBUG.current, reason="only checked in debug mode")
332332
def test_raise_for_non_json_attrs():
333-
with pytest.raises(TypeError, match="JSON serializable"):
333+
with pytest.raises(TypeError, match=r"JSON serializable"):
334334
reactpy.html.div({"nonJsonSerializableObject": object()})
335335

336336

337337
def test_invalid_vdom_keys():
338-
with pytest.raises(ValueError, match="Invalid keys:*"):
338+
with pytest.raises(ValueError, match=r"Invalid keys:*"):
339339
reactpy.types.VdomDict(tagName="test", foo="bar")
340340

341-
with pytest.raises(KeyError, match="Invalid key:*"):
341+
with pytest.raises(KeyError, match=r"Invalid key:*"):
342342
reactpy.types.VdomDict(tagName="test")["foo"] = "bar"
343343

344-
with pytest.raises(ValueError, match="VdomDict requires a 'tagName' key."):
344+
with pytest.raises(ValueError, match=r"VdomDict requires a 'tagName' key."):
345345
reactpy.types.VdomDict(foo="bar")

tests/test_html.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,19 @@ def HasScript():
8787

8888

8989
def test_script_may_only_have_one_child():
90-
with pytest.raises(ValueError, match="'script' nodes may have, at most, one child"):
90+
with pytest.raises(
91+
ValueError, match=r"'script' nodes may have, at most, one child"
92+
):
9193
html.script("one child", "two child")
9294

9395

9496
def test_child_of_script_must_be_string():
95-
with pytest.raises(ValueError, match="The child of a 'script' must be a string"):
97+
with pytest.raises(ValueError, match=r"The child of a 'script' must be a string"):
9698
html.script(1)
9799

98100

99101
def test_script_has_no_event_handlers():
100-
with pytest.raises(ValueError, match="do not support event handlers"):
102+
with pytest.raises(ValueError, match=r"do not support event handlers"):
101103
html.script({"onEvent": lambda: None})
102104

103105

@@ -113,7 +115,7 @@ def test_simple_fragment():
113115

114116

115117
def test_fragment_can_have_no_attributes():
116-
with pytest.raises(TypeError, match="Fragments cannot have attributes"):
118+
with pytest.raises(TypeError, match=r"Fragments cannot have attributes"):
117119
html.fragment({"someAttribute": 1})
118120

119121

0 commit comments

Comments
 (0)