Skip to content

Commit

Permalink
Move doctests to pytests so they can be skipped
Browse files Browse the repository at this point in the history
  • Loading branch information
davidar committed Oct 24, 2024
1 parent 14bad2f commit 44a475a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
3 changes: 0 additions & 3 deletions mathics/builtin/file_operations/file_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,6 @@ class SetFileDate(Builtin):
>> SetFileDate[tmpfilename, {2002, 1, 1, 0, 0, 0.}, "Access"];
>> FileDate[tmpfilename, "Access"]
= {2002, 1, 1, 0, 0, 0.}
#> DeleteFile[tmpfilename]
"""

Expand Down
2 changes: 0 additions & 2 deletions mathics/builtin/files_io/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,6 @@ class OpenRead(_OpenAction):
The stream must be closed after using it to release the resource:
>> Close[%];
S> Close[OpenRead["https://raw.githubusercontent.com/Mathics3/mathics-core/master/README.rst"]];
"""

summary_text = "open a file for reading"
Expand Down
16 changes: 16 additions & 0 deletions test/builtin/files_io/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ def test_close():
"OpenRead[]",
"",
),
(
'Close[OpenRead["https://raw.githubusercontent.com/Mathics3/mathics-core/master/README.rst"]];',
None,
"Null",
"",
),
(
'fd=OpenRead["ExampleData/EinsteinSzilLetter.txt", BinaryFormat -> True, CharacterEncoding->"UTF8"]//Head',
None,
Expand Down Expand Up @@ -318,6 +324,16 @@ def test_close():
),
("FilePrint[pathname]", None, "Null", ""),
("DeleteFile[pathname];Clear[pathname];", None, "Null", ""),
('tmpfilename = $TemporaryDirectory <> "/tmp0";', None, "Null", ""),
("Close[OpenWrite[tmpfilename]];", None, "Null", ""),
(
'SetFileDate[tmpfilename, {2002, 1, 1, 0, 0, 0.}, "Access"];',
None,
"Null",
"",
),
('FileDate[tmpfilename, "Access"]', None, "{2002, 1, 1, 0, 0, 0.}", ""),
("DeleteFile[tmpfilename]", None, "Null", ""),
],
)
def test_private_doctests_files(str_expr, msgs, str_expected, fail_msg):
Expand Down

0 comments on commit 44a475a

Please sign in to comment.