Skip to content

Commit 6a7d67a

Browse files
authored
Align with pytask v0.0.7 and release 0.0.5. (#8)
1 parent 186c0e9 commit 6a7d67a

File tree

9 files changed

+46
-31
lines changed

9 files changed

+46
-31
lines changed

.conda/meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ requirements:
2020

2121
run:
2222
- python >=3.6
23-
- pytask >=0.0.4
23+
- pytask >=0.0.7
2424

2525
test:
2626
requires:

CHANGES.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ all releases are available on `Anaconda.org
77
<https://anaconda.org/pytask/pytask-latex>`_.
88

99

10-
0.0.5 - 2020-xx-xx
10+
0.0.5 - 2020-10-04
1111
------------------
1212

1313
- :gh:`5` fixes some errors in the test suite due to pytask v0.0.6.
1414
- :gh:`6` check that exit codes are equal to zero.
1515
- :gh:`7` fixes the README.
16+
- :gh:`8` works with pytask v0.0.7 and releases v0.0.5.
1617

1718

1819
0.0.4 - 2020-08-21

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies:
1212
- conda-verify
1313

1414
# Package dependencies
15-
- pytask >= 0.0.4
15+
- pytask >= 0.0.7
1616

1717
# Misc
1818
- bumpversion

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.0.4
2+
current_version = 0.0.5
33
parse = (?P<major>\d+)\.(?P<minor>\d+)(\.(?P<patch>\d+))(\-?((dev)?(?P<dev>\d+))?)
44
serialize =
55
{major}.{minor}.{patch}dev{dev}

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
setup(
55
name="pytask-latex",
6-
version="0.0.4",
6+
version="0.0.5",
77
packages=find_packages(where="src"),
88
package_dir={"": "src"},
99
entry_points={"pytask": ["pytask_latex = pytask_latex.plugin"]},

src/pytask_latex/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.0.4"
1+
__version__ = "0.0.5"

src/pytask_latex/collect.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,27 +98,35 @@ def pytask_collect_task(session, path, name, obj):
9898

9999
task.function = latex_function
100100

101-
# Perform some checks.
102-
if not (
103-
isinstance(task.depends_on[0], FilePathNode)
104-
and task.depends_on[0].value.suffix == ".tex"
101+
return task
102+
103+
104+
@hookimpl
105+
def pytask_collect_task_teardown(task):
106+
"""Perform some checks."""
107+
if task is not None:
108+
if (len(task.depends_on) == 0) or (
109+
not (
110+
isinstance(task.depends_on[0], FilePathNode)
111+
and task.depends_on[0].value.suffix == ".tex"
112+
)
105113
):
106114
raise ValueError(
107115
"The first or sole dependency of a LaTeX task must be the document "
108116
"which will be compiled and has a .tex extension."
109117
)
110118

111-
if not (
112-
isinstance(task.produces[0], FilePathNode)
113-
and task.produces[0].value.suffix in [".pdf", ".ps", ".dvi"]
119+
if (len(task.produces) == 0) or (
120+
not (
121+
isinstance(task.produces[0], FilePathNode)
122+
and task.produces[0].value.suffix in [".pdf", ".ps", ".dvi"]
123+
)
114124
):
115125
raise ValueError(
116126
"The first or sole product of a LaTeX task must point to a .pdf, .ps "
117127
"or .dvi file which is the compiled document."
118128
)
119129

120-
return task
121-
122130

123131
def _merge_all_markers(task):
124132
"""Combine all information from markers for the compile latex function."""

tests/test_collect.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from pytask_latex.collect import DEFAULT_OPTIONS
99
from pytask_latex.collect import latex
1010
from pytask_latex.collect import pytask_collect_task
11+
from pytask_latex.collect import pytask_collect_task_teardown
1112

1213

1314
class DummyClass:
@@ -53,6 +54,24 @@ def test_latex(latex_args, expected):
5354
assert options == expected
5455

5556

57+
@pytest.mark.unit
58+
@pytest.mark.parametrize(
59+
"name, expected",
60+
[("task_dummy", True), ("invalid_name", None)],
61+
)
62+
def test_pytask_collect_task(name, expected):
63+
session = DummyClass()
64+
path = Path("some_path")
65+
task_dummy.pytaskmark = [Mark("latex", (), {})]
66+
67+
task = pytask_collect_task(session, path, name, task_dummy)
68+
69+
if expected:
70+
assert task
71+
else:
72+
assert not task
73+
74+
5675
@pytest.mark.unit
5776
@pytest.mark.parametrize(
5877
"depends_on, produces, expectation",
@@ -68,25 +87,12 @@ def test_latex(latex_args, expected):
6887
(["document.tex"], ["document.out", "document.pdf"], pytest.raises(ValueError)),
6988
],
7089
)
71-
def test_pytask_collect_task(monkeypatch, depends_on, produces, expectation):
72-
session = DummyClass()
73-
path = Path("some_path")
74-
75-
task_dummy.pytaskmark = [Mark("latex", (), {})] + [
76-
Mark("depends_on", tuple(d for d in depends_on), {}),
77-
Mark("produces", tuple(d for d in produces), {}),
78-
]
79-
90+
def test_pytask_collect_task_teardown(depends_on, produces, expectation):
8091
task = DummyClass()
8192
task.depends_on = [FilePathNode(n.split(".")[0], Path(n)) for n in depends_on]
8293
task.produces = [FilePathNode(n.split(".")[0], Path(n)) for n in produces]
8394
task.markers = [Mark("latex", (), {})]
8495
task.function = task_dummy
8596

86-
monkeypatch.setattr(
87-
"pytask_latex.collect.PythonFunctionTask.from_path_name_function_session",
88-
lambda *x: task,
89-
)
90-
9197
with expectation:
92-
pytask_collect_task(session, path, "task_dummy", task_dummy)
98+
pytask_collect_task_teardown(task)

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ basepython = python
99

1010
[testenv:pytest]
1111
conda_deps =
12-
pytask >=0.0.4
12+
pytask >=0.0.7
1313
pytest
1414
pytest-cov
1515
pytest-xdist

0 commit comments

Comments
 (0)