From a2ab6d8547feef7fa29e0b5595675276f27a7657 Mon Sep 17 00:00:00 2001 From: Falko Schindler Date: Thu, 4 Apr 2024 16:43:58 +0200 Subject: [PATCH] try to fix flaky interactive_image tests (again) --- tests/test_interactive_image.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/tests/test_interactive_image.py b/tests/test_interactive_image.py index db8b86aa9..eed252150 100644 --- a/tests/test_interactive_image.py +++ b/tests/test_interactive_image.py @@ -21,27 +21,26 @@ async def page(client: Client): with ui.tab_panel('B'): ui.label('Tab B') await client.connected() - img.set_source('https://nicegui.io/logo.png') + img.set_source('https://picsum.photos/id/29/640/360') screen.open('/') screen.wait(0.5) - assert screen.find_by_tag('img').get_attribute('src') == 'https://nicegui.io/logo.png' + assert screen.find_by_tag('img').get_attribute('src') == 'https://picsum.photos/id/29/640/360' screen.click('B') screen.wait(0.5) screen.click('A') - assert screen.find_by_tag('img').get_attribute('src') == 'https://nicegui.io/logo.png' + assert screen.find_by_tag('img').get_attribute('src') == 'https://picsum.photos/id/29/640/360' -@pytest.mark.parametrize('cross, number_of_lines', [(True, 2), (False, 0)]) -def test_with_cross(screen: Screen, cross: bool, number_of_lines: int): - ii = ui.interactive_image('https://nicegui.io/logo.png', cross=cross) - ii.content = '' +@pytest.mark.parametrize('cross', [True, False]) +def test_with_cross(screen: Screen, cross: bool): + ui.interactive_image('https://picsum.photos/id/29/640/360', + content='', cross=cross) screen.open('/') - screen.wait(0.5) screen.find_by_tag('svg') with screen.implicitly_wait(0.5): - assert len(screen.find_all_by_tag('line')) == number_of_lines + assert len(screen.find_all_by_tag('line')) == (2 if cross else 0) assert len(screen.find_all_by_tag('circle')) == 1 @@ -56,11 +55,10 @@ def replace(): ui.button('Replace', on_click=replace) screen.open('/') - screen.wait(0.5) - assert screen.find_by_tag('img').get_attribute('src').endswith('id/29/640/360') + assert (screen.find_by_tag('img').get_attribute('src') or '').endswith('id/29/640/360') screen.click('Replace') screen.wait(0.5) - assert screen.find_by_tag('img').get_attribute('src').endswith('id/30/640/360') + assert (screen.find_by_tag('img').get_attribute('src') or '').endswith('id/30/640/360') @pytest.mark.parametrize('cross', [True, False])