Skip to content

Commit

Permalink
tests: use pytest.mark.flaky to manage flaky tests
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fsouza committed Nov 11, 2023
1 parent c815ec6 commit c63ee45
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions requirements/test_windows.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions tests/test_mouse_interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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,
Expand All @@ -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()
Expand All @@ -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"
Expand All @@ -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):
"""
Expand Down
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
extras = zope.testbrowser, django, flask
deps = -rrequirements/test.txt
commands=
pytest -v {posargs}
pytest --ignore-flaky -v {posargs}


[testenv:tests_selenium]
extras = selenium
deps =
-rrequirements/test.txt
commands=
pytest -v {posargs}
pytest --ignore-flaky -v {posargs}


[testenv:tests_windows_selenium]
Expand All @@ -20,4 +20,4 @@ deps =
passenv =
EDGEWEBDRIVER
commands=
pytest -v {posargs}
pytest --ignore-flaky -v {posargs}

0 comments on commit c63ee45

Please sign in to comment.