/
opt
/
imh-python
/
lib
/
python3.9
/
site-packages
/
IPython
/
core
/
tests
/
/opt/imh-python/lib/python3.9/site-packages/IPython/core/tests
mkdir
upload
Name
Size
Mode
Actions
daft_extension/
-
0755
rm
__pycache__/
-
0755
rm
2x2.jpg
331
0644
edit
dl
rm
2x2.png
71
0644
edit
dl
rm
bad_all.py
206
0644
edit
dl
rm
nonascii.py
135
0644
edit
dl
rm
nonascii2.py
155
0644
edit
dl
rm
print_argv.py
32
0644
edit
dl
rm
refbug.py
1494
0644
edit
dl
rm
simpleerr.py
583
0644
edit
dl
rm
tclass.py
921
0644
edit
dl
rm
test_alias.py
2007
0644
edit
dl
rm
test_application.py
2245
0644
edit
dl
rm
test_async_helpers.py
8647
0644
edit
dl
rm
test_autocall.py
1425
0644
edit
dl
rm
test_compilerop.py
2174
0644
edit
dl
rm
test_completer.py
60803
0644
edit
dl
rm
test_completerlib.py
6507
0644
edit
dl
rm
test_debugger.py
14501
0644
edit
dl
rm
test_display.py
15946
0644
edit
dl
rm
test_displayhook.py
3593
0644
edit
dl
rm
test_events.py
2287
0644
edit
dl
rm
test_exceptiongroup_tb.py
3599
0644
edit
dl
rm
test_extension.py
3026
0644
edit
dl
rm
test_formatters.py
14249
0644
edit
dl
rm
test_guarded_eval.py
15655
0644
edit
dl
rm
test_handlers.py
3286
0644
edit
dl
rm
test_history.py
11698
0644
edit
dl
rm
test_hooks.py
2316
0644
edit
dl
rm
test_imports.py
1153
0644
edit
dl
rm
test_inputsplitter.py
23213
0644
edit
dl
rm
test_inputtransformer.py
15755
0644
edit
dl
rm
test_inputtransformer2.py
11408
0644
edit
dl
rm
test_inputtransformer2_line.py
2971
0644
edit
dl
rm
test_interactiveshell.py
39660
0644
edit
dl
rm
test_iplib.py
6677
0644
edit
dl
rm
test_logger.py
776
0644
edit
dl
rm
test_magic.py
44359
0644
edit
dl
rm
test_magic_arguments.py
4778
0644
edit
dl
rm
test_magic_terminal.py
5996
0644
edit
dl
rm
test_oinspect.py
15674
0644
edit
dl
rm
test_page.py
772
0644
edit
dl
rm
test_paths.py
7081
0644
edit
dl
rm
test_prefilter.py
4214
0644
edit
dl
rm
test_profile.py
5064
0644
edit
dl
rm
test_prompts.py
845
0644
edit
dl
rm
test_pylabtools.py
7880
0644
edit
dl
rm
test_run.py
19369
0644
edit
dl
rm
test_shellapp.py
1892
0644
edit
dl
rm
test_splitinput.py
1227
0644
edit
dl
rm
test_ultratb.py
12026
0644
edit
dl
rm
__init__.py
0
0644
edit
dl
rm
Edit:
/opt/imh-python/lib/python3.9/site-packages/IPython/core/tests/test_profile.py
(5064B)
# coding: utf-8 """Tests for profile-related functions. Currently only the startup-dir functionality is tested, but more tests should be added for: * ipython profile create * ipython profile list * ipython profile create --parallel * security dir permissions Authors ------- * MinRK """ #----------------------------------------------------------------------------- # Imports #----------------------------------------------------------------------------- import shutil import sys import tempfile from pathlib import Path from unittest import TestCase from tempfile import TemporaryDirectory from IPython.core.profileapp import list_bundled_profiles, list_profiles_in from IPython.core.profiledir import ProfileDir from IPython.testing import decorators as dec from IPython.testing import tools as tt from IPython.utils.process import getoutput #----------------------------------------------------------------------------- # Globals #----------------------------------------------------------------------------- TMP_TEST_DIR = Path(tempfile.mkdtemp()) HOME_TEST_DIR = TMP_TEST_DIR / "home_test_dir" IP_TEST_DIR = HOME_TEST_DIR / ".ipython" # # Setup/teardown functions/decorators # def setup_module(): """Setup test environment for the module: - Adds dummy home dir tree """ # Do not mask exceptions here. In particular, catching WindowsError is a # problem because that exception is only defined on Windows... (Path.cwd() / IP_TEST_DIR).mkdir(parents=True) def teardown_module(): """Teardown test environment for the module: - Remove dummy home dir tree """ # Note: we remove the parent test dir, which is the root of all test # subdirs we may have created. Use shutil instead of os.removedirs, so # that non-empty directories are all recursively removed. shutil.rmtree(TMP_TEST_DIR) #----------------------------------------------------------------------------- # Test functions #----------------------------------------------------------------------------- class ProfileStartupTest(TestCase): def setUp(self): # create profile dir self.pd = ProfileDir.create_profile_dir_by_name(IP_TEST_DIR, "test") self.options = ["--ipython-dir", IP_TEST_DIR, "--profile", "test"] self.fname = TMP_TEST_DIR / "test.py" def tearDown(self): # We must remove this profile right away so its presence doesn't # confuse other tests. shutil.rmtree(self.pd.location) def init(self, startup_file, startup, test): # write startup python file with open(Path(self.pd.startup_dir) / startup_file, "w", encoding="utf-8") as f: f.write(startup) # write simple test file, to check that the startup file was run with open(self.fname, "w", encoding="utf-8") as f: f.write(test) def validate(self, output): tt.ipexec_validate(self.fname, output, "", options=self.options) def test_startup_py(self): self.init('00-start.py', 'zzz=123\n', 'print(zzz)\n') self.validate('123') def test_startup_ipy(self): self.init('00-start.ipy', '%xmode plain\n', '') self.validate('Exception reporting mode: Plain') def test_list_profiles_in(): # No need to remove these directories and files, as they will get nuked in # the module-level teardown. td = Path(tempfile.mkdtemp(dir=TMP_TEST_DIR)) for name in ("profile_foo", "profile_hello", "not_a_profile"): Path(td / name).mkdir(parents=True) if dec.unicode_paths: Path(td / "profile_ünicode").mkdir(parents=True) with open(td / "profile_file", "w", encoding="utf-8") as f: f.write("I am not a profile directory") profiles = list_profiles_in(td) # unicode normalization can turn u'ünicode' into u'u\0308nicode', # so only check for *nicode, and that creating a ProfileDir from the # name remains valid found_unicode = False for p in list(profiles): if p.endswith('nicode'): pd = ProfileDir.find_profile_dir_by_name(td, p) profiles.remove(p) found_unicode = True break if dec.unicode_paths: assert found_unicode is True assert set(profiles) == {"foo", "hello"} def test_list_bundled_profiles(): # This variable will need to be updated when a new profile gets bundled bundled = sorted(list_bundled_profiles()) assert bundled == [] def test_profile_create_ipython_dir(): """ipython profile create respects --ipython-dir""" with TemporaryDirectory() as td: getoutput( [ sys.executable, "-m", "IPython", "profile", "create", "foo", "--ipython-dir=%s" % td, ] ) profile_dir = Path(td) / "profile_foo" assert Path(profile_dir).exists() ipython_config = profile_dir / "ipython_config.py" assert Path(ipython_config).exists()
Save
cmd:
run