Opened 7 years ago
Closed 5 years ago
#20270 closed defect (fixed)
some doctests are influenced by the contents of init.sage
Reported by:  Marc Mezzarobba  Owned by:  

Priority:  critical  Milestone:  sage8.0 
Component:  doctest framework  Keywords:  
Cc:  Merged in:  
Authors:  Volker Braun  Reviewers:  François Bissey 
Report Upstream:  N/A  Work issues:  
Branch:  2d898ec (Commits, GitHub, GitLab)  Commit:  2d898ec595530ccb4a7566516ac41c4fd0400032 
Dependencies:  Stopgaps: 
Description
“test shells” created using sage.repl.interpreter.get_test_shell()
load ~/.sage/init.sage
, making the doctests that use get_test_shell()
fragile.
$ echo "x = 'x'" > ~/.sage/init.sage $ ./sage t src/sage/repl/ipython_extension.py [...] sage t src/sage/repl/ipython_extension.py # 2 doctests failed
Change History (8)
comment:1 Changed 6 years ago by
Priority:  major → critical 

Type:  PLEASE CHANGE → defect 
comment:2 followup: 3 Changed 6 years ago by
In a general manner I think doctests should be run with DOT_SAGE=$temp
where $temp
is a temporary directory in /tmp
or /var/tmp
, preferably created with mktemp
or similar process. There may be a couple of tests for which that would cause problem, but overall it would be much more robust.
comment:3 Changed 6 years ago by
Replying to fbissey:
In a general manner I think doctests should be run with
DOT_SAGE=$temp
where$temp
is a temporary directory in/tmp
or/var/tmp
, preferably created withmktemp
or similar process. There may be a couple of tests for which that would cause problem, but overall it would be much more robust.
Even better, why not HOME=$tempdir
?
comment:4 Changed 6 years ago by
That certainly would achieve it too. As far as I know $HOME
is only involved in the determination of DOT_SAGE
but there could be other stuff (dot directories not inside .sage by default for example), so that's extra safe.
comment:5 Changed 5 years ago by
Branch:  → u/vbraun/some_doctests_are_influenced_by_the_contents_of_init_sage 

comment:6 Changed 5 years ago by
Authors:  → Volker Braun 

Commit:  → 2d898ec595530ccb4a7566516ac41c4fd0400032 
Status:  new → needs_review 
New commits:
2d898ec  Do not load init.sage in doctests

comment:7 Changed 5 years ago by
Milestone:  sage7.2 → sage8.0 

Reviewers:  → François Bissey 
Status:  needs_review → positive_review 
Not the solution I was thinking of but that will solve the problem at hand.
comment:8 Changed 5 years ago by
Branch:  u/vbraun/some_doctests_are_influenced_by_the_contents_of_init_sage → 2d898ec595530ccb4a7566516ac41c4fd0400032 

Resolution:  → fixed 
Status:  positive_review → closed 
Failing doctests of 7.6.beta2 because sage.init is loaded and contains
%colors Linux
: