Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compartmentalize README doc/shell tests #261

Merged
merged 3 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,26 @@ stages:
- script: cd doc; make doctest
displayName: Run doctests

- job: readme
displayName: Run README doctests/shell tests

pool:
vmImage: 'Ubuntu-latest'

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.10'

- script: pip install -r requirements-ci.txt
displayName: Install CI requirements

- script: cd doc; make html
displayName: Build docs

- script: pytest -k readme --readme --doctest-glob="README.rst"
displayName: Run README doc/shell tests

- job: linkcheck
displayName: Run docs link-check suite

Expand Down Expand Up @@ -161,7 +181,7 @@ stages:
- script: cd doc; make html; mkdir scratch
displayName: Build docset

- script: pytest --cov=. --nonloc --flake8_ext
- script: pytest --cov=. --nonloc --flake8_ext --readme
displayName: Run pytest with coverage on the entire project tree

- script: coverage report --include="tests/*" --fail-under=100
Expand Down
1 change: 1 addition & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def pytest_addoption(parser):
parser.addoption(
"--flake8_ext", action="store_true", help="Include flake8 extensions test"
)
parser.addoption("--readme", action="store_true", help="Include README shell tests")


@pytest.fixture(scope="session")
Expand Down
2 changes: 1 addition & 1 deletion src/sphobjinv/cli/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def attempt_inv_load(url, params):
print_stderr(f" ... HTTP error: {e.code} {e.reason}.", params)
except URLError: # pragma: no cover
print_stderr(" ... error attempting to retrieve URL.", params)
except VersionError:
except VersionError: # pragma: no cover
print_stderr(" ... no recognized inventory.", params)
except ValueError:
print_stderr(
Expand Down
14 changes: 14 additions & 0 deletions tests/test_readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@
)


pytestmark = [pytest.mark.readme]


@pytest.fixture(scope="module", autouse=True)
def skip_if_no_readme_option(pytestconfig):
"""Skip test if --readme not provided.

Auto-applied to all functions in module, since module is dedicated to README.

"""
if not pytestconfig.getoption("--readme"):
pytest.skip("'--readme' not specified") # pragma: no cover


@pytest.mark.skipif(
sphinx_ver != sphinx_req,
reason="Skip if Sphinx version mismatches current dev version.",
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ markers =
first: Inherited marker from `pytest-ordering`
timeout: Inherited marker from `pytest-timeout`

addopts = --strict-markers --doctest-glob="README.rst" -rsxX -Werror
addopts = --strict-markers -rsxX -Werror

norecursedirs = .* env* src *.egg dist build

Expand Down