Skip to content

Commit

Permalink
Add back a runinstalled marker for ogvjs tests
Browse files Browse the repository at this point in the history
Before 3.3, there was a --runinstalled switch for tests to disable by
default the execution of some tests which were deemed to work only if
the package tools were installed.

In 3.3.0, we assumed this switch was not necessary anymore before with
new Python bootstrap convention, we are always in installed mode.

This statement was indeed wrong because some persons are building and
testing without using our build chain (e.g. they build and test directly
from sdist).

This commit adds back the --runinstalled switch for tests and
corresponding pytest marker to mark tests that are going to work only if
package tools are installed.
  • Loading branch information
benoit74 committed Jun 10, 2024
1 parent 7d49831 commit 53ad6fc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/Tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
pip install -e .[test,scripts]
- name: Run the tests
run: inv coverage --args "--runslow -vvv"
run: inv coverage --args "--runslow --runinstalled -vvv"

- name: Upload coverage report to codecov
if: matrix.python == '3.12'
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Simplify type annotations by replacing Union and Optional with pipe character ("|") for improved readability and clarity

### Fixed
- Add back the `--runinstalled` flag for test execution to allow smooth testing on other build chains (#139)

## [3.3.2] - 2024-03-25

### Added
Expand Down
12 changes: 12 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,28 @@ def pytest_addoption(parser):
parser.addoption(
"--runslow", action="store_true", default=False, help="run slow tests"
)
parser.addoption(
"--runinstalled",
action="store_true",
default=False,
help="run tests checking for installed features",
)


def pytest_configure(config):
config.addinivalue_line("markers", "slow: mark test as slow to run")
config.addinivalue_line(
"markers", "installed: mark test as testing installed features"
)


def pytest_collection_modifyitems(config, items):
skip_slow = pytest.mark.skip(reason="need --runslow option to run")
skip_installed = pytest.mark.skip(reason="need --runinstalled option to run")

for item in items:
if "installed" in item.keywords and not config.getoption("--runinstalled"):
item.add_marker(skip_installed)
if "slow" in item.keywords and not config.getoption("--runslow"):
item.add_marker(skip_slow)

Expand Down
2 changes: 2 additions & 0 deletions tests/ogvjs/test_ogvjs.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def prepare_ogvjs_folder(tmp_path, videojs_url, ogvjs_url, videojs_ogvjs_url):
tmp_path.joinpath(member).rename(tmp_path.joinpath("videojs-ogvjs.js"))


@pytest.mark.installed
def test_ogvjs_installed_script_missing_param():
# run from installed script to check real conditions
script = subprocess.run(
Expand All @@ -63,6 +64,7 @@ def test_ogvjs_from_code_missing_params():


@pytest.mark.slow
@pytest.mark.installed
def test_ogvjs_installed_script_ok(tmp_path, videojs_url, ogvjs_url, videojs_ogvjs_url):
# run from installed script to check real conditions

Expand Down

0 comments on commit 53ad6fc

Please sign in to comment.