Skip to content

Commit 23fd7de

Browse files
committed
pandoc_fe: --output is not mandatory
1 parent c317a46 commit 23fd7de

File tree

2 files changed

+73
-73
lines changed

2 files changed

+73
-73
lines changed

contrib/testsuite/test_adacut.py

Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,68 @@
1-
from pathlib import Path
2-
import epycs.subprocess
3-
from epycs.subprocess import cmd, ShellProgramFilters
4-
5-
epycs.subprocess.exit_on_error = False
6-
7-
8-
TEST_DIR = Path(__file__).parent
9-
TEST_DATA_DIR = TEST_DIR / "adacut"
10-
CONTRIB = TEST_DIR.parent
11-
ADACUT_PY = CONTRIB / "adacut.py"
12-
13-
14-
adacut = cmd.python.arg(ADACUT_PY)
15-
16-
17-
class TestAdaCut:
18-
@classmethod
19-
def init_tests(cls):
20-
for d in (
21-
d_tpl.parent
22-
for d_tpl in TEST_DATA_DIR.glob("**/template")
23-
if d_tpl.is_dir()
24-
):
25-
tests = {}
26-
27-
for dd in (d_src for d_src in d.glob("src_*") if d_src.is_dir()):
28-
cls.add_src_tests(tests, d, dd)
29-
30-
for name, test in tests.items():
31-
setattr(cls, f"test_{name}", test)
32-
33-
def maybe_update_baseline(self, pytestconfig, expected_file, actual):
34-
if pytestconfig.getoption("--update-baseline"):
35-
with open(expected_file, "wt") as f:
36-
f.write(actual)
37-
38-
def assert_file_content_equal(self, pytestconfig, expected_file, actual):
39-
with open(expected_file) as f:
40-
expected = f.read()
41-
42-
try:
43-
assert actual == expected
44-
except AssertionError:
45-
self.maybe_update_baseline(pytestconfig, expected_file, actual)
46-
raise
47-
48-
@classmethod
49-
def parse_options(cls, name):
50-
return name.split("_")
51-
52-
@classmethod
53-
def add_src_tests(cls, tests, d, d_src):
54-
options = cls.parse_options(d_src.name[len("src_") :])
55-
for f in (d / "template").glob("*.ad?"):
56-
57-
def test_file_content_is_expected(self, pytestconfig):
58-
actual = adacut(
59-
*options, "--", f, check=True, out_filter=ShellProgramFilters.text
60-
)
61-
self.assert_file_content_equal(pytestconfig, d_src / f.name, actual)
62-
63-
tests[f"{d_src.parent.name}_{d_src.name}_{f.name}"] = (
64-
test_file_content_is_expected
65-
)
66-
67-
68-
TestAdaCut.init_tests()
1+
from pathlib import Path
2+
import epycs.subprocess
3+
from epycs.subprocess import cmd, ShellProgramFilters
4+
5+
epycs.subprocess.exit_on_error = False
6+
7+
8+
TEST_DIR = Path(__file__).parent
9+
TEST_DATA_DIR = TEST_DIR / "adacut"
10+
CONTRIB = TEST_DIR.parent
11+
ADACUT_PY = CONTRIB / "adacut.py"
12+
13+
14+
adacut = cmd.python.arg(ADACUT_PY)
15+
16+
17+
class TestAdaCut:
18+
@classmethod
19+
def init_tests(cls):
20+
for d in (
21+
d_tpl.parent
22+
for d_tpl in TEST_DATA_DIR.glob("**/template")
23+
if d_tpl.is_dir()
24+
):
25+
tests = {}
26+
27+
for dd in (d_src for d_src in d.glob("src_*") if d_src.is_dir()):
28+
cls.add_src_tests(tests, d, dd)
29+
30+
for name, test in tests.items():
31+
setattr(cls, f"test_{name}", test)
32+
33+
def maybe_update_baseline(self, pytestconfig, expected_file, actual):
34+
if pytestconfig.getoption("--update-baseline"):
35+
with open(expected_file, "wt") as f:
36+
f.write(actual)
37+
38+
def assert_file_content_equal(self, pytestconfig, expected_file, actual):
39+
with open(expected_file) as f:
40+
expected = f.read()
41+
42+
try:
43+
assert actual == expected
44+
except AssertionError:
45+
self.maybe_update_baseline(pytestconfig, expected_file, actual)
46+
raise
47+
48+
@classmethod
49+
def parse_options(cls, name):
50+
return name.split("_")
51+
52+
@classmethod
53+
def add_src_tests(cls, tests, d, d_src):
54+
options = cls.parse_options(d_src.name[len("src_") :])
55+
for f in (d / "template").glob("*.ad?"):
56+
57+
def test_file_content_is_expected(self, pytestconfig):
58+
actual = adacut(
59+
*options, "--", f, check=True, out_filter=ShellProgramFilters.text
60+
)
61+
self.assert_file_content_equal(pytestconfig, d_src / f.name, actual)
62+
63+
tests[
64+
f"{d_src.parent.name}_{d_src.name}_{f.name}"
65+
] = test_file_content_is_expected
66+
67+
68+
TestAdaCut.init_tests()

pandoc/pandoc_fe.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,11 @@ def pandoc_prepare_run_single(n, source_or_source_list, args):
216216

217217
extension = args.extension
218218
if extension is None:
219-
spl = args.output.rsplit(".", 1)
220-
if spl:
221-
extension = spl[-1]
222-
else:
223-
extension = "pdf"
219+
extension = "pdf" # Default
220+
if args.output is not None:
221+
spl = args.output.rsplit(".", 1)
222+
if spl:
223+
extension = spl[-1]
224224

225225
# Output default value is input file name
226226
output_file = output_file_name(

0 commit comments

Comments
 (0)