Skip to content

Commit 356394a

Browse files
committed
fix some assertions by checking the value
1 parent d57d8f3 commit 356394a

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

tests/playwright/shiny/inputs/input_radio_checkbox_group/test_input_radio_checkbox_group_app.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ def test_locator_debugging(page: Page, local_app: ShinyAppProc) -> None:
9696
with pytest.raises(AssertionError) as e:
9797
not_exist.expect_choices(["a", "b", "c"], timeout=timeout)
9898

99-
assert "expected to have count '1'" in str(e)
100-
assert "Actual value: 0" in str(e)
99+
assert "expected to have count '1'" in str(e.value)
100+
assert "Actual value: 0" in str(e.value)
101101

102102
check1 = InputCheckboxGroup(page, "check1")
103103

@@ -106,18 +106,18 @@ def test_locator_debugging(page: Page, local_app: ShinyAppProc) -> None:
106106
# Too many
107107
with pytest.raises(AssertionError) as e:
108108
check1.expect_choices(["red", "green", "blue", "test_value"], timeout=timeout)
109-
assert "expected to have count '4'" in str(e)
110-
assert "Actual value: 3" in str(e)
109+
assert "expected to have count '4'" in str(e.value)
110+
assert "Actual value: 3" in str(e.value)
111111
# Not enough
112112
with pytest.raises(AssertionError) as e:
113113
check1.expect_choices(["red", "green"], timeout=timeout)
114-
assert "expected to have count '2'" in str(e)
115-
assert "Actual value: 3" in str(e)
114+
assert "expected to have count '2'" in str(e.value)
115+
assert "Actual value: 3" in str(e.value)
116116
# Wrong value
117117
with pytest.raises(AssertionError) as e:
118118
check1.expect_choices(["red", "green", "test_value"], timeout=timeout)
119-
assert "attribute 'test_value'" in str(e)
120-
assert "Actual value: blue" in str(e)
119+
assert "attribute 'test_value'" in str(e.value)
120+
assert "Actual value: blue" in str(e.value)
121121

122122

123123
def test_locator_existance(page: Page, local_app: ShinyAppProc) -> None:
@@ -129,8 +129,10 @@ def test_locator_existance(page: Page, local_app: ShinyAppProc) -> None:
129129
not_exist = InputCheckboxGroup(page, "does-not-exist")
130130
with pytest.raises(AssertionError) as e:
131131
not_exist.set(["green"], timeout=timeout)
132-
assert "expected to have count '1'" in str(e)
133-
assert "Actual value: 0" in str(e)
132+
133+
print(str(e.value))
134+
assert "expected to have count '1'" in str(e.value)
135+
assert "Actual value: 0" in str(e.value)
134136

135137
check1 = InputCheckboxGroup(page, "check1")
136138

@@ -143,14 +145,14 @@ def test_locator_existance(page: Page, local_app: ShinyAppProc) -> None:
143145
# Different value
144146
with pytest.raises(AssertionError) as e:
145147
check1.set(["test_value"], timeout=timeout)
146-
assert "expected to have count '1'" in str(e)
147-
assert "Actual value: 0" in str(e)
148+
assert "expected to have count '1'" in str(e.value)
149+
assert "Actual value: 0" in str(e.value)
148150

149151
# Extra value
150152
with pytest.raises(AssertionError) as e:
151153
check1.set(["blue", "test_value"], timeout=timeout)
152154

153-
assert "expected to have count '1'" in str(e)
154-
assert "Actual value: 0" in str(e)
155+
assert "expected to have count '1'" in str(e.value)
156+
assert "Actual value: 0" in str(e.value)
155157

156158
check1.expect_selected(["green"])

tests/pytest/test_sidebar.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,21 @@ def test_panel_main_and_panel_sidebar():
2929

3030
with pytest.raises(ValueError) as e:
3131
ui.layout_sidebar(_s, _s)
32-
assert "multiple `sidebar()` objects" in str(e)
32+
assert "multiple `sidebar()` objects" in str(e.value)
3333

3434
with pytest.raises(ValueError) as e:
3535
ui.layout_sidebar(None, _ps) # pyright: ignore[reportArgumentType]
36-
assert "not being supplied with a `sidebar()` object" in str(e)
36+
assert "not being supplied with a `sidebar()` object" in str(e.value)
3737

3838
with pytest.raises(ValueError) as e:
3939
ui.layout_sidebar(_s, _pm)
40-
assert "is not being used with `panel_sidebar()`" in str(e)
40+
assert "is not being used with `panel_sidebar()`" in str(e.value)
4141

4242
with pytest.raises(ValueError, match="not being supplied as the second argument"):
4343
ui.layout_sidebar(_ps, None, _pm)
4444
with pytest.raises(ValueError) as e:
4545
ui.layout_sidebar(_ps, _pm, None, "42")
46-
assert "Unexpected extra legacy `*args`" in str(e)
46+
assert "Unexpected extra legacy `*args`" in str(e.value)
4747

4848

4949
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)