From cfda2af6f579c31f8cb1e8f663f32334777c7cc9 Mon Sep 17 00:00:00 2001 From: rocky Date: Sat, 1 May 2021 02:36:16 -0400 Subject: [PATCH] tests for $InputFileName in recursive get --- test/test_files.py | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/test/test_files.py b/test/test_files.py index 673cd1f3c6..9188f07c1d 100644 --- a/test/test_files.py +++ b/test/test_files.py @@ -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}"]]' @@ -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))