Always expand all paths (journals, templates, etc) (#1468)

* Refactored path expansion calls into a new path.py file

This also fixed bugs with relative journal and template paths.

* Update tests for new path functions

Also, make the tests specific to Windows, Mac & Linux

Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
This commit is contained in:
Kevin 2022-05-21 14:06:07 -07:00 committed by GitHub
parent 1ce7ce8bfc
commit ea6df4705c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 172 additions and 21 deletions

View file

@ -2,8 +2,10 @@
# License: https://www.gnu.org/licenses/gpl-3.0.html
from pytest import mark
from pytest import skip
from jrnl.os_compat import on_windows
from jrnl.os_compat import on_posix
pytest_plugins = [
@ -15,11 +17,39 @@ pytest_plugins = [
def pytest_bdd_apply_tag(tag, function):
# skip markers
if tag == "skip_win":
marker = mark.skipif(on_windows(), reason="Skip test on Windows")
elif tag == "skip_posix":
marker = mark.skipif(on_posix(), reason="Skip test on Mac/Linux")
# only on OS markers
elif tag == "on_win":
marker = mark.skipif(not on_windows(), reason="Skip test not on Windows")
elif tag == "on_posix":
marker = mark.skipif(not on_posix(), reason="Skip test not on Mac/Linux")
else:
# Fall back to pytest-bdd's default behavior
return None
marker(function)
return True
def pytest_runtest_setup(item):
markers = [mark.name for mark in item.iter_markers()]
on_win = on_windows()
on_nix = on_posix()
if "skip_win" in markers and on_win:
skip("Skip test on Windows")
if "skip_posix" in markers and on_nix:
skip("Skip test on Mac/Linux")
if "on_win" in markers and not on_win:
skip("Skip test not on Windows")
if "on_posix" in markers and not on_nix:
skip("Skip test not on Mac/Linux")