Skip to content

Commit

Permalink
Update pytest entrypoints (#14868)
Browse files Browse the repository at this point in the history
* Update pytest entrypoints

* Update testing docs pytest examples
  • Loading branch information
janbrasna authored Jul 24, 2024
1 parent e7a9b14 commit 23c6e08
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ test: .docker-build-pull
${DC} run --rm test

test-cdn: .docker-build-pull test_infra/fixtures/tls.json
${DC} run test py.test --base-url https://${TEST_DOMAIN} test_infra
${DC} run test pytest --base-url https://${TEST_DOMAIN} test_infra

test-image: .docker-build
${DC} run test-image
Expand Down
2 changes: 1 addition & 1 deletion bin/integration_tests/run_integration_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ set -xe
# Common arguments
if [ "${DRIVER}" = "SauceLabs" ]; then
# Temporarily exclude logs for Saucelabs jobs https://github.com/pytest-dev/pytest-selenium/issues/288
CMD="SAUCELABS_W3C=true SELENIUM_EXCLUDE_DEBUG=logs py.test"
CMD="SAUCELABS_W3C=true SELENIUM_EXCLUDE_DEBUG=logs pytest"
else
CMD="pytest"
fi
Expand Down
2 changes: 1 addition & 1 deletion bin/run-integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ set -xe
# Common arguments
if [ "${DRIVER}" = "SauceLabs" ]; then
# Temporarily exclude logs for Saucelabs jobs https://github.com/pytest-dev/pytest-selenium/issues/288
CMD="SAUCELABS_W3C=true SELENIUM_EXCLUDE_DEBUG=logs py.test"
CMD="SAUCELABS_W3C=true SELENIUM_EXCLUDE_DEBUG=logs pytest"
else
CMD="pytest"
fi
Expand Down
8 changes: 4 additions & 4 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,10 @@ If you don't have Make you can simply run ``docker-compose run test``.
If you'd like to run only a subset of the tests or only one of the test commands you can accomplish
that with a command like the following::

$ docker-compose run test py.test bedrock/firefox
$ docker-compose run test pytest bedrock/firefox

This example will run only the unit tests for the ``firefox`` app in bedrock. You can substitute
``py.test bedrock/firefox`` with most any shell command you'd like and it will run in the Docker
``pytest bedrock/firefox`` with most any shell command you'd like and it will run in the Docker
container and show you the output. You can also just run ``bash`` to get an interactive shell in
the container which you can then use to run any commands you'd like and inspect the file system::

Expand All @@ -276,11 +276,11 @@ Local
From the local install instructions above you should still have your virtualenv
activated, so running the tests is as simple as::

$ py.test lib bedrock
$ pytest lib bedrock

To test a single app, specify the app by name in the command above. e.g.::

$ py.test bedrock/firefox
$ pytest bedrock/firefox


Make it run
Expand Down
2 changes: 1 addition & 1 deletion docs/redirects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ of the site (e.g. www.mozilla.org) you can set the ``--base-url`` command line o

.. code-block:: bash
$ py.test --base-url https://www.mozilla.org tests/redirects/
$ pytest --base-url https://www.mozilla.org tests/redirects/
By default, tests will run one at a time. If you intend to run the suite
against a remote instance of the site (e.g. production) it will run a lot
Expand Down
14 changes: 7 additions & 7 deletions docs/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Mozorg mode:

.. code-block:: bash
$ py.test --base-url http://localhost:8000 --driver Firefox --html tests/functional/results.html tests/functional/
$ pytest --base-url http://localhost:8000 --driver Firefox --html tests/functional/results.html tests/functional/
This will run all test suites found in the ``tests/functional`` directory and
assumes you have bedrock running at ``localhost`` on port ``8000``. Results will
Expand All @@ -125,7 +125,7 @@ time. You need to define a temporary environment variable (needed by the

.. code-block:: bash
$ BASE_POCKET_URL=http://localhost:8000 py.test -m pocket_mode --driver Firefox --html tests/functional/results.html tests/functional/
$ BASE_POCKET_URL=http://localhost:8000 pytest -m pocket_mode --driver Firefox --html tests/functional/results.html tests/functional/
This will run all test suites found in the ``tests/functional`` directory that have
the pytest "`mark`" of `pocket_mode` and assumes you have bedrock running *in Pocket mode* at
Expand All @@ -151,26 +151,26 @@ processes.
take a long time to run, especially if they're not running in parallel.
To skip these tests, add ``-m 'not headless'`` to your command line.

To run a single test file you must tell py.test to execute a specific file
To run a single test file you must tell pytest to execute a specific file
e.g. ``tests/functional/test_newsletter.py``:

.. code-block:: bash
$ py.test --base-url http://localhost:8000 --driver Firefox --html tests/functional/results.html tests/functional/firefox/new/test_download.py
$ pytest --base-url http://localhost:8000 --driver Firefox --html tests/functional/results.html tests/functional/firefox/new/test_download.py
To run a single test you can filter using the ``-k`` argument supplied with a keyword
e.g. ``-k test_download_button_displayed``:

.. code-block:: bash
$ py.test --base-url http://localhost:8000 --driver Firefox --html tests/functional/results.html tests/functional/firefox/new/test_download.py -k test_download_button_displayed
$ pytest --base-url http://localhost:8000 --driver Firefox --html tests/functional/results.html tests/functional/firefox/new/test_download.py -k test_download_button_displayed
You can also easily run the tests against any bedrock environment by specifying the
``--base-url`` argument. For example, to run all functional tests against dev:

.. code-block:: bash
$ py.test --base-url https://www-dev.allizom.org --driver Firefox --html tests/functional/results.html tests/functional/
$ pytest --base-url https://www-dev.allizom.org --driver Firefox --html tests/functional/results.html tests/functional/
.. Note::

Expand All @@ -195,7 +195,7 @@ For example, to run the home page tests using Internet Explorer via Sauce Labs:

.. code-block:: bash
$ SAUCELABS_USERNAME=thedude SAUCELABS_API_KEY=123456789 SAUCELABS_W3C=true SELENIUM_EXCLUDE_DEBUG=logs py.test --base-url https://www-dev.allizom.org --driver SauceLabs --capability browserName 'internet explorer' --capability platformName 'Windows 10' --html tests/functional/results.html tests/functional/test_home.py
$ SAUCELABS_USERNAME=thedude SAUCELABS_API_KEY=123456789 SAUCELABS_W3C=true SELENIUM_EXCLUDE_DEBUG=logs pytest --base-url https://www-dev.allizom.org --driver SauceLabs --capability browserName 'internet explorer' --capability platformName 'Windows 10' --html tests/functional/results.html tests/functional/test_home.py
Writing Selenium tests
Expand Down

0 comments on commit 23c6e08

Please sign in to comment.