From 0080690f8698b83c6b2fb0eb6fab9e1a0b498120 Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Mon, 4 Nov 2024 23:54:29 +0200 Subject: [PATCH] added conftest and strict markers. --- .github/workflows/test-localnet-tests.yml | 1 + multiversx_sdk_cli/tests/conftest.py | 12 ++++++++++++ multiversx_sdk_cli/tests/test_cli_validators.py | 2 -- pytest.ini | 4 ++-- 4 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 multiversx_sdk_cli/tests/conftest.py diff --git a/.github/workflows/test-localnet-tests.yml b/.github/workflows/test-localnet-tests.yml index 630ef7cb..e4b66985 100644 --- a/.github/workflows/test-localnet-tests.yml +++ b/.github/workflows/test-localnet-tests.yml @@ -52,3 +52,4 @@ jobs: - name: Test localnet dependent tests run: | pytest -m require_localnet multiversx_sdk_cli/tests + diff --git a/multiversx_sdk_cli/tests/conftest.py b/multiversx_sdk_cli/tests/conftest.py new file mode 100644 index 00000000..601ea625 --- /dev/null +++ b/multiversx_sdk_cli/tests/conftest.py @@ -0,0 +1,12 @@ +import pytest + + +# function executed right after test items collected but before test run +def pytest_collection_modifyitems(config, items): + if not config.getoption('-m'): + skip_me = pytest.mark.skip(reason="to run marked tests, you need to explicitly run them wiht -m") + for item in items: + if "require_localnet" in item.keywords: + item.add_marker(skip_me) + if "skip_on_winodws" in item.keywords: + item.add_marker(skip_me) diff --git a/multiversx_sdk_cli/tests/test_cli_validators.py b/multiversx_sdk_cli/tests/test_cli_validators.py index 3f5d6402..8b7cc521 100644 --- a/multiversx_sdk_cli/tests/test_cli_validators.py +++ b/multiversx_sdk_cli/tests/test_cli_validators.py @@ -1,5 +1,3 @@ -import requests -import time import pytest from pathlib import Path diff --git a/pytest.ini b/pytest.ini index cab31729..4cee0be1 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,7 +1,7 @@ [pytest] markers = - skip_on_windows: marks tests as being skiped when running on windows (deselect with '-m "skip_on_windows"') + skip_on_windows: marks tests as being skipped when running on windows (deselect with '-m "skip_on_windows"') only: only run a specific test (run using: pytest -m "only") - require_localnet: marks tests that require a localnet (run using: pytest -m require_localnet) + require_localnet: marks tests that require a localnet (select with '-m "require_localnet"') log_cli = True