Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Trac #33213: replace SAGE_TMP in session doctests.
Browse files Browse the repository at this point in the history
  • Loading branch information
orlitzky committed Feb 15, 2022
1 parent 24499f1 commit 3c8c0e6
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/sage/misc/session.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,45 @@ verify that it is listed as a newly defined variable::
sage: show_identifiers()
['w']
We next save this session. We are using a file in ``SAGE_TMP``. We do this
*for testing* only --- please do not do this, when you want to save your
session permanently, since ``SAGE_TMP`` will be removed when leaving Sage!
We next save this session. We are using a temporary directory to hold
the session file but we do this *for testing only.* Please do not do
this if you want to save your session permanently. Also note that
the ``tempfile`` module weasels its way into the session::
::
sage: save_session(os.path.join(SAGE_TMP, 'session'))
sage: from tempfile import TemporaryDirectory
sage: d = TemporaryDirectory()
sage: save_session(os.path.join(d.name, 'session'))
This saves a dictionary with ``w`` as one of the keys::
sage: z = load(os.path.join(SAGE_TMP, 'session'))
sage: z = load(os.path.join(d.name, 'session'))
sage: list(z)
['w']
['d', 'w']
sage: z['w']
2/3
Next we reset the session, verify this, and load the session back.::
Next we reset all variables in the session except for the temporary
directory name. We verify that the session is reset, and then load
it back.::
sage: sage.misc.reset.EXCLUDE.add('d')
sage: reset()
sage: show_identifiers()
[]
sage: load_session(os.path.join(SAGE_TMP, 'session'))
['d']
sage: load_session(os.path.join(d.name, 'session'))
Indeed ``w`` is now defined again.::
sage: show_identifiers()
['w']
['d', 'w']
sage: w
2/3
It is not needed to clean up the file created in the above code, since it
resides in the directory ``SAGE_TMP``.
AUTHOR:
- William Stein
"""

#############################################################################
Expand Down

0 comments on commit 3c8c0e6

Please sign in to comment.