MCPcopy Create free account
hub / github.com/ipython/ipython / doctest_run_builtins

Function doctest_run_builtins

IPython/core/tests/test_run.py:58–94  ·  view source on GitHub ↗

r"""Check that %run doesn't damage __builtins__. In [1]: import tempfile In [2]: bid1 = id(__builtins__) In [3]: fname = tempfile.mkstemp('.py')[1] In [3]: f = open(fname,'w') In [4]: dummy= f.write('pass\n') In [5]: f.flush() In [6]: t1 = type(__builtins__) I

()

Source from the content-addressed store, hash-verified

56
57
58def doctest_run_builtins():
59 r"""Check that %run doesn't damage __builtins__.
60
61 In [1]: import tempfile
62
63 In [2]: bid1 = id(__builtins__)
64
65 In [3]: fname = tempfile.mkstemp('.py')[1]
66
67 In [3]: f = open(fname,'w')
68
69 In [4]: dummy= f.write('pass\n')
70
71 In [5]: f.flush()
72
73 In [6]: t1 = type(__builtins__)
74
75 In [7]: %run $fname
76
77 In [7]: f.close()
78
79 In [8]: bid2 = id(__builtins__)
80
81 In [9]: t2 = type(__builtins__)
82
83 In [10]: t1 == t2
84 Out[10]: True
85
86 In [10]: bid1 == bid2
87 Out[10]: True
88
89 In [12]: try:
90 ....: os.unlink(fname)
91 ....: except:
92 ....: pass
93 ....:
94 """
95
96
97def doctest_run_option_parser():

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected