Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ requirements:

run:
- python >=3.6
- pytask >=0.0.4
- pytask >=0.0.7

test:
requires:
Expand Down
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ all releases are available on `Anaconda.org
<https://anaconda.org/pytask/pytask-latex>`_.


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
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies:
- conda-verify

# Package dependencies
- pytask >= 0.0.4
- pytask >= 0.0.7

# Misc
- bumpversion
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.0.4
current_version = 0.0.5
parse = (?P<major>\d+)\.(?P<minor>\d+)(\.(?P<patch>\d+))(\-?((dev)?(?P<dev>\d+))?)
serialize =
{major}.{minor}.{patch}dev{dev}
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]},
Expand Down
2 changes: 1 addition & 1 deletion src/pytask_latex/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.0.4"
__version__ = "0.0.5"
26 changes: 17 additions & 9 deletions src/pytask_latex/collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
36 changes: 21 additions & 15 deletions tests/test_collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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",
Expand All @@ -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)
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ basepython = python

[testenv:pytest]
conda_deps =
pytask >=0.0.4
pytask >=0.0.7
pytest
pytest-cov
pytest-xdist
Expand Down