##// END OF EJS Templates
[core][tests][magic_terminal] Remove nose
Samuel Gaist -
Show More
@@ -11,8 +11,6 b' import sys'
11 from io import StringIO
11 from io import StringIO
12 from unittest import TestCase
12 from unittest import TestCase
13
13
14 import nose.tools as nt
15
16 from IPython.testing import tools as tt
14 from IPython.testing import tools as tt
17
15
18 #-----------------------------------------------------------------------------
16 #-----------------------------------------------------------------------------
@@ -93,16 +91,16 b' class PasteTestCase(TestCase):'
93 ip.hooks.clipboard_get = self.original_clip
91 ip.hooks.clipboard_get = self.original_clip
94
92
95 def test_paste(self):
93 def test_paste(self):
96 ip.user_ns.pop('x', None)
94 ip.user_ns.pop("x", None)
97 self.paste('x = 1')
95 self.paste("x = 1")
98 nt.assert_equal(ip.user_ns['x'], 1)
96 self.assertEqual(ip.user_ns["x"], 1)
99 ip.user_ns.pop('x')
97 ip.user_ns.pop("x")
100
98
101 def test_paste_pyprompt(self):
99 def test_paste_pyprompt(self):
102 ip.user_ns.pop('x', None)
100 ip.user_ns.pop("x", None)
103 self.paste('>>> x=2')
101 self.paste(">>> x=2")
104 nt.assert_equal(ip.user_ns['x'], 2)
102 self.assertEqual(ip.user_ns["x"], 2)
105 ip.user_ns.pop('x')
103 ip.user_ns.pop("x")
106
104
107 def test_paste_py_multi(self):
105 def test_paste_py_multi(self):
108 self.paste("""
106 self.paste("""
@@ -111,35 +109,38 b' class PasteTestCase(TestCase):'
111 >>> for i in x:
109 >>> for i in x:
112 ... y.append(i**2)
110 ... y.append(i**2)
113 ...
111 ...
114 """)
112 """
115 nt.assert_equal(ip.user_ns['x'], [1,2,3])
113 )
116 nt.assert_equal(ip.user_ns['y'], [1,4,9])
114 self.assertEqual(ip.user_ns["x"], [1, 2, 3])
115 self.assertEqual(ip.user_ns["y"], [1, 4, 9])
117
116
118 def test_paste_py_multi_r(self):
117 def test_paste_py_multi_r(self):
119 "Now, test that self.paste -r works"
118 "Now, test that self.paste -r works"
120 self.test_paste_py_multi()
119 self.test_paste_py_multi()
121 nt.assert_equal(ip.user_ns.pop('x'), [1,2,3])
120 self.assertEqual(ip.user_ns.pop("x"), [1, 2, 3])
122 nt.assert_equal(ip.user_ns.pop('y'), [1,4,9])
121 self.assertEqual(ip.user_ns.pop("y"), [1, 4, 9])
123 nt.assert_false('x' in ip.user_ns)
122 self.assertFalse("x" in ip.user_ns)
124 ip.magic('paste -r')
123 ip.magic("paste -r")
125 nt.assert_equal(ip.user_ns['x'], [1,2,3])
124 self.assertEqual(ip.user_ns["x"], [1, 2, 3])
126 nt.assert_equal(ip.user_ns['y'], [1,4,9])
125 self.assertEqual(ip.user_ns["y"], [1, 4, 9])
127
126
128 def test_paste_email(self):
127 def test_paste_email(self):
129 "Test pasting of email-quoted contents"
128 "Test pasting of email-quoted contents"
130 self.paste("""\
129 self.paste("""\
131 >> def foo(x):
130 >> def foo(x):
132 >> return x + 1
131 >> return x + 1
133 >> xx = foo(1.1)""")
132 >> xx = foo(1.1)"""
134 nt.assert_equal(ip.user_ns['xx'], 2.1)
133 )
134 self.assertEqual(ip.user_ns["xx"], 2.1)
135
135
136 def test_paste_email2(self):
136 def test_paste_email2(self):
137 "Email again; some programs add a space also at each quoting level"
137 "Email again; some programs add a space also at each quoting level"
138 self.paste("""\
138 self.paste("""\
139 > > def foo(x):
139 > > def foo(x):
140 > > return x + 1
140 > > return x + 1
141 > > yy = foo(2.1) """)
141 > > yy = foo(2.1) """
142 nt.assert_equal(ip.user_ns['yy'], 3.1)
142 )
143 self.assertEqual(ip.user_ns["yy"], 3.1)
143
144
144 def test_paste_email_py(self):
145 def test_paste_email_py(self):
145 "Email quoting of interactive input"
146 "Email quoting of interactive input"
@@ -147,8 +148,9 b' class PasteTestCase(TestCase):'
147 >> >>> def f(x):
148 >> >>> def f(x):
148 >> ... return x+1
149 >> ... return x+1
149 >> ...
150 >> ...
150 >> >>> zz = f(2.5) """)
151 >> >>> zz = f(2.5) """
151 nt.assert_equal(ip.user_ns['zz'], 3.5)
152 )
153 self.assertEqual(ip.user_ns["zz"], 3.5)
152
154
153 def test_paste_echo(self):
155 def test_paste_echo(self):
154 "Also test self.paste echoing, by temporarily faking the writer"
156 "Also test self.paste echoing, by temporarily faking the writer"
@@ -163,9 +165,9 b' class PasteTestCase(TestCase):'
163 out = w.getvalue()
165 out = w.getvalue()
164 finally:
166 finally:
165 ip.write = writer
167 ip.write = writer
166 nt.assert_equal(ip.user_ns['a'], 100)
168 self.assertEqual(ip.user_ns["a"], 100)
167 nt.assert_equal(ip.user_ns['b'], 200)
169 self.assertEqual(ip.user_ns["b"], 200)
168 assert out == code+"\n## -- End pasted text --\n"
170 assert out == code + "\n## -- End pasted text --\n"
169
171
170 def test_paste_leading_commas(self):
172 def test_paste_leading_commas(self):
171 "Test multiline strings with leading commas"
173 "Test multiline strings with leading commas"
@@ -174,10 +176,9 b' class PasteTestCase(TestCase):'
174 a = """
176 a = """
175 ,1,2,3
177 ,1,2,3
176 """'''
178 """'''
177 ip.user_ns.pop('foo', None)
179 ip.user_ns.pop("foo", None)
178 tm.store_or_execute(s, 'foo')
180 tm.store_or_execute(s, "foo")
179 nt.assert_in('foo', ip.user_ns)
181 self.assertIn("foo", ip.user_ns)
180
181
182
182 def test_paste_trailing_question(self):
183 def test_paste_trailing_question(self):
183 "Test pasting sources with trailing question marks"
184 "Test pasting sources with trailing question marks"
@@ -189,4 +190,4 b' def funcfoo():'
189 '''
190 '''
190 ip.user_ns.pop('funcfoo', None)
191 ip.user_ns.pop('funcfoo', None)
191 self.paste(s)
192 self.paste(s)
192 nt.assert_equal(ip.user_ns['funcfoo'](), 'fooresult')
193 self.assertEqual(ip.user_ns["funcfoo"](), "fooresult")
General Comments 0
You need to be logged in to leave comments. Login now