Skip to content

Commit e62b8ea

Browse files
committed
Add selenium test marker to stablize CI suite
1 parent b568368 commit e62b8ea

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
python-version: ${{ matrix.python-version }}
6161
- run: python -m pip install Django~="${{ matrix.django-version }}.0"
6262
- run: python -m pip install -e .[test]
63-
- run: python -m pytest
63+
- run: python -m pytest -m "not selenium"
6464
- uses: codecov/codecov-action@v3
6565

6666
Selenium:
@@ -85,5 +85,5 @@ jobs:
8585
python-version: ${{ matrix.python-version }}
8686
- run: python -m pip install Django
8787
- run: python -m pip install -e .[test,selenium]
88-
- run: python -m pytest
88+
- run: python -m pytest -m selenium
8989
- uses: codecov/codecov-action@v3

tests/conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
from selenium.common.exceptions import WebDriverException
77

88

9+
def pytest_configure(config):
10+
config.addinivalue_line(
11+
"markers", "selenium: skip if selenium is not installed"
12+
)
13+
914
def random_string(n):
1015
return "".join(
1116
random.choice(string.ascii_uppercase + string.digits) for _ in range(n)

tests/test_forms.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,14 @@ def test_allow_clear(self, db):
8282
"primary_genre", None
8383
)
8484

85+
@pytest.mark.selenium
8586
def test_no_js_error(self, db, live_server, driver):
8687
driver.get(live_server + self.url)
8788
with pytest.raises(NoSuchElementException):
8889
error = driver.find_element(By.XPATH, "//body[@JSError]")
8990
pytest.fail(error.get_attribute("JSError"))
9091

92+
@pytest.mark.selenium
9193
def test_selecting(self, db, live_server, driver):
9294
driver.get(live_server + self.url)
9395
with pytest.raises(NoSuchElementException):
@@ -298,6 +300,7 @@ def test_many_selected_option(self, db, genres):
298300
), widget_output
299301
assert selected_option2 in widget_output or selected_option2a in widget_output
300302

303+
@pytest.mark.selenium
301304
def test_multiple_widgets(self, db, live_server, driver):
302305
driver.get(live_server + self.url)
303306
with pytest.raises(NoSuchElementException):
@@ -641,6 +644,7 @@ class TestHeavySelect2MultipleWidget:
641644
bool(os.environ.get("CI", False)),
642645
reason="https://bugs.chromium.org/p/chromedriver/issues/detail?id=1772",
643646
)
647+
@pytest.mark.selenium
644648
def test_widgets_selected_after_validation_error(self, db, live_server, driver):
645649
driver.get(live_server + self.url)
646650
WebDriverWait(driver, 3).until(
@@ -678,6 +682,7 @@ class TestAddressChainedSelect2Widget:
678682
url = reverse("model_chained_select2_widget")
679683
form = forms.AddressChainedSelect2WidgetForm()
680684

685+
@pytest.mark.selenium
681686
def test_widgets_selected_after_validation_error(
682687
self, db, live_server, driver, countries, cities
683688
):
@@ -757,6 +762,7 @@ def test_widgets_selected_after_validation_error(
757762
assert len(country_names_from_browser) != Country.objects.count()
758763
assert country_names_from_browser == country_names_from_db
759764

765+
@pytest.mark.selenium
760766
def test_dependent_fields_clear_after_change_parent(
761767
self, db, live_server, driver, countries, cities
762768
):

0 commit comments

Comments
 (0)