Show More
@@ -66,8 +66,6 b' def test_compiler_check_cache():' | |||
|
66 | 66 | cp.cache('x=1', 99) |
|
67 | 67 | # Ensure now that after clearing the cache, our entries survive |
|
68 | 68 | linecache.checkcache() |
|
69 | for k in linecache.cache: | |
|
70 |
|
|
|
71 | break | |
|
72 | else: | |
|
73 | raise AssertionError('Entry for input-99 missing from linecache') | |
|
69 | assert any( | |
|
70 | k.startswith("<ipython-input-99") for k in linecache.cache | |
|
71 | ), "Entry for input-99 missing from linecache" |
@@ -242,10 +242,8 b' def test_interruptible_core_debugger():' | |||
|
242 | 242 | """ |
|
243 | 243 | def raising_input(msg="", called=[0]): |
|
244 | 244 | called[0] += 1 |
|
245 | if called[0] == 1: | |
|
246 |
|
|
|
247 | else: | |
|
248 | raise AssertionError("input() should only be called once!") | |
|
245 | assert called[0] == 1, "input() should only be called once!" | |
|
246 | raise KeyboardInterrupt() | |
|
249 | 247 | |
|
250 | 248 | tracer_orig = sys.gettrace() |
|
251 | 249 | try: |
@@ -6,6 +6,7 b'' | |||
|
6 | 6 | # Imports |
|
7 | 7 | #----------------------------------------------------------------------------- |
|
8 | 8 | |
|
9 | import pytest | |
|
9 | 10 | from IPython.core.error import TryNext |
|
10 | 11 | from IPython.core.hooks import CommandChainDispatcher |
|
11 | 12 | |
@@ -41,12 +42,9 b' def test_command_chain_dispatcher_ff():' | |||
|
41 | 42 | fail2 = Fail("fail2") |
|
42 | 43 | dp = CommandChainDispatcher([(0, fail1), (10, fail2)]) |
|
43 | 44 | |
|
44 | try: | |
|
45 | with pytest.raises(TryNext) as e: | |
|
45 | 46 | dp() |
|
46 | except TryNext as e: | |
|
47 | assert str(e) == "fail2" | |
|
48 | else: | |
|
49 | assert False, "Expected exception was not raised." | |
|
47 | assert str(e.value) == "fail2" | |
|
50 | 48 | |
|
51 | 49 | assert fail1.called is True |
|
52 | 50 | assert fail2.called is True |
@@ -7,12 +7,8 b' import pytest' | |||
|
7 | 7 | from IPython.utils.tempdir import TemporaryDirectory |
|
8 | 8 | |
|
9 | 9 | def test_logstart_inaccessible_file(): |
|
10 | try: | |
|
10 | with pytest.raises(IOError): | |
|
11 | 11 | _ip.logger.logstart(logfname="/") # Opening that filename will fail. |
|
12 | except IOError: | |
|
13 | pass | |
|
14 | else: | |
|
15 | assert False # The try block should never pass. | |
|
16 | 12 | |
|
17 | 13 | try: |
|
18 | 14 | _ip.run_cell("a=1") # Check it doesn't try to log this |
@@ -132,10 +132,10 b' def test_config_print_class():' | |||
|
132 | 132 | _ip.magic('config TerminalInteractiveShell') |
|
133 | 133 | |
|
134 | 134 | stdout = captured.stdout |
|
135 | if not re.match("TerminalInteractiveShell.* options", stdout.splitlines()[0]): | |
|
136 | print(stdout) | |
|
137 | raise AssertionError("1st line of stdout not like " | |
|
138 | "'TerminalInteractiveShell.* options'") | |
|
135 | assert re.match( | |
|
136 | "TerminalInteractiveShell.* options", stdout.splitlines()[0] | |
|
137 | ), f"{stdout}\n\n1st line of stdout not like 'TerminalInteractiveShell.* options'" | |
|
138 | ||
|
139 | 139 | |
|
140 | 140 | def test_rehashx(): |
|
141 | 141 | # clear up everything |
@@ -1219,12 +1219,9 b' def test_edit_interactive():' | |||
|
1219 | 1219 | n = ip.execution_count |
|
1220 | 1220 | ip.run_cell("def foo(): return 1", store_history=True) |
|
1221 | 1221 | |
|
1222 | try: | |
|
1222 | with pytest.raises(code.InteractivelyDefined) as e: | |
|
1223 | 1223 | _run_edit_test("foo") |
|
1224 | except code.InteractivelyDefined as e: | |
|
1225 | assert e.index == n | |
|
1226 | else: | |
|
1227 | raise AssertionError("Should have raised InteractivelyDefined") | |
|
1224 | assert e.value.index == n | |
|
1228 | 1225 | |
|
1229 | 1226 | |
|
1230 | 1227 | def test_edit_cell(): |
@@ -70,13 +70,14 b' def test_columnize_random():' | |||
|
70 | 70 | out = text.columnize(items, row_first=row_first, displaywidth=displaywidth) |
|
71 | 71 | longer_line = max([len(x) for x in out.split('\n')]) |
|
72 | 72 | longer_element = max(rand_len) |
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
|
73 | assert longer_line <= displaywidth, ( | |
|
74 | f"Columnize displayed something lager than displaywidth : {longer_line}\n" | |
|
75 | f"longer element : {longer_element}\n" | |
|
76 | f"displaywidth : {displaywidth}\n" | |
|
77 | f"number of element : {nitems}\n" | |
|
78 | f"size of each element : {rand_len}\n" | |
|
79 | f"row_first={row_first}\n" | |
|
80 | ) | |
|
80 | 81 | |
|
81 | 82 | |
|
82 | 83 | # TODO: pytest mark.parametrize once nose removed. |
@@ -103,9 +104,9 b' def eval_formatter_check(f):' | |||
|
103 | 104 | ns = dict(n=12, pi=math.pi, stuff='hello there', os=os, u=u"cafΓ©", b="cafΓ©") |
|
104 | 105 | s = f.format("{n} {n//4} {stuff.split()[0]}", **ns) |
|
105 | 106 | assert s == "12 3 hello" |
|
106 |
s = f.format( |
|
|
107 | s = f.format(" ".join(["{n//%i}" % i for i in range(1, 8)]), **ns) | |
|
107 | 108 | assert s == "12 6 4 3 2 2 1" |
|
108 |
s = f.format( |
|
|
109 | s = f.format("{[n//i for i in range(1,8)]}", **ns) | |
|
109 | 110 | assert s == "[12, 6, 4, 3, 2, 2, 1]" |
|
110 | 111 | s = f.format("{stuff!s}", **ns) |
|
111 | 112 | assert s == ns["stuff"] |
@@ -133,9 +134,9 b' def eval_formatter_slicing_check(f):' | |||
|
133 | 134 | pytest.raises(SyntaxError, f.format, "{n:x}", **ns) |
|
134 | 135 | |
|
135 | 136 | def eval_formatter_no_slicing_check(f): |
|
136 |
ns = dict(n=12, pi=math.pi, stuff= |
|
|
137 | ||
|
138 |
s = f.format( |
|
|
137 | ns = dict(n=12, pi=math.pi, stuff="hello there", os=os) | |
|
138 | ||
|
139 | s = f.format("{n:x} {pi**2:+f}", **ns) | |
|
139 | 140 | assert s == "c +9.869604" |
|
140 | 141 | |
|
141 | 142 | s = f.format("{stuff[slice(1,4)]}", **ns) |
@@ -187,10 +188,11 b' def test_strip_email():' | |||
|
187 | 188 | |
|
188 | 189 | |
|
189 | 190 | def test_strip_email2(): |
|
190 |
src = |
|
|
191 |
cln = |
|
|
191 | src = "> > > list()" | |
|
192 | cln = "list()" | |
|
192 | 193 | assert text.strip_email_quotes(src) == cln |
|
193 | 194 | |
|
195 | ||
|
194 | 196 | def test_LSString(): |
|
195 | 197 | lss = text.LSString("abc\ndef") |
|
196 | 198 | assert lss.l == ["abc", "def"] |
@@ -198,6 +200,7 b' def test_LSString():' | |||
|
198 | 200 | lss = text.LSString(os.getcwd()) |
|
199 | 201 | assert isinstance(lss.p[0], Path) |
|
200 | 202 | |
|
203 | ||
|
201 | 204 | def test_SList(): |
|
202 | 205 | sl = text.SList(["a 11", "b 1", "a 2"]) |
|
203 | 206 | assert sl.n == "a 11\nb 1\na 2" |
General Comments 0
You need to be logged in to leave comments.
Login now