-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from esm-tools/fix/doctests
Doctest Optimizations
- Loading branch information
Showing
11 changed files
with
91 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import os | ||
import re | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from tests.utils.constants import TEST_ROOT | ||
|
||
pytest_plugins = [ | ||
"tests.fixtures.configs", | ||
"tests.fixtures.environment", | ||
"tests.fixtures.fake_filesystem", | ||
"tests.fixtures.sample_rules", | ||
"tests.fixtures.config_files", | ||
"tests.fixtures.CV_Dir", | ||
"tests.fixtures.CMIP_Tables_Dir", | ||
] | ||
|
||
|
||
@pytest.hookimpl(tryfirst=True) | ||
def pytest_collection_modifyitems(config, items): | ||
for item in items: | ||
if item.fspath and item.fspath.ext == ".py": | ||
item.add_marker(pytest.mark.doctest) | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def pathlib_doctest_directive(doctest_namespace): | ||
"""Replace PosixPath/WindowsPath with Path in doc-test output.""" | ||
doctest_namespace["Path"] = Path | ||
|
||
def path_replace(output): | ||
"""Replace platform-specific Path output with generic Path in doc-tests.""" | ||
return re.sub(r"(PosixPath|WindowsPath)\((.*?)\)", r"Path(\2)", output) | ||
|
||
doctest_namespace["path_replace"] = path_replace | ||
|
||
|
||
def pytest_unconfigure(config): | ||
"""Remove all JSON files containing 'pipeline' in their name.""" | ||
for file in os.listdir(): | ||
if "pipeline" in file and file.endswith(".json"): | ||
os.remove(file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[pytest] | ||
doctest_optionflags = NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL ELLIPSIS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.