Skip to content

Tests fixes #328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 9, 2023
Merged
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
27 changes: 16 additions & 11 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,12 @@ def test_conversion_with_data_files(self):
if os.path.exists(test_docx_file):
os.remove(test_docx_file)
result = pypandoc.convert_file(
os.path.join(test_data_dir, 'index.html'),
to='docx',
format='html',
outputfile=test_docx_file,
sandbox=True,
)
os.path.join(test_data_dir, 'index.html'),
to='docx',
format='html',
outputfile=test_docx_file,
sandbox=True,
)
print(result)

def test_convert_with_custom_writer(self):
Expand Down Expand Up @@ -347,9 +347,10 @@ def caps(key, value, format, meta):
toJSONFilter(caps)
'''
python_source = textwrap.dedent(python_source)
python_source.format(sys.executable)
python_source = python_source.format(sys.executable)

with closed_tempfile(".py", python_source) as tempfile:
os.chmod(tempfile, 0o755)
output = pypandoc.convert_text(
markdown_source, to='html', format='md', outputfile=None, filters=tempfile
).strip()
Expand Down Expand Up @@ -389,28 +390,32 @@ def test_conversion_with_mixed_filters(self):

def func(key, value, format, meta):
if key == "Para":
return Para(value + [Str("{0}-")])
return Para(value + [Str("{{0}}-")])

if __name__ == "__main__":
toJSONFilter(func)

"""
python = textwrap.dedent(python)
python.format(sys.executable)
python = python.format(sys.executable)

with closed_tempfile(".lua", lua.format(1)) as temp1, closed_tempfile(".py", python.format(2)) as temp2:
os.chmod(temp2, 0o755)

with closed_tempfile(".lua", lua.format(3)) as temp3, closed_tempfile(".py", python.format(4)) as temp4:
os.chmod(temp4, 0o755)

output = pypandoc.convert_text(
markdown_source, to="html", format="md", outputfile=None, filters=[temp1, temp2, temp3, temp4]
).strip()
expected = "<p>-0-1-2-3-4-</p>"
self.assertTrue(output == expected)
self.assertEquals(output, expected)

output = pypandoc.convert_text(
markdown_source, to="html", format="md", outputfile=None, filters=[temp3, temp1, temp4, temp2]
).strip()
expected = "<p>-0-3-1-4-2-</p>"
self.assertTrue(output == expected)
self.assertEquals(output, expected)

def test_classify_pandoc_logging(self):

Expand Down