diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 52e212a..cedc3fe 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -70,18 +70,26 @@ jobs: - name: check code style run: | + set -eux + pdm run lint pdm run autopep8 -v --exit-code --recursive --diff kleinanzeigen_bot tests - name: run unit tests run: | + pdm run utest + + - name: run integration tests + run: | + set -eux + case "${{ matrix.os }}" in ubuntu-*) sudo apt-get install -o Acquire::Retries=3 --no-install-recommends -y xvfb - xvfb-run pdm run test + xvfb-run pdm run itest ;; - *) pdm run test + *) pdm run itest ;; esac diff --git a/README.md b/README.md index 546e9bb..71c95a1 100644 --- a/README.md +++ b/README.md @@ -295,9 +295,12 @@ updated_on: # set automatically > Please read [CONTRIBUTING.md](CONTRIBUTING.md) before contributing code. Thank you! - Format source code: `pdm run format` -- Running unit tests: `pdm run test` -- Running linter: `pdm run lint` -- Creating platform-specific executable: `pdm run compile` +- Run tests: + - unit tests: `pdm run utest` + - integration tests: `pdm run itest` + - all tests: `pdm run test` +- Run linter: `pdm run lint` +- Create platform-specific executable: `pdm run compile` - Application bootstrap works like this: ```python pdm run app diff --git a/pyproject.toml b/pyproject.toml index 6d189b7..5ed4abb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -73,7 +73,8 @@ format = "autopep8 --recursive --in-place kleinanzeigen_bot tests" lint = "pylint -v kleinanzeigen_bot tests" scan = "bandit -c pyproject.toml -r kleinanzeigen_bot" test = "python -m pytest --capture=tee-sys -v" - +utest = "python -m pytest --capture=tee-sys -v -m 'not itest'" +itest = "python -m pytest --capture=tee-sys -v -m 'itest'" ##################### # autopep8 @@ -91,6 +92,7 @@ ignore = [ # https://github.com/hhatto/autopep8#features ] aggressive = 3 + ##################### # bandit # https://pypi.org/project/bandit/ @@ -161,4 +163,7 @@ max-statements = 70 ##################### [tool.pytest.ini_options] # https://docs.pytest.org/en/stable/reference.html#confval-addopts -addopts = "-p no:cacheprovider --doctest-modules --ignore=__pypackages__ --ignore=kleinanzeigen_bot/__main__.py" +addopts = "--strict-markers -p no:cacheprovider --doctest-modules --ignore=__pypackages__ --ignore=kleinanzeigen_bot/__main__.py" +markers = [ + "itest: marks a test as an integration test (i.e. a test with external dependencies)" +] \ No newline at end of file diff --git a/tests/test_selenium_mixin.py b/tests/test_selenium_mixin.py index a65677d..a1206d2 100644 --- a/tests/test_selenium_mixin.py +++ b/tests/test_selenium_mixin.py @@ -2,10 +2,13 @@ Copyright (C) 2022 Sebastian Thomschke and contributors SPDX-License-Identifier: AGPL-3.0-or-later """ +import pytest + from kleinanzeigen_bot.selenium_mixin import SeleniumMixin from kleinanzeigen_bot import utils +@pytest.mark.itest def test_webdriver_auto_init(): selenium_mixin = SeleniumMixin()