MCPcopy Index your code
hub / github.com/reactive-python/reactpy / test_use_location

Function test_use_location

src/py/reactpy/tests/test_backend/test_all.py:109–135  ·  view source on GitHub ↗
(display: DisplayFixture)

Source from the content-addressed store, hash-verified

107
108
109async def test_use_location(display: DisplayFixture):
110 location = reactpy.Ref()
111
112 @poll
113 async def poll_location():
114 """This needs to be async to allow the server to respond"""
115 return getattr(location, "current", None)
116
117 @reactpy.component
118 def ShowRoute():
119 location.current = reactpy.use_location()
120 return html.pre(str(location.current))
121
122 await display.show(ShowRoute)
123
124 await poll_location.until_equals(Location("/", ""))
125
126 for loc in [
127 Location("/something", ""),
128 Location("/something/file.txt", ""),
129 Location("/another/something", ""),
130 Location("/another/something/file.txt", ""),
131 Location("/another/something/file.txt", "?key=value"),
132 Location("/another/something/file.txt", "?key1=value1&key2=value2"),
133 ]:
134 await display.goto(loc.pathname + loc.search)
135 await poll_location.until_equals(loc)
136
137
138@pytest.mark.parametrize("hook_name", ["use_request", "use_websocket"])

Callers

nothing calls this directly

Calls 4

LocationClass · 0.90
showMethod · 0.80
until_equalsMethod · 0.80
gotoMethod · 0.80

Tested by

no test coverage detected