separate unit/integration tests

This commit is contained in:
sebthom
2022-02-10 05:14:44 +01:00
parent c3275a375b
commit 0b46322a47
4 changed files with 26 additions and 7 deletions

View File

@@ -70,18 +70,26 @@ jobs:
- name: check code style - name: check code style
run: | run: |
set -eux
pdm run lint pdm run lint
pdm run autopep8 -v --exit-code --recursive --diff kleinanzeigen_bot tests pdm run autopep8 -v --exit-code --recursive --diff kleinanzeigen_bot tests
- name: run unit tests - name: run unit tests
run: | run: |
pdm run utest
- name: run integration tests
run: |
set -eux
case "${{ matrix.os }}" in case "${{ matrix.os }}" in
ubuntu-*) ubuntu-*)
sudo apt-get install -o Acquire::Retries=3 --no-install-recommends -y xvfb 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 esac

View File

@@ -295,9 +295,12 @@ updated_on: # set automatically
> Please read [CONTRIBUTING.md](CONTRIBUTING.md) before contributing code. Thank you! > Please read [CONTRIBUTING.md](CONTRIBUTING.md) before contributing code. Thank you!
- Format source code: `pdm run format` - Format source code: `pdm run format`
- Running unit tests: `pdm run test` - Run tests:
- Running linter: `pdm run lint` - unit tests: `pdm run utest`
- Creating platform-specific executable: `pdm run compile` - 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: - Application bootstrap works like this:
```python ```python
pdm run app pdm run app

View File

@@ -73,7 +73,8 @@ format = "autopep8 --recursive --in-place kleinanzeigen_bot tests"
lint = "pylint -v kleinanzeigen_bot tests" lint = "pylint -v kleinanzeigen_bot tests"
scan = "bandit -c pyproject.toml -r kleinanzeigen_bot" scan = "bandit -c pyproject.toml -r kleinanzeigen_bot"
test = "python -m pytest --capture=tee-sys -v" 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 # autopep8
@@ -91,6 +92,7 @@ ignore = [ # https://github.com/hhatto/autopep8#features
] ]
aggressive = 3 aggressive = 3
##################### #####################
# bandit # bandit
# https://pypi.org/project/bandit/ # https://pypi.org/project/bandit/
@@ -161,4 +163,7 @@ max-statements = 70
##################### #####################
[tool.pytest.ini_options] [tool.pytest.ini_options]
# https://docs.pytest.org/en/stable/reference.html#confval-addopts # 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)"
]

View File

@@ -2,10 +2,13 @@
Copyright (C) 2022 Sebastian Thomschke and contributors Copyright (C) 2022 Sebastian Thomschke and contributors
SPDX-License-Identifier: AGPL-3.0-or-later SPDX-License-Identifier: AGPL-3.0-or-later
""" """
import pytest
from kleinanzeigen_bot.selenium_mixin import SeleniumMixin from kleinanzeigen_bot.selenium_mixin import SeleniumMixin
from kleinanzeigen_bot import utils from kleinanzeigen_bot import utils
@pytest.mark.itest
def test_webdriver_auto_init(): def test_webdriver_auto_init():
selenium_mixin = SeleniumMixin() selenium_mixin = SeleniumMixin()