From c63ee45158fa9492043e3ff4dc0d30a3f42bc2ec Mon Sep 17 00:00:00 2001 From: francisco souza <108725+fsouza@users.noreply.github.com> Date: Fri, 10 Nov 2023 22:15:26 -0500 Subject: [PATCH] tests: use `pytest.mark.flaky` to manage flaky tests We want to run those, but we don't trust them, so we ignore their results. Also mark all tests for mouse operations as flaky. --- requirements/test.txt | 1 + requirements/test_windows.txt | 1 + tests/test_mouse_interaction.py | 6 ++++++ tox.ini | 6 +++--- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/requirements/test.txt b/requirements/test.txt index 2cbb5a773..d338a50af 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -4,4 +4,5 @@ argparse Django>=2.0.6 pytest==7.4.3 pytest-xdist==3.3.1 +pytest-ignore-flaky==2.1.0 zope.testbrowser==6.0 diff --git a/requirements/test_windows.txt b/requirements/test_windows.txt index bbdbf5330..8053813cd 100644 --- a/requirements/test_windows.txt +++ b/requirements/test_windows.txt @@ -2,4 +2,5 @@ Flask==3.0.0 coverage==7.3.2 argparse pytest==7.4.3 +pytest-ignore-flaky==2.1.0 pytest-xdist==3.3.1 diff --git a/tests/test_mouse_interaction.py b/tests/test_mouse_interaction.py index ee8956e84..d82c101c0 100644 --- a/tests/test_mouse_interaction.py +++ b/tests/test_mouse_interaction.py @@ -9,6 +9,7 @@ from .fake_webapp import EXAMPLE_APP +@pytest.mark.flaky @pytest.mark.parametrize("browser_name", supported_browsers) def test_mouse_over(browser_name, get_new_browser): "Should be able to perform a mouse over on an element" @@ -27,6 +28,7 @@ def test_mouse_over(browser_name, get_new_browser): assert browser.is_element_not_present_by_id("what-is-your-name", wait_time=10) +@pytest.mark.flaky @pytest.mark.parametrize("browser_name", supported_browsers) def test_mouse_out(browser_name, get_new_browser): "Should be able to perform a mouse out on an element" @@ -40,6 +42,7 @@ def test_mouse_out(browser_name, get_new_browser): assert browser.is_element_not_present_by_id("what-is-your-name", wait_time=10) +@pytest.mark.flaky @pytest.mark.parametrize("browser_name", supported_browsers) def test_mouse_out_top_left(browser_name, get_new_browser): """Should be able to perform a mouse out on an element, @@ -55,6 +58,7 @@ def test_mouse_out_top_left(browser_name, get_new_browser): assert browser.is_element_not_present_by_id("what-is-your-name", wait_time=10) +@pytest.mark.flaky @pytest.mark.parametrize("browser_name", supported_browsers) def test_double_click(browser_name, get_new_browser): """Test: WebDriverElement.double_click() @@ -77,6 +81,7 @@ def test_double_click(browser_name, get_new_browser): assert browser.is_element_not_present_by_id("what-is-your-name", wait_time=20) +@pytest.mark.flaky @pytest.mark.parametrize("browser_name", supported_browsers) def test_right_click(browser_name, get_new_browser): "should be able to perform a right click on an element" @@ -93,6 +98,7 @@ def test_right_click(browser_name, get_new_browser): assert result_1 == result_2 == "right clicked" +@pytest.mark.flaky @pytest.mark.parametrize("browser_name", supported_browsers) def test_drag_and_drop(browser_name, get_new_browser): """ diff --git a/tox.ini b/tox.ini index 475f0869b..73668aeee 100644 --- a/tox.ini +++ b/tox.ini @@ -2,7 +2,7 @@ extras = zope.testbrowser, django, flask deps = -rrequirements/test.txt commands= - pytest -v {posargs} + pytest --ignore-flaky -v {posargs} [testenv:tests_selenium] @@ -10,7 +10,7 @@ extras = selenium deps = -rrequirements/test.txt commands= - pytest -v {posargs} + pytest --ignore-flaky -v {posargs} [testenv:tests_windows_selenium] @@ -20,4 +20,4 @@ deps = passenv = EDGEWEBDRIVER commands= - pytest -v {posargs} + pytest --ignore-flaky -v {posargs}