-
Notifications
You must be signed in to change notification settings - Fork 670
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This involved numerous fixes to the code and tests, to use posix strings. There was also an issue of the tempdir being created on a different drive. Therefore, a pytest cmdline option was added to set the location of this directory. Additionally, pip caching was set up on the GitHub CI, and and pytest-timeout config Co-authored-by: phaustin <https://github.com/phaustin> Co-authored-by: foster999 <https://github.com/foster999>"
- Loading branch information
1 parent
1f0c7a7
commit 6fb0cbe
Showing
13 changed files
with
223 additions
and
101 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
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,40 @@ | ||
"""On GH Actions windows-latest, the supplied tmpdir is on a different Drive to the CWD, | ||
and so relative path computations fail. | ||
Therefore, here we allow for the directory to be directly supplied, | ||
via an environmental variable. | ||
""" | ||
import shutil | ||
from pathlib import Path | ||
from uuid import uuid4 | ||
|
||
import pytest | ||
|
||
|
||
def pytest_addoption(parser): | ||
"""Define pytest command-line option""" | ||
group = parser.getgroup("jupyter_book") | ||
group.addoption( | ||
"--jb-tempdir", | ||
dest="jb_tempdir", | ||
default=None, | ||
help="Specify a directory in which to create tempdirs", | ||
) | ||
|
||
|
||
def pytest_report_header(config): | ||
path = "<TEMP>" | ||
if config.getoption("jb_tempdir"): | ||
path = Path(config.getoption("jb_tempdir")).absolute().as_posix() | ||
return [f"JB TEMPDIR: {path}"] | ||
|
||
|
||
@pytest.fixture() | ||
def temp_with_override(pytestconfig, tmpdir): | ||
if pytestconfig.getoption("jb_tempdir"): | ||
path = Path(pytestconfig.getoption("jb_tempdir")).resolve().absolute() | ||
path = path / str(uuid4()) | ||
path.mkdir(parents=True) | ||
yield path | ||
shutil.rmtree(path) | ||
else: | ||
yield Path(tmpdir.dirname) / tmpdir.basename |
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
Oops, something went wrong.