summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_site.py
diff options
context:
space:
mode:
authorZackery Spytz <zspytz@gmail.com>2024-01-07 06:30:12 (GMT)
committerGitHub <noreply@github.com>2024-01-07 06:30:12 (GMT)
commitf19b93fce04fb0bc9b59071915a6aa6b01860d8a (patch)
tree60b5f104bc68bc35f79d681aacf94f70a6dcc6e7 /Lib/test/test_site.py
parent541c5dbb81c784afd587406be2cc82645979a107 (diff)
downloadcpython-f19b93fce04fb0bc9b59071915a6aa6b01860d8a.zip
cpython-f19b93fce04fb0bc9b59071915a6aa6b01860d8a.tar.gz
cpython-f19b93fce04fb0bc9b59071915a6aa6b01860d8a.tar.bz2
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>
Diffstat (limited to 'Lib/test/test_site.py')
-rw-r--r--Lib/test/test_site.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py
index 9f199d9..e26b48e 100644
--- a/Lib/test/test_site.py
+++ b/Lib/test/test_site.py
@@ -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, ""):