mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
gh-73965: New environment variable PYTHON_HISTORY (#13208)
It can be used to set the location of a .python_history file --------- Co-authored-by: Levi Sabah <0xl3vi@gmail.com> Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
This commit is contained in:
parent
541c5dbb81
commit
f19b93fce0
7 changed files with 50 additions and 3 deletions
|
|
@ -7,6 +7,7 @@ executing have not been removed.
|
|||
import unittest
|
||||
import test.support
|
||||
from test import support
|
||||
from test.support.script_helper import assert_python_ok
|
||||
from test.support import os_helper
|
||||
from test.support import socket_helper
|
||||
from test.support import captured_stderr
|
||||
|
|
@ -338,6 +339,19 @@ class HelperFunctionsTests(unittest.TestCase):
|
|||
mock_addsitedir.assert_not_called()
|
||||
self.assertFalse(known_paths)
|
||||
|
||||
def test_gethistoryfile(self):
|
||||
filename = 'file'
|
||||
rc, out, err = assert_python_ok('-c',
|
||||
f'import site; assert site.gethistoryfile() == "{filename}"',
|
||||
PYTHON_HISTORY=filename)
|
||||
self.assertEqual(rc, 0)
|
||||
|
||||
# Check that PYTHON_HISTORY is ignored in isolated mode.
|
||||
rc, out, err = assert_python_ok('-I', '-c',
|
||||
f'import site; assert site.gethistoryfile() != "{filename}"',
|
||||
PYTHON_HISTORY=filename)
|
||||
self.assertEqual(rc, 0)
|
||||
|
||||
def test_trace(self):
|
||||
message = "bla-bla-bla"
|
||||
for verbose, out in (True, message + "\n"), (False, ""):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue