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: sage-8.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:

Status badges

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 Daniel Krenn

Priority: majorcritical
Type: PLEASE CHANGEdefect

Failing doctests of 7.6.beta2 because sage.init is loaded and contains %colors Linux:

sage -t --long src/sage/interfaces/expect.py  # 1 doctest failed
sage -t --long src/sage/repl/interpreter.py  # 3 doctests failed
sage -t --long src/sage/repl/interface_magic.py  # 3 doctests failed
sage -t --long src/sage/repl/ipython_tests.py  # 4 doctests failed

comment:2 Changed 6 years ago by François Bissey

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 in reply to:  2 Changed 6 years ago by Jeroen Demeyer

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 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.

Even better, why not HOME=$tempdir?

comment:4 Changed 6 years ago by François Bissey

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 Volker Braun

Branch: u/vbraun/some_doctests_are_influenced_by_the_contents_of_init_sage

comment:6 Changed 5 years ago by Volker Braun

Authors: Volker Braun
Commit: 2d898ec595530ccb4a7566516ac41c4fd0400032
Status: newneeds_review

New commits:

2d898ecDo not load init.sage in doctests

comment:7 Changed 5 years ago by François Bissey

Milestone: sage-7.2sage-8.0
Reviewers: François Bissey
Status: needs_reviewpositive_review

Not the solution I was thinking of but that will solve the problem at hand.

comment:8 Changed 5 years ago by Volker Braun

Branch: u/vbraun/some_doctests_are_influenced_by_the_contents_of_init_sage2d898ec595530ccb4a7566516ac41c4fd0400032
Resolution: fixed
Status: positive_reviewclosed
Note: See TracTickets for help on using tickets.