Skip to content

Commit

Permalink
Allow more control over tox Selenium tests (#1897)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
living180 committed Mar 18, 2024
1 parent b3cb611 commit 3097692
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions docs/contributing.rst
Expand Up @@ -85,6 +85,12 @@ or by setting the ``DJANGO_SELENIUM_TESTS`` environment variable::
$ DJANGO_SELENIUM_TESTS=true make coverage
$ DJANGO_SELENIUM_TESTS=true tox

Note that by default, ``tox`` enables the Selenium tests for a single test
environment. To run the entire ``tox`` test suite with all Selenium tests
disabled, run the following::

$ DJANGO_SELENIUM_TESTS= tox

To test via ``tox`` against other databases, you'll need to create the user,
database and assign the proper permissions. For PostgreSQL in a ``psql``
shell (note this allows the debug_toolbar user the permission to create
Expand Down
2 changes: 1 addition & 1 deletion tests/test_integration.py
Expand Up @@ -547,7 +547,7 @@ def test_auth_login_view_without_redirect(self):

@unittest.skipIf(webdriver is None, "selenium isn't installed")
@unittest.skipUnless(
"DJANGO_SELENIUM_TESTS" in os.environ, "selenium tests not requested"
os.environ.get("DJANGO_SELENIUM_TESTS"), "selenium tests not requested"
)
@override_settings(DEBUG=True)
class DebugToolbarLiveTestCase(StaticLiveServerTestCase):
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Expand Up @@ -36,7 +36,7 @@ passenv=
setenv =
PYTHONPATH = {toxinidir}
PYTHONWARNINGS = d
py311-dj42-postgresql: DJANGO_SELENIUM_TESTS = true
py311-dj42-postgresql: DJANGO_SELENIUM_TESTS = {env:DJANGO_SELENIUM_TESTS:true}
DB_NAME = {env:DB_NAME:debug_toolbar}
DB_USER = {env:DB_USER:debug_toolbar}
DB_HOST = {env:DB_HOST:localhost}
Expand Down

0 comments on commit 3097692

Please sign in to comment.