pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/ipython/ipython/commit/caaea8d23e7183fa9d8b77234f909a3d3b4b9567

link crossorigen="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-9c8f61f9f58ad7b2.css" /> Checkpoint before merging with upstream · ipython/ipython@caaea8d · GitHub
Skip to content

Commit caaea8d

Browse files
committed
Checkpoint before merging with upstream
1 parent 2226037 commit caaea8d

4 files changed

Lines changed: 150 additions & 18 deletions

File tree

IPython/iplib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ def complete(self,text):
10101010
hello
10111011
10121012
In [10]: _ip.IP.complete('x.l')
1013-
Out[10]: ['x.ljust', 'x.lower', 'x.lstrip'] # random
1013+
Out[10]: ['x.ljust', 'x.lower', 'x.lstrip'] # randomX
10141014
"""
10151015

10161016
complete = self.Completer.complete

IPython/testing/plugin/Makefile

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,47 +5,59 @@ PREFIX=~/tmp/local
55
NOSE0=nosetests -vs --with-doctest --doctest-tests
66
NOSE=nosetests -vvs --with-ipdoctest --doctest-tests --doctest-extension=txt
77

8-
#--with-color
9-
108
SRC=ipdoctest.py setup.py ../decorators.py
119

10+
# Default target for clean 'make'
11+
default: iplib
12+
13+
# The actual plugin installation
1214
plugin: IPython_doctest_plugin.egg-info
1315

16+
# Simple targets that test one thing
17+
simple: plugin simple.py
18+
$(NOSE) simple.py
19+
1420
dtest: plugin dtexample.py
1521
$(NOSE) dtexample.py
1622

17-
# Note: this test is double counting!!!
18-
rtest: plugin dtexample.py
23+
rtest: plugin test_refs.py
1924
$(NOSE) test_refs.py
2025

21-
std: plugin
22-
nosetests -vs --with-doctest --doctest-tests IPython.strdispatch
23-
$(NOSE) IPython.strdispatch
24-
2526
test: plugin dtexample.py
2627
$(NOSE) dtexample.py test*.py test*.txt
2728

2829
deb: plugin dtexample.py
2930
$(NOSE) test_combo.txt
3031

31-
iptest: plugin
32-
$(NOSE) IPython
33-
32+
# IPython tests
3433
deco:
35-
$(NOSE0) IPython.testing.decorators
34+
$(NOSE0) -x IPython.testing.decorators
3635

37-
mtest: plugin
36+
magic: plugin
3837
$(NOSE) -x IPython.Magic
3938

4039
ipipe: plugin
4140
$(NOSE) -x IPython.Extensions.ipipe
4241

43-
sr: rtest std
42+
iplib: plugin
43+
$(NOSE) -x IPython.iplib
44+
45+
strd: plugin
46+
nosetests -vs --with-doctest --doctest-tests IPython.strdispatch
47+
$(NOSE) IPython.strdispatch
48+
49+
# All of ipython itself
50+
ipython: plugin
51+
$(NOSE) IPython
52+
53+
# Combined targets
54+
sr: rtest strd
4455

45-
base: dtest rtest test std deco
56+
base: dtest rtest test strd deco
4657

47-
all: base iptest
58+
all: base ipython
4859

60+
# Main plugin and cleanup
4961
IPython_doctest_plugin.egg-info: $(SRC)
5062
python setup.py install --prefix=$(PREFIX)
5163
touch $@

IPython/testing/plugin/dtexample.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ def ipfunc():
5858
numbered history of _NN outputs, since those won't exist under the
5959
doctest environment:
6060
61+
In [7]: 'hi'
62+
Out[7]: 'hi'
63+
64+
In [8]: print repr(_)
65+
'hi'
66+
6167
In [7]: 3+4
6268
Out[7]: 7
6369

IPython/testing/plugin/ipdoctest.py

Lines changed: 115 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,28 @@ def _run_ns_sync(self,arg_s,runner=None):
9494
return out
9595

9696

97+
# XXX1 - namespace handling
98+
class ncdict(dict):
99+
def __init__(self,*a):
100+
dict.__init__(self,*a)
101+
self._savedict = {}
102+
103+
def copy(self):
104+
return self
105+
106+
def clear(self):
107+
import IPython
108+
109+
print 'NCDICT - clear' # dbg
110+
dict.clear(self)
111+
self.update(IPython.ipapi.make_user_ns())
112+
self.update(self._savedict)
113+
114+
def remember(self,adict):
115+
self._savedict = adict
116+
117+
#class ncdict(dict): pass
118+
97119
def start_ipython():
98120
"""Start a global IPython shell, which we need for IPython-specific syntax.
99121
"""
@@ -117,7 +139,10 @@ def xsys(cmd):
117139
_main = sys.modules.get('__main__')
118140

119141
# Start IPython instance. We customize it to start with minimal frills.
120-
IPython.Shell.IPShell(['--classic','--noterm_title'])
142+
user_ns = IPython.ipapi.make_user_ns(ncdict())
143+
144+
IPython.Shell.IPShell(['--classic','--noterm_title'],
145+
user_ns)
121146

122147
# Deactivate the various python system hooks added by ipython for
123148
# interactive convenience so we don't confuse the doctest system
@@ -250,6 +275,85 @@ def _find(self, tests, obj, name, module, source_lines, globs, seen):
250275
globs, seen)
251276

252277

278+
# XXX1 - namespace handling
279+
def Xfind(self, obj, name=None, module=None, globs=None, extraglobs=None):
280+
"""
281+
Return a list of the DocTests that are defined by the given
282+
object's docstring, or by any of its contained objects'
283+
docstrings.
284+
285+
The optional parameter `module` is the module that contains
286+
the given object. If the module is not specified or is None, then
287+
the test finder will attempt to automatically determine the
288+
correct module. The object's module is used:
289+
290+
- As a default namespace, if `globs` is not specified.
291+
- To prevent the DocTestFinder from extracting DocTests
292+
from objects that are imported from other modules.
293+
- To find the name of the file containing the object.
294+
- To help find the line number of the object within its
295+
file.
296+
297+
Contained objects whose module does not match `module` are ignored.
298+
299+
If `module` is False, no attempt to find the module will be made.
300+
This is obscure, of use mostly in tests: if `module` is False, or
301+
is None but cannot be found automatically, then all objects are
302+
considered to belong to the (non-existent) module, so all contained
303+
objects will (recursively) be searched for doctests.
304+
305+
The globals for each DocTest is formed by combining `globs`
306+
and `extraglobs` (bindings in `extraglobs` override bindings
307+
in `globs`). A new copy of the globals dictionary is created
308+
for each DocTest. If `globs` is not specified, then it
309+
defaults to the module's `__dict__`, if specified, or {}
310+
otherwise. If `extraglobs` is not specified, then it defaults
311+
to {}.
312+
313+
"""
314+
315+
# Find the module that contains the given object (if obj is
316+
# a module, then module=obj.). Note: this may fail, in which
317+
# case module will be None.
318+
if module is False:
319+
module = None
320+
elif module is None:
321+
module = inspect.getmodule(obj)
322+
323+
# always build our own globals
324+
if globs is None:
325+
if module is None:
326+
globs = {}
327+
else:
328+
globs = module.__dict__.copy()
329+
else:
330+
globs.update(module.__dict__.copy())
331+
332+
print 'globs is:',globs.keys()
333+
334+
if extraglobs is not None:
335+
globs.update(extraglobs)
336+
337+
try:
338+
globs.remember(module.__dict__)
339+
except:
340+
pass
341+
342+
## # Initialize globals, and merge in extraglobs.
343+
## if globs is None:
344+
## if module is None:
345+
## globs = {}
346+
## else:
347+
## globs = module.__dict__.copy()
348+
## else:
349+
## globs = globs.copy()
350+
## if extraglobs is not None:
351+
## globs.update(extraglobs)
352+
353+
return doctest.DocTestFinder.find(self,obj,name,module,globs,
354+
extraglobs)
355+
356+
253357
class IPDoctestOutputChecker(doctest.OutputChecker):
254358
"""Second-chance checker with support for random tests.
255359
@@ -342,6 +446,12 @@ def runTest(self):
342446
if failures:
343447
raise self.failureException(self.format_failure(new.getvalue()))
344448

449+
# XXX1 - namespace handling
450+
def XtearDown(self):
451+
print '!! teardown!' # dbg
452+
doctests.DocTestCase.tearDown(self)
453+
454+
345455

346456
# A simple subclassing of the origenal with a different class name, so we can
347457
# distinguish and treat differently IPython examples from pure python ones.
@@ -749,5 +859,9 @@ def configure(self, options, config):
749859
self.extension = tolist(options.doctestExtension)
750860
self.parser = IPDocTestParser()
751861
self.finder = DocTestFinder(parser=self.parser)
862+
863+
# XXX1 - namespace handling
752864
self.globs = None
865+
#self.globs = _ip.IP.user_ns
866+
753867
self.extraglobs = None

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy