Skip to content

Commit

Permalink
Merge pull request #86 from rstcheck/issue-#84-fix-yaml-tests-running…
Browse files Browse the repository at this point in the history
…-when-yaml-is-missing

Issue #84 fix yaml tests running when yaml is missing
  • Loading branch information
Cielquan authored Jan 12, 2024
2 parents f7e894d + e05e2a2 commit 0fc90c8
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ repos:

# prettier - multi formatter
- repo: https://github.com/pre-commit/mirrors-prettier
rev: f12edd9c7be1c20cfa42420fd0e6df71e42b51ea # frozen: v4.0.0-alpha.8
rev: ffb6a759a979008c0e6dff86e39f4745a2d9eac4 # frozen: v3.1.0
hooks:
- id: prettier

Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ NOTE: please use them in this order.

[diff v1.2.0...main](https://github.com/rstcheck/rstcheck-core/compare/v1.2.0...main)

### Miscellaneous

- Fixed yaml tests running even when pyyaml is not installed ([#84](https://github.com/rstcheck/rstcheck-core/issues/84))

## [1.2.0 (2023-11-13)](https://github.com/rstcheck/rstcheck-core/releases/v1.2.0)

[diff v1.1.1...v1.2.0](https://github.com/rstcheck/rstcheck-core/compare/v1.1.1...v1.2.0)
Expand Down
2 changes: 2 additions & 0 deletions docs/source/spelling_dict.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ pre
py
pyproject
pytest
pyyaml
rc
rd
reStructuredText
Expand Down Expand Up @@ -98,3 +99,4 @@ venv
virtualenv
whitespace
xml
yaml
4 changes: 4 additions & 0 deletions tests/checker_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,7 @@ def test_check_json_returns_error_on_bad_code_block() -> None:
assert "Expecting value:" in result[0]["message"]

@staticmethod
@pytest.mark.skipif(checker.yaml_imported is False, reason="Requires pyyaml to be installed")
def test_check_yaml_returns_none_on_ok_code_block_no_pyyaml(
mocker: pytest_mock.MockerFixture,
) -> None:
Expand All @@ -794,6 +795,7 @@ def test_check_yaml_returns_none_on_ok_code_block_no_pyyaml(
assert not result

@staticmethod
@pytest.mark.skipif(checker.yaml_imported is False, reason="Requires pyyaml to be installed")
def test_check_yaml_returns_ok_on_bad_code_block_no_pyyaml(
mocker: pytest_mock.MockerFixture,
) -> None:
Expand All @@ -810,6 +812,7 @@ def test_check_yaml_returns_ok_on_bad_code_block_no_pyyaml(
assert not result

@staticmethod
@pytest.mark.skipif(checker.yaml_imported is False, reason="Requires pyyaml to be installed")
def test_check_yaml_returns_none_on_ok_code_block() -> None:
"""Test ``check_json`` returns ``None`` on ok code block."""
source = """
Expand All @@ -823,6 +826,7 @@ def test_check_yaml_returns_none_on_ok_code_block() -> None:
assert not result

@staticmethod
@pytest.mark.skipif(checker.yaml_imported is False, reason="Requires pyyaml to be installed")
def test_check_yaml_returns_error_on_bad_code_block() -> None:
"""Test ``check_json`` returns error on bad code block."""
source = """
Expand Down
34 changes: 27 additions & 7 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ env_list =
docs-test-{html,linkcheck,coverage,doctest,spelling}

labels =
test = py{312,311,310,39,38},py{312,311,310,39,38}-with-sphinx{4,5,6,7},py{312,311,310,39,38}-with-tomli,coverage-all
py3.8 = py38,py38-with-sphinx{4,5,6,7},py38-with-tomli,coverage-all
py3.9 = py39,py39-with-sphinx{4,5,6,7},py39-with-tomli,coverage-all
py3.10 = py310,py310-with-sphinx{4,5,6,7},py310-with-tomli,package,coverage-all
py3.11 = py311,py311-with-sphinx{4,5,6,7},py311-with-tomli,package,coverage-all
py3.12 = py312,py312-with-sphinx{4,5,6,7},py312-with-tomli,package,coverage-all
test = py{312,311,310,39,38},py{312,311,310,39,38}-with-yaml,py{312,311,310,39,38}-with-sphinx{4,5,6,7},py{312,311,310,39,38}-with-tomli,coverage-all
py3.8 = py38,py38-with-yaml,py38-with-sphinx{4,5,6,7},py38-with-tomli,coverage-all
py3.9 = py39,py39-with-yaml,py39-with-sphinx{4,5,6,7},py39-with-tomli,coverage-all
py3.10 = py310,py310-with-yaml,py310-with-sphinx{4,5,6,7},py310-with-tomli,package,coverage-all
py3.11 = py311,py311-with-yaml,py311-with-sphinx{4,5,6,7},py311-with-tomli,package,coverage-all
py3.12 = py312,py312-with-yaml,py312-with-sphinx{4,5,6,7},py312-with-tomli,package,coverage-all
docs = docs-test-{html,linkcheck,coverage,doctest,spelling}


Expand Down Expand Up @@ -110,6 +110,26 @@ commands =

[testenv:py{312,311,310,39,38}]
description = run tests with {basepython}
pass_env =
{[testenv]pass_env}
PYTEST_*
set_env =
{[testenv]set_env}
COVERAGE_FILE = {env:COVERAGE_FILE:{toxinidir}/.coverage_cache/.coverage.{envname}}
extras =
testing
commands =
pytest \
{tty:--color yes:{env:CI_FORCE_COLORS_PYTEST:}} \
--basetemp {envtmpdir} \
--cov {envsitepackagesdir}/{[tox]package} \
--cov-fail-under 0 \
{tty::-vvv} \
{posargs:tests}


[testenv:py{312,311,310,39,38}-with-yaml]
description = run tests with {basepython}
pass_env =
{[testenv]pass_env}
PYTEST_*
Expand Down Expand Up @@ -164,8 +184,8 @@ set_env =
{[testenv]set_env}
COVERAGE_FILE = {env:COVERAGE_FILE:{toxinidir}/.coverage_cache/.coverage.{envname}}
extras =
toml
testing
toml
yaml
commands =
pytest \
Expand Down

0 comments on commit 0fc90c8

Please sign in to comment.