##// END OF EJS Templates
Fixes to testing....
Fernando Perez -
Show More
@@ -61,9 +61,11 b' class Style(object):'
61 61 ``bg`` as the background color and ``attrs`` as the attributes.
62 62
63 63 Examples:
64
65 64 >>> Style(COLOR_RED, COLOR_BLACK)
65 <Style fg=red bg=black attrs=0>
66
66 67 >>> Style(COLOR_YELLOW, COLOR_BLUE, A_BOLD|A_UNDERLINE)
68 <Style fg=yellow bg=blue attrs=bold|underline>
67 69 """
68 70 self.fg = fg
69 71 self.bg = bg
@@ -8,7 +8,7 b' objects imported this way starts with ``i`` to minimize collisions.'
8 8 ``ipipe`` supports "pipeline expressions", which is something resembling Unix
9 9 pipes. An example is::
10 10
11 >>> ienv | isort("key.lower()")
11 py> ienv | isort("key.lower()")
12 12
13 13 This gives a listing of all environment variables sorted by name.
14 14
@@ -49,31 +49,31 b' three extensions points (all of them optional):'
49 49 makes it possible to use dictionaries and modules in pipeline expressions,
50 50 for example::
51 51
52 >>> import sys
53 >>> sys | ifilter("isinstance(value, int)") | idump
52 py> import sys
53 py> sys | ifilter("isinstance(value, int)") | idump
54 54 key |value
55 55 api_version| 1012
56 56 dllhandle | 503316480
57 57 hexversion | 33817328
58 58 maxint |2147483647
59 59 maxunicode | 65535
60 >>> sys.modules | ifilter("_.value is not None") | isort("_.key.lower()")
60 py> sys.modules | ifilter("_.value is not None") | isort("_.key.lower()")
61 61 ...
62 62
63 63 Note: The expression strings passed to ``ifilter()`` and ``isort()`` can
64 64 refer to the object to be filtered or sorted via the variable ``_`` and to any
65 65 of the attributes of the object, i.e.::
66 66
67 >>> sys.modules | ifilter("_.value is not None") | isort("_.key.lower()")
67 py> sys.modules | ifilter("_.value is not None") | isort("_.key.lower()")
68 68
69 69 does the same as::
70 70
71 >>> sys.modules | ifilter("value is not None") | isort("key.lower()")
71 py> sys.modules | ifilter("value is not None") | isort("key.lower()")
72 72
73 73 In addition to expression strings, it's possible to pass callables (taking
74 74 the object as an argument) to ``ifilter()``, ``isort()`` and ``ieval()``::
75 75
76 >>> sys | ifilter(lambda _:isinstance(_.value, int)) \
76 py> sys | ifilter(lambda _:isinstance(_.value, int)) \
77 77 ... | ieval(lambda _: (_.key, hex(_.value))) | idump
78 78 0 |1
79 79 api_version|0x3f4
@@ -123,8 +123,7 b' except ImportError:'
123 123 grp = None
124 124
125 125 from IPython.external import simplegeneric
126
127 import path
126 from IPython.external import path
128 127
129 128 try:
130 129 from IPython import genutils, generics
@@ -1209,9 +1208,9 b' class ils(Table):'
1209 1208
1210 1209 Examples::
1211 1210
1212 >>> ils
1213 >>> ils("/usr/local/lib/python2.4")
1214 >>> ils("~")
1211 py> ils
1212 py> ils("/usr/local/lib/python2.4")
1213 py> ils("~")
1215 1214 """
1216 1215 def __init__(self, base=os.curdir, dirs=True, files=True):
1217 1216 self.base = os.path.expanduser(base)
@@ -1247,7 +1246,7 b' class iglob(Table):'
1247 1246
1248 1247 Examples::
1249 1248
1250 >>> iglob("*.py")
1249 py> iglob("*.py")
1251 1250 """
1252 1251 def __init__(self, glob):
1253 1252 self.glob = glob
@@ -1272,9 +1271,9 b' class iwalk(Table):'
1272 1271 """
1273 1272 List all files and directories in a directory and it's subdirectory::
1274 1273
1275 >>> iwalk
1276 >>> iwalk("/usr/local/lib/python2.4")
1277 >>> iwalk("~")
1274 py> iwalk
1275 py> iwalk("/usr/local/lib/python2.4")
1276 py> iwalk("~")
1278 1277 """
1279 1278 def __init__(self, base=os.curdir, dirs=True, files=True):
1280 1279 self.base = os.path.expanduser(base)
@@ -1377,7 +1376,7 b' class ipwd(Table):'
1377 1376
1378 1377 Example::
1379 1378
1380 >>> ipwd | isort("uid")
1379 py> ipwd | isort("uid")
1381 1380 """
1382 1381 def __iter__(self):
1383 1382 for entry in pwd.getpwall():
@@ -1561,7 +1560,7 b' class ienv(Table):'
1561 1560
1562 1561 Example::
1563 1562
1564 >>> ienv
1563 py> ienv
1565 1564 """
1566 1565
1567 1566 def __iter__(self):
@@ -1582,8 +1581,8 b' class ihist(Table):'
1582 1581
1583 1582 Example::
1584 1583
1585 >>> ihist
1586 >>> ihist(True) (raw mode)
1584 py> ihist
1585 py> ihist(True) (raw mode)
1587 1586 """
1588 1587 def __init__(self, raw=True):
1589 1588 self.raw = raw
@@ -1617,7 +1616,7 b' class ialias(Table):'
1617 1616
1618 1617 Example::
1619 1618
1620 >>> ialias
1619 py> ialias
1621 1620 """
1622 1621 def __iter__(self):
1623 1622 api = ipapi.get()
@@ -1679,8 +1678,8 b' class ix(Table):'
1679 1678
1680 1679 Examples::
1681 1680
1682 >>> ix("ps x")
1683 >>> ix("find .") | ifile
1681 py> ix("ps x")
1682 py> ix("find .") | ifile
1684 1683 """
1685 1684 def __init__(self, cmd):
1686 1685 self.cmd = cmd
@@ -1718,9 +1717,9 b' class ifilter(Pipe):'
1718 1717
1719 1718 Examples::
1720 1719
1721 >>> ils | ifilter("_.isfile() and size>1000")
1722 >>> igrp | ifilter("len(mem)")
1723 >>> sys.modules | ifilter(lambda _:_.value is not None)
1720 py> ils | ifilter("_.isfile() and size>1000")
1721 py> igrp | ifilter("len(mem)")
1722 py> sys.modules | ifilter(lambda _:_.value is not None)
1724 1723 """
1725 1724
1726 1725 def __init__(self, expr, globals=None, errors="raiseifallfail"):
@@ -1810,8 +1809,8 b' class ieval(Pipe):'
1810 1809
1811 1810 Examples::
1812 1811
1813 >>> ils | ieval("_.abspath()")
1814 >>> sys.path | ieval(ifile)
1812 py> ils | ieval("_.abspath()")
1813 py> sys.path | ieval(ifile)
1815 1814 """
1816 1815
1817 1816 def __init__(self, expr, globals=None, errors="raiseifallfail"):
@@ -1882,7 +1881,7 b' class ienum(Pipe):'
1882 1881
1883 1882 Examples::
1884 1883
1885 >>> xrange(20) | ieval("_,_*_") | ienum | ifilter("index % 2 == 0") | ieval("object")
1884 py> xrange(20) | ieval("_,_*_") | ienum | ifilter("index % 2 == 0") | ieval("object")
1886 1885 """
1887 1886 def __iter__(self):
1888 1887 fields = ("index", "object")
@@ -1896,8 +1895,8 b' class isort(Pipe):'
1896 1895
1897 1896 Examples::
1898 1897
1899 >>> ils | isort("size")
1900 >>> ils | isort("_.isdir(), _.lower()", reverse=True)
1898 py> ils | isort("size")
1899 py> ils | isort("_.isdir(), _.lower()", reverse=True)
1901 1900 """
1902 1901
1903 1902 def __init__(self, key=None, globals=None, reverse=False):
@@ -2054,8 +2053,8 b' class icap(Table):'
2054 2053
2055 2054 Examples::
2056 2055
2057 >>> import time
2058 >>> icap("for i in range(10): print i, time.sleep(0.1)")
2056 py> import time
2057 py> icap("for i in range(10): print i, time.sleep(0.1)")
2059 2058
2060 2059 """
2061 2060 def __init__(self, expr, globals=None):
@@ -4,6 +4,7 b' A module to change reload() so that it acts recursively.'
4 4 To enable it type:
5 5 >>> import __builtin__, deep_reload
6 6 >>> __builtin__.reload = deep_reload.reload
7
7 8 You can then disable it with:
8 9 >>> __builtin__.reload = deep_reload.original_reload
9 10
@@ -477,11 +477,6 b' class SystemExec:'
477 477
478 478 An instance can then be created as:
479 479 >>> sysexec = SystemExec(verbose=1,debug=0,header='Calling: ')
480
481 And used as:
482 >>> sysexec.xsys('echo "Hello Python"')
483 Calling: echo "Hello Python"
484 Hello Python
485 480 """
486 481
487 482 def __init__(self,verbose=0,debug=0,header='',split=0):
@@ -685,7 +680,7 b' def optstr2types(ostr):'
685 680
686 681 #----------------------------------------------------------------------------
687 682 def read_dict(filename,type_conv=None,**opt):
688 """Read a dictionary of key=value pairs from an input file, optionally
683 r"""Read a dictionary of key=value pairs from an input file, optionally
689 684 performing conversions on the resulting values.
690 685
691 686 read_dict(filename,type_conv,**opt) -> dict
@@ -731,20 +726,33 b' def read_dict(filename,type_conv=None,**opt):'
731 726 to make a list of all appearances.
732 727
733 728 Example:
734 If the input file test.ini has:
735 i 3
736 x 4.5
737 y 5.5
738 s hi ho
739 Then:
740 729
730 If the input file test.ini contains (we put it in a string to keep the test
731 self-contained):
732
733 >>> test_ini = '''\
734 ... i 3
735 ... x 4.5
736 ... y 5.5
737 ... s hi ho'''
738
739 Then we can use it as follows:
741 740 >>> type_conv={int:'i',float:'x',None:'s'}
742 >>> read_dict('test.ini')
743 {'i': '3', 's': 'hi ho', 'x': '4.5', 'y': '5.5'}
744 >>> read_dict('test.ini',type_conv)
745 {'i': 3, 's': 'hi ho', 'x': 4.5, 'y': '5.5'}
746 >>> read_dict('test.ini',type_conv,purge=1)
747 {'i': 3, 's': 'hi ho', 'x': 4.5}
741
742 >>> d = read_dict(test_ini)
743
744 >>> sorted(d.items())
745 [('i', '3'), ('s', 'hi ho'), ('x', '4.5'), ('y', '5.5')]
746
747 >>> d = read_dict(test_ini,type_conv)
748
749 >>> sorted(d.items())
750 [('i', 3), ('s', 'hi ho'), ('x', 4.5), ('y', '5.5')]
751
752 >>> d = read_dict(test_ini,type_conv,purge=True)
753
754 >>> sorted(d.items())
755 [('i', 3), ('s', 'hi ho'), ('x', 4.5)]
748 756 """
749 757
750 758 # starting config
@@ -762,9 +770,15 b' def read_dict(filename,type_conv=None,**opt):'
762 770 raise ValueError, 'Unique keys must be given as a string, List or Tuple'
763 771
764 772 dict = {}
773
765 774 # first read in table of values as strings
775 if '\n' in filename:
776 lines = filename.splitlines()
777 file = None
778 else:
766 779 file = open(filename,'r')
767 for line in file.readlines():
780 lines = file.readlines()
781 for line in lines:
768 782 line = line.strip()
769 783 if len(line) and line[0]=='#': continue
770 784 if len(line)>0:
@@ -1007,10 +1007,17 b' class InteractiveShell(object,Magic):'
1007 1007
1008 1008 Simple usage example:
1009 1009
1010 In [1]: x = 'hello'
1010 In [7]: x = 'hello'
1011 1011
1012 In [2]: __IP.complete('x.l')
1013 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
1012 In [8]: x
1013 Out[8]: 'hello'
1014
1015 In [9]: print x
1016 hello
1017
1018 In [10]: _ip.IP.complete('x.l')
1019 Out[10]: ['x.ljust', 'x.lower', 'x.lstrip']
1020 """
1014 1021
1015 1022 complete = self.Completer.complete
1016 1023 state = 0
@@ -1026,6 +1033,8 b' class InteractiveShell(object,Magic):'
1026 1033 state += 1
1027 1034 outcomps = comps.keys()
1028 1035 outcomps.sort()
1036 print "T:",text,"OC:",outcomps # dbg
1037 #print "vars:",self.user_ns.keys()
1029 1038 return outcomps
1030 1039
1031 1040 def set_completer_frame(self, frame=None):
@@ -1636,6 +1645,7 b' want to merge them back into the new files.""" % locals()'
1636 1645 # previous call (which most likely existed in a separate scope).
1637 1646 local_varnames = local_ns.keys()
1638 1647 self.user_ns.update(local_ns)
1648 #self.user_ns['local_ns'] = local_ns # dbg
1639 1649
1640 1650 # Patch for global embedding to make sure that things don't overwrite
1641 1651 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
@@ -2361,7 +2371,6 b' want to merge them back into the new files.""" % locals()'
2361 2371 def handle_auto(self, line_info):
2362 2372 """Hande lines which can be auto-executed, quoting if requested."""
2363 2373
2364 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2365 2374 line = line_info.line
2366 2375 iFun = line_info.iFun
2367 2376 theRest = line_info.theRest
@@ -2369,8 +2378,11 b' want to merge them back into the new files.""" % locals()'
2369 2378 continue_prompt = line_info.continue_prompt
2370 2379 obj = line_info.ofind(self)['obj']
2371 2380
2381 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2382
2372 2383 # This should only be active for single-line input!
2373 2384 if continue_prompt:
2385 print 'getting out!' # dbg
2374 2386 self.log(line,line,continue_prompt)
2375 2387 return line
2376 2388
@@ -89,7 +89,7 b' class Struct:'
89 89 accessed using the dictionary syntax. Again, an example:
90 90
91 91 This doesn't work:
92 >> s=Struct(4='hi') #doctest: +IGNORE_EXCEPTION_DETAIL
92 py> s=Struct(4='hi') #doctest: +IGNORE_EXCEPTION_DETAIL
93 93 Traceback (most recent call last):
94 94 ...
95 95 SyntaxError: keyword can't be an expression
@@ -172,7 +172,13 b" if __name__ == '__main__':"
172 172 # A comment
173 173 remote() # this means the code below only runs remotely
174 174 print 'Hello remote world'
175 x = 3.14
175 x = range(10)
176 176 # Comments are OK
177 177 # Even misindented.
178 178 y = x+1
179
180
181 with pfor('i',sequence) as pr:
182 print x[i]
183
184 print pr.x + pr.y
1 NO CONTENT: file renamed from IPython/testing/attic/parametric.py to IPython/testing/parametric.py
@@ -12,6 +12,10 b' deb: plugin dtexample.py'
12 12 nosetests -vs --with-ipdoctest --doctest-tests --doctest-extension=txt \
13 13 test_combo.txt
14 14
15 iptest: plugin
16 nosetests -vs --with-ipdoctest --doctest-tests --doctest-extension=txt \
17 IPython
18
15 19 IPython_doctest_plugin.egg-info: ipdoctest.py setup.py
16 20 python setup.py install --prefix=$(PREFIX)
17 21 touch $@
@@ -298,9 +298,9 b' class IPDocTestParser(doctest.DocTestParser):'
298 298 """Convert input IPython source into valid Python."""
299 299 out = []
300 300 newline = out.append
301 for line in source.splitlines():
301 for lnum,line in enumerate(source.splitlines()):
302 302 #newline(_ip.IPipython.prefilter(line,True))
303 newline(_ip.IP.prefilter(line,True))
303 newline(_ip.IP.prefilter(line,lnum>0))
304 304 newline('') # ensure a closing newline, needed by doctest
305 305 return '\n'.join(out)
306 306
@@ -538,6 +538,20 b' class ExtensionDoctest(doctests.Doctest):'
538 538 """
539 539 #print 'Filename:',filename # dbg
540 540
541 # temporarily hardcoded list, will move to driver later
542 exclude = ['IPython/external/',
543 'IPython/Extensions/ipy_',
544 'IPython/platutils_win32',
545 'IPython/frontend/cocoa',
546 'IPython_doctest_plugin',
547 'IPython/Gnuplot',
548 'IPython/Extensions/PhysicalQIn']
549
550 for fex in exclude:
551 if fex in filename: # substring
552 #print '###>>> SKIP:',filename # dbg
553 return False
554
541 555 if is_extension_module(filename):
542 556 return True
543 557 else:
General Comments 0
You need to be logged in to leave comments. Login now