Skip to content

Commit b09f28d

Browse files
authored
Merge pull request #1140 from davep/finish-mount-tests
Add the final TooManyMatches mounting unit test
2 parents e779e4a + 73cc602 commit b09f28d

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

tests/test_widget_mounting.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from textual.app import App
44
from textual.widgets import Static
5+
from textual.css.query import TooManyMatches
56

67
async def test_mount_via_app() -> None:
78
"""Perform mount tests via the app."""
@@ -94,20 +95,9 @@ async def test_mount_via_app() -> None:
9495
with pytest.raises(Static.MountError):
9596
await pilot.app.mount(Static(), after=Static())
9697

97-
# TODO: At the moment query_one() simply takes a query and returns the
98-
# .first() item. As such doing a query_one() that gets more than one
99-
# thing isn't an error, it just skims off the first thing. OTOH the
100-
# intention of before= and after= with a selector is that an exception
101-
# will be thrown -- the exception being the own that should be thrown
102-
# from query_one(). So, this test here is a TODO test because we'll wait
103-
# for a change to query_one() and then its exception will just bubble
104-
# up.
105-
#
106-
# See https://github.com/Textualize/textual/issues/1096
107-
#
108-
# async with App().run_test() as pilot:
109-
# # Make sure we get an error if we try and mount with a selector that
110-
# # results in more than one hit.
111-
# await pilot.app.mount_all(widgets)
112-
# with pytest.raises( ?Something? ):
113-
# await pilot.app.mount(Static(), before="Static")
98+
async with App().run_test() as pilot:
99+
# Make sure we get an error if we try and mount with a selector that
100+
# results in more than one hit.
101+
await pilot.app.mount_all(widgets)
102+
with pytest.raises(TooManyMatches):
103+
await pilot.app.mount(Static(), before="Static")

0 commit comments

Comments
 (0)