/opt/imh-python/lib/python3.9/site-packages/IPython/core/tests
NameSizeModeActions
daft_extension/-0755rm
__pycache__/-0755rm
2x2.jpg3310644editdlrm
2x2.png710644editdlrm
bad_all.py2060644editdlrm
nonascii.py1350644editdlrm
nonascii2.py1550644editdlrm
print_argv.py320644editdlrm
refbug.py14940644editdlrm
simpleerr.py5830644editdlrm
tclass.py9210644editdlrm
test_alias.py20070644editdlrm
test_application.py22450644editdlrm
test_async_helpers.py86470644editdlrm
test_autocall.py14250644editdlrm
test_compilerop.py21740644editdlrm
test_completer.py608030644editdlrm
test_completerlib.py65070644editdlrm
test_debugger.py145010644editdlrm
test_display.py159460644editdlrm
test_displayhook.py35930644editdlrm
test_events.py22870644editdlrm
test_exceptiongroup_tb.py35990644editdlrm
test_extension.py30260644editdlrm
test_formatters.py142490644editdlrm
test_guarded_eval.py156550644editdlrm
test_handlers.py32860644editdlrm
test_history.py116980644editdlrm
test_hooks.py23160644editdlrm
test_imports.py11530644editdlrm
test_inputsplitter.py232130644editdlrm
test_inputtransformer.py157550644editdlrm
test_inputtransformer2.py114080644editdlrm
test_inputtransformer2_line.py29710644editdlrm
test_interactiveshell.py396600644editdlrm
test_iplib.py66770644editdlrm
test_logger.py7760644editdlrm
test_magic.py443590644editdlrm
test_magic_arguments.py47780644editdlrm
test_magic_terminal.py59960644editdlrm
test_oinspect.py156740644editdlrm
test_page.py7720644editdlrm
test_paths.py70810644editdlrm
test_prefilter.py42140644editdlrm
test_profile.py50640644editdlrm
test_prompts.py8450644editdlrm
test_pylabtools.py78800644editdlrm
test_run.py193690644editdlrm
test_shellapp.py18920644editdlrm
test_splitinput.py12270644editdlrm
test_ultratb.py120260644editdlrm
__init__.py00644editdlrm
Edit: /opt/imh-python/lib/python3.9/site-packages/IPython/core/tests/test_iplib.py (6677B)
"""Tests for the key interactiveshell module, where the main ipython class is defined. """ import stack_data import sys SV_VERSION = tuple([int(x) for x in stack_data.__version__.split(".")[0:2]]) def test_reset(): """reset must clear most namespaces.""" # Check that reset runs without error ip.reset() # Once we've reset it (to clear of any junk that might have been there from # other tests, we can count how many variables are in the user's namespace nvars_user_ns = len(ip.user_ns) nvars_hidden = len(ip.user_ns_hidden) # Now add a few variables to user_ns, and check that reset clears them ip.user_ns['x'] = 1 ip.user_ns['y'] = 1 ip.reset() # Finally, check that all namespaces have only as many variables as we # expect to find in them: assert len(ip.user_ns) == nvars_user_ns assert len(ip.user_ns_hidden) == nvars_hidden # Tests for reporting of exceptions in various modes, handling of SystemExit, # and %tb functionality. This is really a mix of testing ultraTB and interactiveshell. def doctest_tb_plain(): """ In [18]: xmode plain Exception reporting mode: Plain In [19]: run simpleerr.py Traceback (most recent call last): File ...:... bar(mode) File ...:... in bar div0() File ...:... in div0 x/y ZeroDivisionError: ... """ def doctest_tb_context(): """ In [3]: xmode context Exception reporting mode: Context In [4]: run simpleerr.py --------------------------------------------------------------------------- ZeroDivisionError Traceback (most recent call last) ... 30 except IndexError: 31 mode = 'div' ---> 33 bar(mode) ... in bar(mode) 15 "bar" 16 if mode=='div': ---> 17 div0() 18 elif mode=='exit': 19 try: ... in div0() 6 x = 1 7 y = 0 ----> 8 x/y ZeroDivisionError: ...""" def doctest_tb_verbose(): """ In [5]: xmode verbose Exception reporting mode: Verbose In [6]: run simpleerr.py --------------------------------------------------------------------------- ZeroDivisionError Traceback (most recent call last) ... 30 except IndexError: 31 mode = 'div' ---> 33 bar(mode) mode = 'div' ... in bar(mode='div') 15 "bar" 16 if mode=='div': ---> 17 div0() 18 elif mode=='exit': 19 try: ... in div0() 6 x = 1 7 y = 0 ----> 8 x/y x = 1 y = 0 ZeroDivisionError: ... """ def doctest_tb_sysexit(): """ In [17]: %xmode plain Exception reporting mode: Plain In [18]: %run simpleerr.py exit An exception has occurred, use %tb to see the full traceback. SystemExit: (1, 'Mode = exit') In [19]: %run simpleerr.py exit 2 An exception has occurred, use %tb to see the full traceback. SystemExit: (2, 'Mode = exit') In [20]: %tb Traceback (most recent call last): File ...:... in execfile exec(compiler(f.read(), fname, "exec"), glob, loc) File ...:... bar(mode) File ...:... in bar sysexit(stat, mode) File ...:... in sysexit raise SystemExit(stat, f"Mode = {mode}") SystemExit: (2, 'Mode = exit') In [21]: %xmode context Exception reporting mode: Context In [22]: %tb --------------------------------------------------------------------------- SystemExit Traceback (most recent call last) File ..., in execfile(fname, glob, loc, compiler) ... with open(fname, "rb") as f: ... compiler = compiler or compile ---> ... exec(compiler(f.read(), fname, "exec"), glob, loc) ... 30 except IndexError: 31 mode = 'div' ---> 33 bar(mode) ...bar(mode) 21 except: 22 stat = 1 ---> 23 sysexit(stat, mode) 24 else: 25 raise ValueError('Unknown mode') ...sysexit(stat, mode) 10 def sysexit(stat, mode): ---> 11 raise SystemExit(stat, f"Mode = {mode}") SystemExit: (2, 'Mode = exit') """ if SV_VERSION < (0, 6): def doctest_tb_sysexit_verbose_stack_data_05(): """ In [18]: %run simpleerr.py exit An exception has occurred, use %tb to see the full traceback. SystemExit: (1, 'Mode = exit') In [19]: %run simpleerr.py exit 2 An exception has occurred, use %tb to see the full traceback. SystemExit: (2, 'Mode = exit') In [23]: %xmode verbose Exception reporting mode: Verbose In [24]: %tb --------------------------------------------------------------------------- SystemExit Traceback (most recent call last) ... 30 except IndexError: 31 mode = 'div' ---> 33 bar(mode) mode = 'exit' ... in bar(mode='exit') ... except: ... stat = 1 ---> ... sysexit(stat, mode) mode = 'exit' stat = 2 ... else: ... raise ValueError('Unknown mode') ... in sysexit(stat=2, mode='exit') 10 def sysexit(stat, mode): ---> 11 raise SystemExit(stat, f"Mode = {mode}") stat = 2 SystemExit: (2, 'Mode = exit') """ def test_run_cell(): import textwrap ip.run_cell("a = 10\na+=1") ip.run_cell("assert a == 11\nassert 1") assert ip.user_ns["a"] == 11 complex = textwrap.dedent( """ if 1: print "hello" if 1: print "world" if 2: print "foo" if 3: print "bar" if 4: print "bar" """ ) # Simply verifies that this kind of input is run ip.run_cell(complex) def test_db(): """Test the internal database used for variable persistence.""" ip.db["__unittest_"] = 12 assert ip.db["__unittest_"] == 12 del ip.db["__unittest_"] assert "__unittest_" not in ip.db