Skip to content
Draft
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
40 changes: 32 additions & 8 deletions test/test_files.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
# -*- coding: utf-8 -*-
import sys
from .helper import check_evaluation, evaluate

if sys.platform not in ("win32",):
def test_put_and_get_and_InputFileName():
check_evaluation(
'Put[HoldForm[$InputFileName], $TemporaryDirectory<>"/getme.m"]', "Null"
)
check_evaluation(
'Get[$TemporaryDirectory<>"/getme.m"]', '$TemporaryDirectory<>"/getme.m"'
)

def test_put_and_get_and_InputFileName_recursive():
check_evaluation(
'Put[HoldForm[$InputFileName], $TemporaryDirectory<>"/getmeA.m"]', "Null"
)
check_evaluation(
'stream=OpenWrite[$TemporaryDirectory<>"/getmeB.m"];'
'cmd="Get[\\"" <> $TemporaryDirectory<>"/getmeA.m"<>"\\"]";'
"Write[stream,cmd];Close[stream]",
'$TemporaryDirectory<>"/getmeB.m"',
)
check_evaluation(
'Get[$TemporaryDirectory<>"/getmeB.m"]', '$TemporaryDirectory<>"/getmeA.m"'
)

def test_get_and_put():
temp_filename = evaluate('$TemporaryDirectory<>"/testfile"').to_python()
temp_filename_strip = temp_filename[1:-1]
check_evaluation(f"40! >> {temp_filename_strip}", "Null")
check_evaluation(f"<< {temp_filename_strip}", "40!")
check_evaluation(f"DeleteFile[{temp_filename}]", "Null")


def test_compress():
for text in ("", "abc", " "):
str_expr = f'Uncompress[Compress["{text}"]]'
Expand All @@ -18,14 +50,6 @@ def test_unprotected():
check_evaluation(str_expr, str_expected, message)


def test_get_and_put():
temp_filename = evaluate('$TemporaryDirectory<>"/testfile"').to_python()
temp_filename_strip = temp_filename[1:-1]
check_evaluation(f"40! >> {temp_filename_strip}", "Null")
check_evaluation(f"<< {temp_filename_strip}", "40!")
check_evaluation(f"DeleteFile[{temp_filename}]", "Null")


# I do not know what is it supposed to test with this...
# def test_Inputget_and_put():
# stream = Expression('Plus', Symbol('x'), Integer(2))
Expand Down