diff --git a/.conda/meta.yaml b/.conda/meta.yaml index 417c05c..1d9a45f 100644 --- a/.conda/meta.yaml +++ b/.conda/meta.yaml @@ -20,7 +20,7 @@ requirements: run: - python >=3.6 - - pytask >=0.0.4 + - pytask >=0.0.7 test: requires: diff --git a/CHANGES.rst b/CHANGES.rst index dec38fb..5cc4f66 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -7,12 +7,13 @@ all releases are available on `Anaconda.org `_. -0.0.5 - 2020-xx-xx +0.0.5 - 2020-10-04 ------------------ - :gh:`5` fixes some errors in the test suite due to pytask v0.0.6. - :gh:`6` check that exit codes are equal to zero. - :gh:`7` fixes the README. +- :gh:`8` works with pytask v0.0.7 and releases v0.0.5. 0.0.4 - 2020-08-21 diff --git a/environment.yml b/environment.yml index ed81146..4fc1a3a 100644 --- a/environment.yml +++ b/environment.yml @@ -12,7 +12,7 @@ dependencies: - conda-verify # Package dependencies - - pytask >= 0.0.4 + - pytask >= 0.0.7 # Misc - bumpversion diff --git a/setup.cfg b/setup.cfg index 4f415b2..399ec26 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.0.4 +current_version = 0.0.5 parse = (?P\d+)\.(?P\d+)(\.(?P\d+))(\-?((dev)?(?P\d+))?) serialize = {major}.{minor}.{patch}dev{dev} diff --git a/setup.py b/setup.py index eb91729..b4137d5 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name="pytask-latex", - version="0.0.4", + version="0.0.5", packages=find_packages(where="src"), package_dir={"": "src"}, entry_points={"pytask": ["pytask_latex = pytask_latex.plugin"]}, diff --git a/src/pytask_latex/__init__.py b/src/pytask_latex/__init__.py index 81f0fde..b1a19e3 100644 --- a/src/pytask_latex/__init__.py +++ b/src/pytask_latex/__init__.py @@ -1 +1 @@ -__version__ = "0.0.4" +__version__ = "0.0.5" diff --git a/src/pytask_latex/collect.py b/src/pytask_latex/collect.py index 7c4772a..8084d43 100644 --- a/src/pytask_latex/collect.py +++ b/src/pytask_latex/collect.py @@ -98,27 +98,35 @@ def pytask_collect_task(session, path, name, obj): task.function = latex_function - # Perform some checks. - if not ( - isinstance(task.depends_on[0], FilePathNode) - and task.depends_on[0].value.suffix == ".tex" + return task + + +@hookimpl +def pytask_collect_task_teardown(task): + """Perform some checks.""" + if task is not None: + if (len(task.depends_on) == 0) or ( + not ( + isinstance(task.depends_on[0], FilePathNode) + and task.depends_on[0].value.suffix == ".tex" + ) ): raise ValueError( "The first or sole dependency of a LaTeX task must be the document " "which will be compiled and has a .tex extension." ) - if not ( - isinstance(task.produces[0], FilePathNode) - and task.produces[0].value.suffix in [".pdf", ".ps", ".dvi"] + if (len(task.produces) == 0) or ( + not ( + isinstance(task.produces[0], FilePathNode) + and task.produces[0].value.suffix in [".pdf", ".ps", ".dvi"] + ) ): raise ValueError( "The first or sole product of a LaTeX task must point to a .pdf, .ps " "or .dvi file which is the compiled document." ) - return task - def _merge_all_markers(task): """Combine all information from markers for the compile latex function.""" diff --git a/tests/test_collect.py b/tests/test_collect.py index 9925198..06068de 100644 --- a/tests/test_collect.py +++ b/tests/test_collect.py @@ -8,6 +8,7 @@ from pytask_latex.collect import DEFAULT_OPTIONS from pytask_latex.collect import latex from pytask_latex.collect import pytask_collect_task +from pytask_latex.collect import pytask_collect_task_teardown class DummyClass: @@ -53,6 +54,24 @@ def test_latex(latex_args, expected): assert options == expected +@pytest.mark.unit +@pytest.mark.parametrize( + "name, expected", + [("task_dummy", True), ("invalid_name", None)], +) +def test_pytask_collect_task(name, expected): + session = DummyClass() + path = Path("some_path") + task_dummy.pytaskmark = [Mark("latex", (), {})] + + task = pytask_collect_task(session, path, name, task_dummy) + + if expected: + assert task + else: + assert not task + + @pytest.mark.unit @pytest.mark.parametrize( "depends_on, produces, expectation", @@ -68,25 +87,12 @@ def test_latex(latex_args, expected): (["document.tex"], ["document.out", "document.pdf"], pytest.raises(ValueError)), ], ) -def test_pytask_collect_task(monkeypatch, depends_on, produces, expectation): - session = DummyClass() - path = Path("some_path") - - task_dummy.pytaskmark = [Mark("latex", (), {})] + [ - Mark("depends_on", tuple(d for d in depends_on), {}), - Mark("produces", tuple(d for d in produces), {}), - ] - +def test_pytask_collect_task_teardown(depends_on, produces, expectation): task = DummyClass() task.depends_on = [FilePathNode(n.split(".")[0], Path(n)) for n in depends_on] task.produces = [FilePathNode(n.split(".")[0], Path(n)) for n in produces] task.markers = [Mark("latex", (), {})] task.function = task_dummy - monkeypatch.setattr( - "pytask_latex.collect.PythonFunctionTask.from_path_name_function_session", - lambda *x: task, - ) - with expectation: - pytask_collect_task(session, path, "task_dummy", task_dummy) + pytask_collect_task_teardown(task) diff --git a/tox.ini b/tox.ini index cf3fc2d..653a3ee 100644 --- a/tox.ini +++ b/tox.ini @@ -9,7 +9,7 @@ basepython = python [testenv:pytest] conda_deps = - pytask >=0.0.4 + pytask >=0.0.7 pytest pytest-cov pytest-xdist