Skip to content

Commit

Permalink
Merge pull request #166 from openzim/installed_tests
Browse files Browse the repository at this point in the history
Add back a runinstalled marker for ogvjs tests
  • Loading branch information
benoit74 authored Jun 11, 2024
2 parents 7d49831 + 1760941 commit f3d1b07
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/Tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ 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'
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}

build_python:
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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ apk add ffmpeg gifsicle libmagic wget libjpeg

# Contribution

This project adheres to openZIM's [Contribution Guidelines](https://github.com/openzim/overview/wiki/Contributing)
This project adheres to openZIM's [Contribution Guidelines](https://github.com/openzim/overview/wiki/Contributing).

This project has implemented openZIM's [Python bootstrap, conventions and policies](https://github.com/openzim/_python-bootstrap/docs/Policy.md) **v1.0.2**.

```shell
pip install hatch
Expand Down
11 changes: 5 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["hatchling", "hatch-openzim"]
requires = ["hatchling", "hatch-openzim>=0.2"]
build-backend = "hatchling.build"

[project]
Expand All @@ -25,11 +25,10 @@ dynamic = ["authors", "classifiers", "keywords", "license", "version", "urls"]

[tool.hatch.metadata.hooks.openzim-metadata]
kind = "scraper"
# not yet supported in hatch-openzim 0.1
# additional-classifiers = [
# "Development Status :: 5 - Production/Stable",
# "Intended Audience :: Developers",
# ]
additional-classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
]

[project.optional-dependencies]
scripts = [
Expand Down
3 changes: 2 additions & 1 deletion tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def report_cov(ctx: Context, *, html: bool = False):
"""report coverage"""
ctx.run("coverage combine", warn=True, pty=use_pty)
ctx.run("coverage report --show-missing", pty=use_pty)
ctx.run("coverage xml", pty=use_pty)
if html:
ctx.run("coverage html", pty=use_pty)

Expand Down Expand Up @@ -92,7 +93,7 @@ def fix_black(ctx: Context, args: str = "."):
def fix_ruff(ctx: Context, args: str = "."):
"""fix all ruff rules"""
args = args or "." # needed for hatch script
ctx.run(f"ruff --fix {args}", pty=use_pty)
ctx.run(f"ruff check --fix {args}", pty=use_pty)


@task(
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 f3d1b07

Please sign in to comment.