Skip to content

Commit 3097692

Browse files
authored
Allow more control over tox Selenium tests (#1897)
Instead of unconditionally enabling Selenium tests for the py311-dj42-postgresql tox environment, enable them by default for that environment but allow them to be disabled if the user's DJANGO_SELENIUM_TESTS environment variable is empty. This will allow the user to run DJANGO_SELENIUM_TESTS= tox to run the full tox test suite with Selenium tests disabled.
1 parent b3cb611 commit 3097692

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

docs/contributing.rst

+6
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ or by setting the ``DJANGO_SELENIUM_TESTS`` environment variable::
8585
$ DJANGO_SELENIUM_TESTS=true make coverage
8686
$ DJANGO_SELENIUM_TESTS=true tox
8787

88+
Note that by default, ``tox`` enables the Selenium tests for a single test
89+
environment. To run the entire ``tox`` test suite with all Selenium tests
90+
disabled, run the following::
91+
92+
$ DJANGO_SELENIUM_TESTS= tox
93+
8894
To test via ``tox`` against other databases, you'll need to create the user,
8995
database and assign the proper permissions. For PostgreSQL in a ``psql``
9096
shell (note this allows the debug_toolbar user the permission to create

tests/test_integration.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ def test_auth_login_view_without_redirect(self):
547547

548548
@unittest.skipIf(webdriver is None, "selenium isn't installed")
549549
@unittest.skipUnless(
550-
"DJANGO_SELENIUM_TESTS" in os.environ, "selenium tests not requested"
550+
os.environ.get("DJANGO_SELENIUM_TESTS"), "selenium tests not requested"
551551
)
552552
@override_settings(DEBUG=True)
553553
class DebugToolbarLiveTestCase(StaticLiveServerTestCase):

tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ passenv=
3636
setenv =
3737
PYTHONPATH = {toxinidir}
3838
PYTHONWARNINGS = d
39-
py311-dj42-postgresql: DJANGO_SELENIUM_TESTS = true
39+
py311-dj42-postgresql: DJANGO_SELENIUM_TESTS = {env:DJANGO_SELENIUM_TESTS:true}
4040
DB_NAME = {env:DB_NAME:debug_toolbar}
4141
DB_USER = {env:DB_USER:debug_toolbar}
4242
DB_HOST = {env:DB_HOST:localhost}

0 commit comments

Comments
 (0)