With plantri installed, a doctest creates a file in SAGE_ROOT
jhpalmieri opened this issue · 9 comments
The doctest in graphs/graph_generators.py
sage: list(graphs.plantri_gen("6 -c 3")) # optional plantri
Traceback (most recent call last):
...
AttributeError: invalid options '6 -c 3'
creates a file "3" in SAGE_ROOT if the optional package plantri is detected and used. Maybe the doctest should be changed, maybe the code should be changed so that the error is caught before the file is created.
Component: packages: optional
Author: Dave Morris
Branch/Commit: 4b3b7f4
Reviewer: David Coudert
Issue created by migration from https://trac.sagemath.org/ticket/34245
Branch: public/34245
Author: Dave Morris
Commit: 4b3b7f4
Good catch! (Plantri parses "3" as the name of the output file.) This little patch fixes the doctest so it tests the same sagemath codepath without creating a file.
New commits:
4b3b7f4 | trac 34245 doctest shouldn't create file |
Thank you for the fix.
Reviewer: David Coudert
FYI, plantri writes to stderr:
- when
options='6 -c3'
['/Users/dcoudert/sage/local/bin/plantri 6 -c3 \n',
'2 triangulations written to stdout; cpu=0.00 sec\n']
- when
options='6 -c=3'
['/Users/dcoudert/sage/local/bin/plantri 6 -c=3 \n',
'>E /Users/dcoudert/sage/local/bin/plantri: -= is not permitted\n']
- when
options='6 -c 3'
['/Users/dcoudert/sage/local/bin/plantri 6 -c 3 \n',
'2 triangulations written to 3; cpu=0.02 sec\n']
In this last case, the graphs are written in file 3 and this is not an error. Consequently, some users may write output to file without noticing it and I don't know how to prevent that. We may however raise a warning since we can detect that stdout is missing.
Thanks for the review and additional comments. Perhaps there should be a follow-up ticket.
Changed branch from public/34245 to 4b3b7f4