Show More
@@ -19,7 +19,6 b' import os' | |||||
19 | from os.path import join as pjoin |
|
19 | from os.path import join as pjoin | |
20 | import random |
|
20 | import random | |
21 | import sys |
|
21 | import sys | |
22 | import tempfile |
|
|||
23 | import textwrap |
|
22 | import textwrap | |
24 | import unittest |
|
23 | import unittest | |
25 |
|
24 | |||
@@ -209,7 +208,7 b' class TestMagicRunPass(tt.TempFileMixin):' | |||||
209 | def test_run_profile( self ): |
|
208 | def test_run_profile( self ): | |
210 | """Test that the option -p, which invokes the profiler, do not |
|
209 | """Test that the option -p, which invokes the profiler, do not | |
211 | crash by invoking execfile""" |
|
210 | crash by invoking execfile""" | |
212 |
|
|
211 | get_ipython() | |
213 | self.run_tmpfile_p() |
|
212 | self.run_tmpfile_p() | |
214 |
|
213 | |||
215 |
|
214 | |||
@@ -368,7 +367,6 b' tclass.py: deleting object: C-third' | |||||
368 | with tt.AssertNotPrints('SystemExit'): |
|
367 | with tt.AssertNotPrints('SystemExit'): | |
369 | _ip.magic('run -e %s' % self.fname) |
|
368 | _ip.magic('run -e %s' % self.fname) | |
370 |
|
369 | |||
371 | @dec.skip_without('nbformat') # Requires jsonschema |
|
|||
372 | def test_run_nb(self): |
|
370 | def test_run_nb(self): | |
373 | """Test %run notebook.ipynb""" |
|
371 | """Test %run notebook.ipynb""" | |
374 | from nbformat import v4, writes |
|
372 | from nbformat import v4, writes |
@@ -19,7 +19,6 b' import unittest' | |||||
19 |
|
19 | |||
20 | from IPython.testing import decorators as dec |
|
20 | from IPython.testing import decorators as dec | |
21 | from IPython.testing import tools as tt |
|
21 | from IPython.testing import tools as tt | |
22 | from IPython.utils.py3compat import PY3 |
|
|||
23 |
|
22 | |||
24 | sqlite_err_maybe = dec.module_not_available('sqlite3') |
|
23 | sqlite_err_maybe = dec.module_not_available('sqlite3') | |
25 | SQLITE_NOT_AVAILABLE_ERROR = ('WARNING: IPython History requires SQLite,' |
|
24 | SQLITE_NOT_AVAILABLE_ERROR = ('WARNING: IPython History requires SQLite,' | |
@@ -55,14 +54,3 b' class TestFileToRun(unittest.TestCase, tt.TempFileMixin):' | |||||
55 | out, err = tt.ipexec(self.fname, options=['-i'], |
|
54 | out, err = tt.ipexec(self.fname, options=['-i'], | |
56 | commands=['"__file__" in globals()', 'exit()']) |
|
55 | commands=['"__file__" in globals()', 'exit()']) | |
57 | self.assertIn("False", out) |
|
56 | self.assertIn("False", out) | |
58 |
|
||||
59 | @dec.skip_win32 |
|
|||
60 | @dec.skipif(PY3) |
|
|||
61 | def test_py_script_file_compiler_directive(self): |
|
|||
62 | """Test `__future__` compiler directives with `ipython -i file.py`""" |
|
|||
63 | src = "from __future__ import division\n" |
|
|||
64 | self.mktmp(src) |
|
|||
65 |
|
||||
66 | out, err = tt.ipexec(self.fname, options=['-i'], |
|
|||
67 | commands=['type(1/2)', 'exit()']) |
|
|||
68 | self.assertIn('float', out) |
|
@@ -7,13 +7,13 b'' | |||||
7 | from __future__ import print_function |
|
7 | from __future__ import print_function | |
8 |
|
8 | |||
9 | from collections import Counter, defaultdict, deque, OrderedDict |
|
9 | from collections import Counter, defaultdict, deque, OrderedDict | |
10 |
import types, string |
|
10 | import types, string | |
11 |
|
11 | |||
12 | import nose.tools as nt |
|
12 | import nose.tools as nt | |
13 |
|
13 | |||
14 | from IPython.lib import pretty |
|
14 | from IPython.lib import pretty | |
15 |
from IPython.testing.decorators import (skip_without, py2_only, py3_only |
|
15 | from IPython.testing.decorators import (skip_without, py2_only, py3_only) | |
16 |
|
|
16 | ||
17 | from IPython.utils.py3compat import PY3, unicode_to_str |
|
17 | from IPython.utils.py3compat import PY3, unicode_to_str | |
18 |
|
18 | |||
19 | if PY3: |
|
19 | if PY3: | |
@@ -161,7 +161,7 b' def test_pprint_break_repr():' | |||||
161 | def test_bad_repr(): |
|
161 | def test_bad_repr(): | |
162 | """Don't catch bad repr errors""" |
|
162 | """Don't catch bad repr errors""" | |
163 | with nt.assert_raises(ZeroDivisionError): |
|
163 | with nt.assert_raises(ZeroDivisionError): | |
164 |
|
|
164 | pretty.pretty(BadRepr()) | |
165 |
|
165 | |||
166 | class BadException(Exception): |
|
166 | class BadException(Exception): | |
167 | def __str__(self): |
|
167 | def __str__(self): | |
@@ -178,7 +178,7 b' class ReallyBadRepr(object):' | |||||
178 |
|
178 | |||
179 | def test_really_bad_repr(): |
|
179 | def test_really_bad_repr(): | |
180 | with nt.assert_raises(BadException): |
|
180 | with nt.assert_raises(BadException): | |
181 |
|
|
181 | pretty.pretty(ReallyBadRepr()) | |
182 |
|
182 | |||
183 |
|
183 | |||
184 | class SA(object): |
|
184 | class SA(object): | |
@@ -485,52 +485,3 b' def test_mappingproxy():' | |||||
485 | ] |
|
485 | ] | |
486 | for obj, expected in cases: |
|
486 | for obj, expected in cases: | |
487 | nt.assert_equal(pretty.pretty(obj), expected) |
|
487 | nt.assert_equal(pretty.pretty(obj), expected) | |
488 |
|
||||
489 | @cpython2_only # In PyPy, types.DictProxyType is dict |
|
|||
490 | def test_dictproxy(): |
|
|||
491 | # This is the dictproxy constructor itself from the Python API, |
|
|||
492 | DP = ctypes.pythonapi.PyDictProxy_New |
|
|||
493 | DP.argtypes, DP.restype = (ctypes.py_object,), ctypes.py_object |
|
|||
494 |
|
||||
495 | underlying_dict = {} |
|
|||
496 | mp_recursive = DP(underlying_dict) |
|
|||
497 | underlying_dict[0] = mp_recursive |
|
|||
498 | underlying_dict[-3] = underlying_dict |
|
|||
499 |
|
||||
500 | cases = [ |
|
|||
501 | (DP({}), "dict_proxy({})"), |
|
|||
502 | (DP({None: DP({})}), "dict_proxy({None: dict_proxy({})})"), |
|
|||
503 | (DP({k: k.lower() for k in string.ascii_uppercase}), |
|
|||
504 | "dict_proxy({'A': 'a',\n" |
|
|||
505 | " 'B': 'b',\n" |
|
|||
506 | " 'C': 'c',\n" |
|
|||
507 | " 'D': 'd',\n" |
|
|||
508 | " 'E': 'e',\n" |
|
|||
509 | " 'F': 'f',\n" |
|
|||
510 | " 'G': 'g',\n" |
|
|||
511 | " 'H': 'h',\n" |
|
|||
512 | " 'I': 'i',\n" |
|
|||
513 | " 'J': 'j',\n" |
|
|||
514 | " 'K': 'k',\n" |
|
|||
515 | " 'L': 'l',\n" |
|
|||
516 | " 'M': 'm',\n" |
|
|||
517 | " 'N': 'n',\n" |
|
|||
518 | " 'O': 'o',\n" |
|
|||
519 | " 'P': 'p',\n" |
|
|||
520 | " 'Q': 'q',\n" |
|
|||
521 | " 'R': 'r',\n" |
|
|||
522 | " 'S': 's',\n" |
|
|||
523 | " 'T': 't',\n" |
|
|||
524 | " 'U': 'u',\n" |
|
|||
525 | " 'V': 'v',\n" |
|
|||
526 | " 'W': 'w',\n" |
|
|||
527 | " 'X': 'x',\n" |
|
|||
528 | " 'Y': 'y',\n" |
|
|||
529 | " 'Z': 'z'})"), |
|
|||
530 | (mp_recursive, "dict_proxy({-3: {-3: {...}, 0: {...}}, 0: {...}})"), |
|
|||
531 | ] |
|
|||
532 | for obj, expected in cases: |
|
|||
533 | nt.assert_is_instance(obj, types.DictProxyType) # Meta-test |
|
|||
534 | nt.assert_equal(pretty.pretty(obj), expected) |
|
|||
535 | nt.assert_equal(pretty.pretty(underlying_dict), |
|
|||
536 | "{-3: {...}, 0: dict_proxy({-3: {...}, 0: {...}})}") |
|
@@ -336,7 +336,6 b" skip_known_failure = knownfailureif(True,'This test is known to fail')" | |||||
336 | known_failure_py3 = knownfailureif(sys.version_info[0] >= 3, |
|
336 | known_failure_py3 = knownfailureif(sys.version_info[0] >= 3, | |
337 | 'This test is known to fail on Python 3.') |
|
337 | 'This test is known to fail on Python 3.') | |
338 |
|
338 | |||
339 | cpython2_only = skipif(PY3 or PYPY, "This test only runs on CPython 2.") |
|
|||
340 | py2_only = skipif(PY3, "This test only runs on Python 2.") |
|
339 | py2_only = skipif(PY3, "This test only runs on Python 2.") | |
341 | py3_only = skipif(PY2, "This test only runs on Python 3.") |
|
340 | py3_only = skipif(PY2, "This test only runs on Python 3.") | |
342 |
|
341 |
General Comments 0
You need to be logged in to leave comments.
Login now