Skip to content
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

Rewrite Export test so it doesn't pollute #1052

Merged
merged 1 commit into from
Aug 5, 2024
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
19 changes: 13 additions & 6 deletions test/builtin/files_io/test_importexport.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import pytest

from mathics.builtin.atomic.strings import to_python_encoding
from mathics.core.systemsymbols import SymbolFailed

# def test_import():
# eaccent = "\xe9"
Expand Down Expand Up @@ -221,12 +222,6 @@ def test_export():
),
## Empty elems
('Export["123.txt", 1+x, {}]', None, "123.txt", None),
(
'Export["123.jcp", 1+x, {}]',
("Cannot infer format of file 123.jcp.",),
"$Failed",
None,
),
## FORMATS
## ASCII text
('FileFormat["ExampleData/BloodToilTearsSweat.txt"]', None, "Text", None),
Expand Down Expand Up @@ -260,6 +255,18 @@ def test_private_doctests_importexport(str_expr, msgs, str_expected, fail_msg):
)


def test_inividually():
# Test Export where we cannot infer the export type from the file extension;
# here it is: ".jcp".
with tempfile.NamedTemporaryFile(mode="w", suffix=".jcp") as tmp:
filename = osp.join(tmp.name, "123.jcp")
expr = f'Export["{filename}", 1+x,' + "{}]"
result = evaluate(expr)
outs = [out.text for out in session.evaluation.out]
assert result == SymbolFailed
assert outs == [f"Cannot infer format of file {filename}."]


# TODO:
# mmatera: please put in pytest conditionally
# >> System`Convert`B64Dump`B64Encode["∫ f  x"]
Expand Down
Loading