##// END OF EJS Templates
s/assertEquals/assertEqual/
Bradley M. Froehle -
Show More
@@ -82,94 +82,94 b' class TestApplication(TestCase):'
82 82
83 83 def test_basic(self):
84 84 app = MyApp()
85 self.assertEquals(app.name, u'myapp')
86 self.assertEquals(app.running, False)
87 self.assertEquals(app.classes, [MyApp,Bar,Foo])
88 self.assertEquals(app.config_file, u'')
85 self.assertEqual(app.name, u'myapp')
86 self.assertEqual(app.running, False)
87 self.assertEqual(app.classes, [MyApp,Bar,Foo])
88 self.assertEqual(app.config_file, u'')
89 89
90 90 def test_config(self):
91 91 app = MyApp()
92 92 app.parse_command_line(["--i=10","--Foo.j=10","--enabled=False","--log-level=50"])
93 93 config = app.config
94 self.assertEquals(config.Foo.i, 10)
95 self.assertEquals(config.Foo.j, 10)
96 self.assertEquals(config.Bar.enabled, False)
97 self.assertEquals(config.MyApp.log_level,50)
94 self.assertEqual(config.Foo.i, 10)
95 self.assertEqual(config.Foo.j, 10)
96 self.assertEqual(config.Bar.enabled, False)
97 self.assertEqual(config.MyApp.log_level,50)
98 98
99 99 def test_config_propagation(self):
100 100 app = MyApp()
101 101 app.parse_command_line(["--i=10","--Foo.j=10","--enabled=False","--log-level=50"])
102 102 app.init_foo()
103 103 app.init_bar()
104 self.assertEquals(app.foo.i, 10)
105 self.assertEquals(app.foo.j, 10)
106 self.assertEquals(app.bar.enabled, False)
104 self.assertEqual(app.foo.i, 10)
105 self.assertEqual(app.foo.j, 10)
106 self.assertEqual(app.bar.enabled, False)
107 107
108 108 def test_flags(self):
109 109 app = MyApp()
110 110 app.parse_command_line(["--disable"])
111 111 app.init_bar()
112 self.assertEquals(app.bar.enabled, False)
112 self.assertEqual(app.bar.enabled, False)
113 113 app.parse_command_line(["--enable"])
114 114 app.init_bar()
115 self.assertEquals(app.bar.enabled, True)
115 self.assertEqual(app.bar.enabled, True)
116 116
117 117 def test_aliases(self):
118 118 app = MyApp()
119 119 app.parse_command_line(["--i=5", "--j=10"])
120 120 app.init_foo()
121 self.assertEquals(app.foo.i, 5)
121 self.assertEqual(app.foo.i, 5)
122 122 app.init_foo()
123 self.assertEquals(app.foo.j, 10)
123 self.assertEqual(app.foo.j, 10)
124 124
125 125 def test_flag_clobber(self):
126 126 """test that setting flags doesn't clobber existing settings"""
127 127 app = MyApp()
128 128 app.parse_command_line(["--Bar.b=5", "--disable"])
129 129 app.init_bar()
130 self.assertEquals(app.bar.enabled, False)
131 self.assertEquals(app.bar.b, 5)
130 self.assertEqual(app.bar.enabled, False)
131 self.assertEqual(app.bar.b, 5)
132 132 app.parse_command_line(["--enable", "--Bar.b=10"])
133 133 app.init_bar()
134 self.assertEquals(app.bar.enabled, True)
135 self.assertEquals(app.bar.b, 10)
134 self.assertEqual(app.bar.enabled, True)
135 self.assertEqual(app.bar.b, 10)
136 136
137 137 def test_flatten_flags(self):
138 138 cfg = Config()
139 139 cfg.MyApp.log_level = logging.WARN
140 140 app = MyApp()
141 141 app.update_config(cfg)
142 self.assertEquals(app.log_level, logging.WARN)
143 self.assertEquals(app.config.MyApp.log_level, logging.WARN)
142 self.assertEqual(app.log_level, logging.WARN)
143 self.assertEqual(app.config.MyApp.log_level, logging.WARN)
144 144 app.initialize(["--crit"])
145 self.assertEquals(app.log_level, logging.CRITICAL)
145 self.assertEqual(app.log_level, logging.CRITICAL)
146 146 # this would be app.config.Application.log_level if it failed:
147 self.assertEquals(app.config.MyApp.log_level, logging.CRITICAL)
147 self.assertEqual(app.config.MyApp.log_level, logging.CRITICAL)
148 148
149 149 def test_flatten_aliases(self):
150 150 cfg = Config()
151 151 cfg.MyApp.log_level = logging.WARN
152 152 app = MyApp()
153 153 app.update_config(cfg)
154 self.assertEquals(app.log_level, logging.WARN)
155 self.assertEquals(app.config.MyApp.log_level, logging.WARN)
154 self.assertEqual(app.log_level, logging.WARN)
155 self.assertEqual(app.config.MyApp.log_level, logging.WARN)
156 156 app.initialize(["--log-level", "CRITICAL"])
157 self.assertEquals(app.log_level, logging.CRITICAL)
157 self.assertEqual(app.log_level, logging.CRITICAL)
158 158 # this would be app.config.Application.log_level if it failed:
159 self.assertEquals(app.config.MyApp.log_level, "CRITICAL")
159 self.assertEqual(app.config.MyApp.log_level, "CRITICAL")
160 160
161 161 def test_extra_args(self):
162 162 app = MyApp()
163 163 app.parse_command_line(["--Bar.b=5", 'extra', "--disable", 'args'])
164 164 app.init_bar()
165 self.assertEquals(app.bar.enabled, False)
166 self.assertEquals(app.bar.b, 5)
167 self.assertEquals(app.extra_args, ['extra', 'args'])
165 self.assertEqual(app.bar.enabled, False)
166 self.assertEqual(app.bar.b, 5)
167 self.assertEqual(app.extra_args, ['extra', 'args'])
168 168 app = MyApp()
169 169 app.parse_command_line(["--Bar.b=5", '--', 'extra', "--disable", 'args'])
170 170 app.init_bar()
171 self.assertEquals(app.bar.enabled, True)
172 self.assertEquals(app.bar.b, 5)
173 self.assertEquals(app.extra_args, ['extra', '--disable', 'args'])
171 self.assertEqual(app.bar.enabled, True)
172 self.assertEqual(app.bar.b, 5)
173 self.assertEqual(app.extra_args, ['extra', '--disable', 'args'])
174 174
175 175
@@ -83,8 +83,8 b' class TestConfigurable(TestCase):'
83 83 c1 = Configurable()
84 84 c2 = Configurable(config=c1.config)
85 85 c3 = Configurable(config=c2.config)
86 self.assertEquals(c1.config, c2.config)
87 self.assertEquals(c2.config, c3.config)
86 self.assertEqual(c1.config, c2.config)
87 self.assertEqual(c2.config, c3.config)
88 88
89 89 def test_custom(self):
90 90 config = Config()
@@ -93,9 +93,9 b' class TestConfigurable(TestCase):'
93 93 c1 = Configurable(config=config)
94 94 c2 = Configurable(config=c1.config)
95 95 c3 = Configurable(config=c2.config)
96 self.assertEquals(c1.config, config)
97 self.assertEquals(c2.config, config)
98 self.assertEquals(c3.config, config)
96 self.assertEqual(c1.config, config)
97 self.assertEqual(c2.config, config)
98 self.assertEqual(c3.config, config)
99 99 # Test that copies are not made
100 100 self.assert_(c1.config is config)
101 101 self.assert_(c2.config is config)
@@ -109,10 +109,10 b' class TestConfigurable(TestCase):'
109 109 config.MyConfigurable.b = 2.0
110 110 c1 = MyConfigurable(config=config)
111 111 c2 = MyConfigurable(config=c1.config)
112 self.assertEquals(c1.a, config.MyConfigurable.a)
113 self.assertEquals(c1.b, config.MyConfigurable.b)
114 self.assertEquals(c2.a, config.MyConfigurable.a)
115 self.assertEquals(c2.b, config.MyConfigurable.b)
112 self.assertEqual(c1.a, config.MyConfigurable.a)
113 self.assertEqual(c1.b, config.MyConfigurable.b)
114 self.assertEqual(c2.a, config.MyConfigurable.a)
115 self.assertEqual(c2.b, config.MyConfigurable.b)
116 116
117 117 def test_parent(self):
118 118 config = Config()
@@ -122,19 +122,19 b' class TestConfigurable(TestCase):'
122 122 config.Bar.c = 100.0
123 123 f = Foo(config=config)
124 124 b = Bar(config=f.config)
125 self.assertEquals(f.a, 10)
126 self.assertEquals(f.b, 'wow')
127 self.assertEquals(b.b, 'gotit')
128 self.assertEquals(b.c, 100.0)
125 self.assertEqual(f.a, 10)
126 self.assertEqual(f.b, 'wow')
127 self.assertEqual(b.b, 'gotit')
128 self.assertEqual(b.c, 100.0)
129 129
130 130 def test_override1(self):
131 131 config = Config()
132 132 config.MyConfigurable.a = 2
133 133 config.MyConfigurable.b = 2.0
134 134 c = MyConfigurable(a=3, config=config)
135 self.assertEquals(c.a, 3)
136 self.assertEquals(c.b, config.MyConfigurable.b)
137 self.assertEquals(c.c, 'no config')
135 self.assertEqual(c.a, 3)
136 self.assertEqual(c.b, config.MyConfigurable.b)
137 self.assertEqual(c.c, 'no config')
138 138
139 139 def test_override2(self):
140 140 config = Config()
@@ -142,20 +142,20 b' class TestConfigurable(TestCase):'
142 142 config.Bar.b = 'or' # Up above b is config=False, so this won't do it.
143 143 config.Bar.c = 10.0
144 144 c = Bar(config=config)
145 self.assertEquals(c.a, config.Foo.a)
146 self.assertEquals(c.b, 'gotit')
147 self.assertEquals(c.c, config.Bar.c)
145 self.assertEqual(c.a, config.Foo.a)
146 self.assertEqual(c.b, 'gotit')
147 self.assertEqual(c.c, config.Bar.c)
148 148 c = Bar(a=2, b='and', c=20.0, config=config)
149 self.assertEquals(c.a, 2)
150 self.assertEquals(c.b, 'and')
151 self.assertEquals(c.c, 20.0)
149 self.assertEqual(c.a, 2)
150 self.assertEqual(c.b, 'and')
151 self.assertEqual(c.c, 20.0)
152 152
153 153 def test_help(self):
154 self.assertEquals(MyConfigurable.class_get_help(), mc_help)
154 self.assertEqual(MyConfigurable.class_get_help(), mc_help)
155 155
156 156 def test_help_inst(self):
157 157 inst = MyConfigurable(a=5, b=4)
158 self.assertEquals(MyConfigurable.class_get_help(inst), mc_help_inst)
158 self.assertEqual(MyConfigurable.class_get_help(inst), mc_help_inst)
159 159
160 160
161 161 class TestSingletonConfigurable(TestCase):
@@ -163,21 +163,21 b' class TestSingletonConfigurable(TestCase):'
163 163 def test_instance(self):
164 164 from IPython.config.configurable import SingletonConfigurable
165 165 class Foo(SingletonConfigurable): pass
166 self.assertEquals(Foo.initialized(), False)
166 self.assertEqual(Foo.initialized(), False)
167 167 foo = Foo.instance()
168 self.assertEquals(Foo.initialized(), True)
169 self.assertEquals(foo, Foo.instance())
170 self.assertEquals(SingletonConfigurable._instance, None)
168 self.assertEqual(Foo.initialized(), True)
169 self.assertEqual(foo, Foo.instance())
170 self.assertEqual(SingletonConfigurable._instance, None)
171 171
172 172 def test_inheritance(self):
173 173 class Bar(SingletonConfigurable): pass
174 174 class Bam(Bar): pass
175 self.assertEquals(Bar.initialized(), False)
176 self.assertEquals(Bam.initialized(), False)
175 self.assertEqual(Bar.initialized(), False)
176 self.assertEqual(Bam.initialized(), False)
177 177 bam = Bam.instance()
178 178 bam == Bar.instance()
179 self.assertEquals(Bar.initialized(), True)
180 self.assertEquals(Bam.initialized(), True)
181 self.assertEquals(bam, Bam._instance)
182 self.assertEquals(bam, Bar._instance)
183 self.assertEquals(SingletonConfigurable._instance, None)
179 self.assertEqual(Bar.initialized(), True)
180 self.assertEqual(Bam.initialized(), True)
181 self.assertEqual(bam, Bam._instance)
182 self.assertEqual(bam, Bar._instance)
183 self.assertEqual(SingletonConfigurable._instance, None)
@@ -63,11 +63,11 b' class TestPyFileCL(TestCase):'
63 63 # Unlink the file
64 64 cl = PyFileConfigLoader(fname)
65 65 config = cl.load_config()
66 self.assertEquals(config.a, 10)
67 self.assertEquals(config.b, 20)
68 self.assertEquals(config.Foo.Bar.value, 10)
69 self.assertEquals(config.Foo.Bam.value, range(10))
70 self.assertEquals(config.D.C.value, 'hi there')
66 self.assertEqual(config.a, 10)
67 self.assertEqual(config.b, 20)
68 self.assertEqual(config.Foo.Bar.value, 10)
69 self.assertEqual(config.Foo.Bam.value, range(10))
70 self.assertEqual(config.D.C.value, 'hi there')
71 71
72 72 class MyLoader1(ArgParseConfigLoader):
73 73 def _add_arguments(self, aliases=None, flags=None):
@@ -90,31 +90,31 b' class TestArgParseCL(TestCase):'
90 90 def test_basic(self):
91 91 cl = MyLoader1()
92 92 config = cl.load_config('-f hi -b 10 -n wow'.split())
93 self.assertEquals(config.Global.foo, 'hi')
94 self.assertEquals(config.MyClass.bar, 10)
95 self.assertEquals(config.n, True)
96 self.assertEquals(config.Global.bam, 'wow')
93 self.assertEqual(config.Global.foo, 'hi')
94 self.assertEqual(config.MyClass.bar, 10)
95 self.assertEqual(config.n, True)
96 self.assertEqual(config.Global.bam, 'wow')
97 97 config = cl.load_config(['wow'])
98 self.assertEquals(config.keys(), ['Global'])
99 self.assertEquals(config.Global.keys(), ['bam'])
100 self.assertEquals(config.Global.bam, 'wow')
98 self.assertEqual(config.keys(), ['Global'])
99 self.assertEqual(config.Global.keys(), ['bam'])
100 self.assertEqual(config.Global.bam, 'wow')
101 101
102 102 def test_add_arguments(self):
103 103 cl = MyLoader2()
104 104 config = cl.load_config('2 frobble'.split())
105 self.assertEquals(config.subparser_name, '2')
106 self.assertEquals(config.y, 'frobble')
105 self.assertEqual(config.subparser_name, '2')
106 self.assertEqual(config.y, 'frobble')
107 107 config = cl.load_config('1 -x frobble'.split())
108 self.assertEquals(config.subparser_name, '1')
109 self.assertEquals(config.Global.x, 'frobble')
108 self.assertEqual(config.subparser_name, '1')
109 self.assertEqual(config.Global.x, 'frobble')
110 110
111 111 def test_argv(self):
112 112 cl = MyLoader1(argv='-f hi -b 10 -n wow'.split())
113 113 config = cl.load_config()
114 self.assertEquals(config.Global.foo, 'hi')
115 self.assertEquals(config.MyClass.bar, 10)
116 self.assertEquals(config.n, True)
117 self.assertEquals(config.Global.bam, 'wow')
114 self.assertEqual(config.Global.foo, 'hi')
115 self.assertEqual(config.MyClass.bar, 10)
116 self.assertEqual(config.n, True)
117 self.assertEqual(config.Global.bam, 'wow')
118 118
119 119
120 120 class TestKeyValueCL(TestCase):
@@ -125,39 +125,39 b' class TestKeyValueCL(TestCase):'
125 125 argv = ['--'+s.strip('c.') for s in pyfile.split('\n')[2:-1]]
126 126 with mute_warn():
127 127 config = cl.load_config(argv)
128 self.assertEquals(config.a, 10)
129 self.assertEquals(config.b, 20)
130 self.assertEquals(config.Foo.Bar.value, 10)
131 self.assertEquals(config.Foo.Bam.value, range(10))
132 self.assertEquals(config.D.C.value, 'hi there')
128 self.assertEqual(config.a, 10)
129 self.assertEqual(config.b, 20)
130 self.assertEqual(config.Foo.Bar.value, 10)
131 self.assertEqual(config.Foo.Bam.value, range(10))
132 self.assertEqual(config.D.C.value, 'hi there')
133 133
134 134 def test_expanduser(self):
135 135 cl = self.klass()
136 136 argv = ['--a=~/1/2/3', '--b=~', '--c=~/', '--d="~/"']
137 137 with mute_warn():
138 138 config = cl.load_config(argv)
139 self.assertEquals(config.a, os.path.expanduser('~/1/2/3'))
140 self.assertEquals(config.b, os.path.expanduser('~'))
141 self.assertEquals(config.c, os.path.expanduser('~/'))
142 self.assertEquals(config.d, '~/')
139 self.assertEqual(config.a, os.path.expanduser('~/1/2/3'))
140 self.assertEqual(config.b, os.path.expanduser('~'))
141 self.assertEqual(config.c, os.path.expanduser('~/'))
142 self.assertEqual(config.d, '~/')
143 143
144 144 def test_extra_args(self):
145 145 cl = self.klass()
146 146 with mute_warn():
147 147 config = cl.load_config(['--a=5', 'b', '--c=10', 'd'])
148 self.assertEquals(cl.extra_args, ['b', 'd'])
149 self.assertEquals(config.a, 5)
150 self.assertEquals(config.c, 10)
148 self.assertEqual(cl.extra_args, ['b', 'd'])
149 self.assertEqual(config.a, 5)
150 self.assertEqual(config.c, 10)
151 151 with mute_warn():
152 152 config = cl.load_config(['--', '--a=5', '--c=10'])
153 self.assertEquals(cl.extra_args, ['--a=5', '--c=10'])
153 self.assertEqual(cl.extra_args, ['--a=5', '--c=10'])
154 154
155 155 def test_unicode_args(self):
156 156 cl = self.klass()
157 157 argv = [u'--a=épsîlön']
158 158 with mute_warn():
159 159 config = cl.load_config(argv)
160 self.assertEquals(config.a, u'épsîlön')
160 self.assertEqual(config.a, u'épsîlön')
161 161
162 162 def test_unicode_bytes_args(self):
163 163 uarg = u'--a=é'
@@ -169,14 +169,14 b' class TestKeyValueCL(TestCase):'
169 169 cl = self.klass()
170 170 with mute_warn():
171 171 config = cl.load_config([barg])
172 self.assertEquals(config.a, u'é')
172 self.assertEqual(config.a, u'é')
173 173
174 174 def test_unicode_alias(self):
175 175 cl = self.klass()
176 176 argv = [u'--a=épsîlön']
177 177 with mute_warn():
178 178 config = cl.load_config(argv, aliases=dict(a='A.a'))
179 self.assertEquals(config.A.a, u'épsîlön')
179 self.assertEqual(config.A.a, u'épsîlön')
180 180
181 181
182 182 class TestArgParseKVCL(TestKeyValueCL):
@@ -187,15 +187,15 b' class TestArgParseKVCL(TestKeyValueCL):'
187 187 argv = ['-a', '~/1/2/3', '--b', "'~/1/2/3'"]
188 188 with mute_warn():
189 189 config = cl.load_config(argv, aliases=dict(a='A.a', b='A.b'))
190 self.assertEquals(config.A.a, os.path.expanduser('~/1/2/3'))
191 self.assertEquals(config.A.b, '~/1/2/3')
190 self.assertEqual(config.A.a, os.path.expanduser('~/1/2/3'))
191 self.assertEqual(config.A.b, '~/1/2/3')
192 192
193 193 def test_eval(self):
194 194 cl = self.klass()
195 195 argv = ['-c', 'a=5']
196 196 with mute_warn():
197 197 config = cl.load_config(argv, aliases=dict(c='A.c'))
198 self.assertEquals(config.A.c, u"a=5")
198 self.assertEqual(config.A.c, u"a=5")
199 199
200 200
201 201 class TestConfig(TestCase):
@@ -203,19 +203,19 b' class TestConfig(TestCase):'
203 203 def test_setget(self):
204 204 c = Config()
205 205 c.a = 10
206 self.assertEquals(c.a, 10)
207 self.assertEquals('b' in c, False)
206 self.assertEqual(c.a, 10)
207 self.assertEqual('b' in c, False)
208 208
209 209 def test_auto_section(self):
210 210 c = Config()
211 self.assertEquals('A' in c, True)
212 self.assertEquals(c._has_section('A'), False)
211 self.assertEqual('A' in c, True)
212 self.assertEqual(c._has_section('A'), False)
213 213 A = c.A
214 214 A.foo = 'hi there'
215 self.assertEquals(c._has_section('A'), True)
216 self.assertEquals(c.A.foo, 'hi there')
215 self.assertEqual(c._has_section('A'), True)
216 self.assertEqual(c.A.foo, 'hi there')
217 217 del c.A
218 self.assertEquals(len(c.A.keys()),0)
218 self.assertEqual(len(c.A.keys()),0)
219 219
220 220 def test_merge_doesnt_exist(self):
221 221 c1 = Config()
@@ -223,11 +223,11 b' class TestConfig(TestCase):'
223 223 c2.bar = 10
224 224 c2.Foo.bar = 10
225 225 c1._merge(c2)
226 self.assertEquals(c1.Foo.bar, 10)
227 self.assertEquals(c1.bar, 10)
226 self.assertEqual(c1.Foo.bar, 10)
227 self.assertEqual(c1.bar, 10)
228 228 c2.Bar.bar = 10
229 229 c1._merge(c2)
230 self.assertEquals(c1.Bar.bar, 10)
230 self.assertEqual(c1.Bar.bar, 10)
231 231
232 232 def test_merge_exists(self):
233 233 c1 = Config()
@@ -237,12 +237,12 b' class TestConfig(TestCase):'
237 237 c2.Foo.bar = 20
238 238 c2.Foo.wow = 40
239 239 c1._merge(c2)
240 self.assertEquals(c1.Foo.bam, 30)
241 self.assertEquals(c1.Foo.bar, 20)
242 self.assertEquals(c1.Foo.wow, 40)
240 self.assertEqual(c1.Foo.bam, 30)
241 self.assertEqual(c1.Foo.bar, 20)
242 self.assertEqual(c1.Foo.wow, 40)
243 243 c2.Foo.Bam.bam = 10
244 244 c1._merge(c2)
245 self.assertEquals(c1.Foo.Bam.bam, 10)
245 self.assertEqual(c1.Foo.Bam.bam, 10)
246 246
247 247 def test_deepcopy(self):
248 248 c1 = Config()
@@ -252,12 +252,12 b' class TestConfig(TestCase):'
252 252 c1.b = range(10)
253 253 import copy
254 254 c2 = copy.deepcopy(c1)
255 self.assertEquals(c1, c2)
255 self.assertEqual(c1, c2)
256 256 self.assert_(c1 is not c2)
257 257 self.assert_(c1.Foo is not c2.Foo)
258 258
259 259 def test_builtin(self):
260 260 c1 = Config()
261 261 exec 'foo = True' in c1
262 self.assertEquals(c1.foo, True)
262 self.assertEqual(c1.foo, True)
263 263 self.assertRaises(ConfigError, setattr, c1, 'ValueError', 10)
@@ -50,17 +50,17 b' class InteractiveShellTestCase(unittest.TestCase):'
50 50 """Test that cells with only naked strings are fully executed"""
51 51 # First, single-line inputs
52 52 ip.run_cell('"a"\n')
53 self.assertEquals(ip.user_ns['_'], 'a')
53 self.assertEqual(ip.user_ns['_'], 'a')
54 54 # And also multi-line cells
55 55 ip.run_cell('"""a\nb"""\n')
56 self.assertEquals(ip.user_ns['_'], 'a\nb')
56 self.assertEqual(ip.user_ns['_'], 'a\nb')
57 57
58 58 def test_run_empty_cell(self):
59 59 """Just make sure we don't get a horrible error with a blank
60 60 cell of input. Yes, I did overlook that."""
61 61 old_xc = ip.execution_count
62 62 ip.run_cell('')
63 self.assertEquals(ip.execution_count, old_xc)
63 self.assertEqual(ip.execution_count, old_xc)
64 64
65 65 def test_run_cell_multiline(self):
66 66 """Multi-block, multi-line cells must execute correctly.
@@ -71,38 +71,38 b' class InteractiveShellTestCase(unittest.TestCase):'
71 71 " x += 1",
72 72 " y += 1",])
73 73 ip.run_cell(src)
74 self.assertEquals(ip.user_ns['x'], 2)
75 self.assertEquals(ip.user_ns['y'], 3)
74 self.assertEqual(ip.user_ns['x'], 2)
75 self.assertEqual(ip.user_ns['y'], 3)
76 76
77 77 def test_multiline_string_cells(self):
78 78 "Code sprinkled with multiline strings should execute (GH-306)"
79 79 ip.run_cell('tmp=0')
80 self.assertEquals(ip.user_ns['tmp'], 0)
80 self.assertEqual(ip.user_ns['tmp'], 0)
81 81 ip.run_cell('tmp=1;"""a\nb"""\n')
82 self.assertEquals(ip.user_ns['tmp'], 1)
82 self.assertEqual(ip.user_ns['tmp'], 1)
83 83
84 84 def test_dont_cache_with_semicolon(self):
85 85 "Ending a line with semicolon should not cache the returned object (GH-307)"
86 86 oldlen = len(ip.user_ns['Out'])
87 87 a = ip.run_cell('1;', store_history=True)
88 88 newlen = len(ip.user_ns['Out'])
89 self.assertEquals(oldlen, newlen)
89 self.assertEqual(oldlen, newlen)
90 90 #also test the default caching behavior
91 91 ip.run_cell('1', store_history=True)
92 92 newlen = len(ip.user_ns['Out'])
93 self.assertEquals(oldlen+1, newlen)
93 self.assertEqual(oldlen+1, newlen)
94 94
95 95 def test_In_variable(self):
96 96 "Verify that In variable grows with user input (GH-284)"
97 97 oldlen = len(ip.user_ns['In'])
98 98 ip.run_cell('1;', store_history=True)
99 99 newlen = len(ip.user_ns['In'])
100 self.assertEquals(oldlen+1, newlen)
101 self.assertEquals(ip.user_ns['In'][-1],'1;')
100 self.assertEqual(oldlen+1, newlen)
101 self.assertEqual(ip.user_ns['In'][-1],'1;')
102 102
103 103 def test_magic_names_in_string(self):
104 104 ip.run_cell('a = """\n%exit\n"""')
105 self.assertEquals(ip.user_ns['a'], '\n%exit\n')
105 self.assertEqual(ip.user_ns['a'], '\n%exit\n')
106 106
107 107 def test_alias_crash(self):
108 108 """Errors in prefilter can't crash IPython"""
@@ -113,7 +113,7 b' class InteractiveShellTestCase(unittest.TestCase):'
113 113 ip.run_cell('parts 1')
114 114 err = io.stderr.getvalue()
115 115 io.stderr = save_err
116 self.assertEquals(err.split(':')[0], 'ERROR')
116 self.assertEqual(err.split(':')[0], 'ERROR')
117 117
118 118 def test_trailing_newline(self):
119 119 """test that running !(command) does not raise a SyntaxError"""
@@ -192,9 +192,9 b' class InteractiveShellTestCase(unittest.TestCase):'
192 192 # capture stderr
193 193 io.stderr = StringIO()
194 194 ip.set_custom_exc((IOError,), lambda etype,value,tb: 1/0)
195 self.assertEquals(ip.custom_exceptions, (IOError,))
195 self.assertEqual(ip.custom_exceptions, (IOError,))
196 196 ip.run_cell(u'raise IOError("foo")')
197 self.assertEquals(ip.custom_exceptions, ())
197 self.assertEqual(ip.custom_exceptions, ())
198 198 self.assertTrue("Custom TB Handler failed" in io.stderr.getvalue())
199 199 finally:
200 200 io.stderr = save_stderr
@@ -207,9 +207,9 b' class InteractiveShellTestCase(unittest.TestCase):'
207 207 # capture stderr
208 208 io.stderr = StringIO()
209 209 ip.set_custom_exc((NameError,),lambda etype,value,tb, tb_offset=None: 1)
210 self.assertEquals(ip.custom_exceptions, (NameError,))
210 self.assertEqual(ip.custom_exceptions, (NameError,))
211 211 ip.run_cell(u'a=abracadabra')
212 self.assertEquals(ip.custom_exceptions, ())
212 self.assertEqual(ip.custom_exceptions, ())
213 213 self.assertTrue("Custom TB Handler failed" in io.stderr.getvalue())
214 214 finally:
215 215 io.stderr = save_stderr
@@ -288,11 +288,11 b' class InteractiveShellTestCase(unittest.TestCase):'
288 288 # silent should force store_history=False
289 289 ip.run_cell("1", store_history=True, silent=True)
290 290
291 self.assertEquals(ec, ip.execution_count)
291 self.assertEqual(ec, ip.execution_count)
292 292 # double-check that non-silent exec did what we expected
293 293 # silent to avoid
294 294 ip.run_cell("1", store_history=True)
295 self.assertEquals(ec+1, ip.execution_count)
295 self.assertEqual(ec+1, ip.execution_count)
296 296
297 297 def test_silent_nodisplayhook(self):
298 298 """run_cell(silent=True) doesn't trigger displayhook"""
@@ -30,10 +30,10 b' class PluginTest(TestCase):'
30 30 self.manager = PluginManager()
31 31
32 32 def test_register_get(self):
33 self.assertEquals(None, self.manager.get_plugin('foo'))
33 self.assertEqual(None, self.manager.get_plugin('foo'))
34 34 foo = FooPlugin()
35 35 self.manager.register_plugin('foo', foo)
36 self.assertEquals(foo, self.manager.get_plugin('foo'))
36 self.assertEqual(foo, self.manager.get_plugin('foo'))
37 37 bar = BarPlugin()
38 38 self.assertRaises(KeyError, self.manager.register_plugin, 'foo', bar)
39 39 bad = BadPlugin()
@@ -43,4 +43,4 b' class PluginTest(TestCase):'
43 43 foo = FooPlugin()
44 44 self.manager.register_plugin('foo', foo)
45 45 self.manager.unregister_plugin('foo')
46 self.assertEquals(None, self.manager.get_plugin('foo'))
46 self.assertEqual(None, self.manager.get_plugin('foo'))
@@ -47,19 +47,19 b' class PromptTests(unittest.TestCase):'
47 47 ip.ex("foo='bar'")
48 48 self.pm.in_template = "In [{foo}]"
49 49 prompt = self.pm.render('in')
50 self.assertEquals(prompt, u'In [bar]')
50 self.assertEqual(prompt, u'In [bar]')
51 51
52 52 def test_builtins(self):
53 53 self.pm.color_scheme = 'NoColor'
54 54 self.pm.in_template = "In [{int}]"
55 55 prompt = self.pm.render('in')
56 self.assertEquals(prompt, u"In [%r]" % int)
56 self.assertEqual(prompt, u"In [%r]" % int)
57 57
58 58 def test_undefined(self):
59 59 self.pm.color_scheme = 'NoColor'
60 60 self.pm.in_template = "In [{foo_dne}]"
61 61 prompt = self.pm.render('in')
62 self.assertEquals(prompt, u"In [<ERROR: 'foo_dne' not found>]")
62 self.assertEqual(prompt, u"In [<ERROR: 'foo_dne' not found>]")
63 63
64 64 def test_render(self):
65 65 self.pm.in_template = r'\#>'
@@ -71,32 +71,32 b' class PromptTests(unittest.TestCase):'
71 71 os.chdir(td)
72 72 self.pm.in_template = r'\w [\#]'
73 73 p = self.pm.render('in', color=False)
74 self.assertEquals(p, u"%s [%i]" % (os.getcwdu(), ip.execution_count))
74 self.assertEqual(p, u"%s [%i]" % (os.getcwdu(), ip.execution_count))
75 75 os.chdir(save)
76 76
77 77 def test_lazy_eval_unicode(self):
78 78 u = u'ünicødé'
79 79 lz = LazyEvaluate(lambda : u)
80 80 # str(lz) would fail
81 self.assertEquals(unicode(lz), u)
82 self.assertEquals(format(lz), u)
81 self.assertEqual(unicode(lz), u)
82 self.assertEqual(format(lz), u)
83 83
84 84 def test_lazy_eval_nonascii_bytes(self):
85 85 u = u'ünicødé'
86 86 b = u.encode('utf8')
87 87 lz = LazyEvaluate(lambda : b)
88 88 # unicode(lz) would fail
89 self.assertEquals(str(lz), str(b))
90 self.assertEquals(format(lz), str(b))
89 self.assertEqual(str(lz), str(b))
90 self.assertEqual(format(lz), str(b))
91 91
92 92 def test_lazy_eval_float(self):
93 93 f = 0.503
94 94 lz = LazyEvaluate(lambda : f)
95 95
96 self.assertEquals(str(lz), str(f))
97 self.assertEquals(unicode(lz), unicode(f))
98 self.assertEquals(format(lz), str(f))
99 self.assertEquals(format(lz, '.1'), '0.5')
96 self.assertEqual(str(lz), str(f))
97 self.assertEqual(unicode(lz), unicode(f))
98 self.assertEqual(format(lz), str(f))
99 self.assertEqual(format(lz, '.1'), '0.5')
100 100
101 101 @dec.skip_win32
102 102 def test_cwd_x(self):
@@ -105,7 +105,7 b' class PromptTests(unittest.TestCase):'
105 105 os.chdir(os.path.expanduser('~'))
106 106 p = self.pm.render('in', color=False)
107 107 try:
108 self.assertEquals(p, '~')
108 self.assertEqual(p, '~')
109 109 finally:
110 110 os.chdir(save)
111 111
@@ -10,12 +10,12 b' class TestKernelManager(TestCase):'
10 10 km = MultiKernelManager()
11 11 kid = km.start_kernel()
12 12 self.assert_(kid in km)
13 self.assertEquals(len(km),1)
13 self.assertEqual(len(km),1)
14 14 km.kill_kernel(kid)
15 15 self.assert_(not kid in km)
16 16
17 17 kid = km.start_kernel()
18 self.assertEquals('127.0.0.1',km.get_kernel_ip(kid))
18 self.assertEqual('127.0.0.1',km.get_kernel_ip(kid))
19 19 port_dict = km.get_kernel_ports(kid)
20 20 self.assert_('stdin_port' in port_dict)
21 21 self.assert_('iopub_port' in port_dict)
@@ -14,13 +14,13 b' class TestNotebookManager(TestCase):'
14 14 def test_nb_dir(self):
15 15 with TemporaryDirectory() as td:
16 16 km = NotebookManager(notebook_dir=td)
17 self.assertEquals(km.notebook_dir, td)
17 self.assertEqual(km.notebook_dir, td)
18 18
19 19 def test_create_nb_dir(self):
20 20 with TemporaryDirectory() as td:
21 21 nbdir = os.path.join(td, 'notebooks')
22 22 km = NotebookManager(notebook_dir=nbdir)
23 self.assertEquals(km.notebook_dir, nbdir)
23 self.assertEqual(km.notebook_dir, nbdir)
24 24
25 25 def test_missing_nb_dir(self):
26 26 with TemporaryDirectory() as td:
@@ -17,20 +17,20 b' class TestAnsiCodeProcessor(unittest.TestCase):'
17 17 i = -1
18 18 for i, substring in enumerate(self.processor.split_string(string)):
19 19 if i == 0:
20 self.assertEquals(len(self.processor.actions), 1)
20 self.assertEqual(len(self.processor.actions), 1)
21 21 action = self.processor.actions[0]
22 self.assertEquals(action.action, 'erase')
23 self.assertEquals(action.area, 'screen')
24 self.assertEquals(action.erase_to, 'all')
22 self.assertEqual(action.action, 'erase')
23 self.assertEqual(action.area, 'screen')
24 self.assertEqual(action.erase_to, 'all')
25 25 elif i == 1:
26 self.assertEquals(len(self.processor.actions), 1)
26 self.assertEqual(len(self.processor.actions), 1)
27 27 action = self.processor.actions[0]
28 self.assertEquals(action.action, 'erase')
29 self.assertEquals(action.area, 'line')
30 self.assertEquals(action.erase_to, 'end')
28 self.assertEqual(action.action, 'erase')
29 self.assertEqual(action.area, 'line')
30 self.assertEqual(action.erase_to, 'end')
31 31 else:
32 32 self.fail('Too many substrings.')
33 self.assertEquals(i, 1, 'Too few substrings.')
33 self.assertEqual(i, 1, 'Too few substrings.')
34 34
35 35 def test_colors(self):
36 36 """ Do basic controls sequences for colors work?
@@ -39,17 +39,17 b' class TestAnsiCodeProcessor(unittest.TestCase):'
39 39 i = -1
40 40 for i, substring in enumerate(self.processor.split_string(string)):
41 41 if i == 0:
42 self.assertEquals(substring, 'first')
43 self.assertEquals(self.processor.foreground_color, None)
42 self.assertEqual(substring, 'first')
43 self.assertEqual(self.processor.foreground_color, None)
44 44 elif i == 1:
45 self.assertEquals(substring, 'blue')
46 self.assertEquals(self.processor.foreground_color, 4)
45 self.assertEqual(substring, 'blue')
46 self.assertEqual(self.processor.foreground_color, 4)
47 47 elif i == 2:
48 self.assertEquals(substring, 'last')
49 self.assertEquals(self.processor.foreground_color, None)
48 self.assertEqual(substring, 'last')
49 self.assertEqual(self.processor.foreground_color, None)
50 50 else:
51 51 self.fail('Too many substrings.')
52 self.assertEquals(i, 2, 'Too few substrings.')
52 self.assertEqual(i, 2, 'Too few substrings.')
53 53
54 54 def test_colors_xterm(self):
55 55 """ Do xterm-specific control sequences for colors work?
@@ -59,12 +59,12 b' class TestAnsiCodeProcessor(unittest.TestCase):'
59 59 substrings = list(self.processor.split_string(string))
60 60 desired = { 20 : (255, 255, 255),
61 61 25 : (255, 255, 255) }
62 self.assertEquals(self.processor.color_map, desired)
62 self.assertEqual(self.processor.color_map, desired)
63 63
64 64 string = '\x1b[38;5;20m\x1b[48;5;25m'
65 65 substrings = list(self.processor.split_string(string))
66 self.assertEquals(self.processor.foreground_color, 20)
67 self.assertEquals(self.processor.background_color, 25)
66 self.assertEqual(self.processor.foreground_color, 20)
67 self.assertEqual(self.processor.background_color, 25)
68 68
69 69 def test_scroll(self):
70 70 """ Do control sequences for scrolling the buffer work?
@@ -73,34 +73,34 b' class TestAnsiCodeProcessor(unittest.TestCase):'
73 73 i = -1
74 74 for i, substring in enumerate(self.processor.split_string(string)):
75 75 if i == 0:
76 self.assertEquals(len(self.processor.actions), 1)
76 self.assertEqual(len(self.processor.actions), 1)
77 77 action = self.processor.actions[0]
78 self.assertEquals(action.action, 'scroll')
79 self.assertEquals(action.dir, 'up')
80 self.assertEquals(action.unit, 'line')
81 self.assertEquals(action.count, 5)
78 self.assertEqual(action.action, 'scroll')
79 self.assertEqual(action.dir, 'up')
80 self.assertEqual(action.unit, 'line')
81 self.assertEqual(action.count, 5)
82 82 elif i == 1:
83 self.assertEquals(len(self.processor.actions), 1)
83 self.assertEqual(len(self.processor.actions), 1)
84 84 action = self.processor.actions[0]
85 self.assertEquals(action.action, 'scroll')
86 self.assertEquals(action.dir, 'down')
87 self.assertEquals(action.unit, 'line')
88 self.assertEquals(action.count, 1)
85 self.assertEqual(action.action, 'scroll')
86 self.assertEqual(action.dir, 'down')
87 self.assertEqual(action.unit, 'line')
88 self.assertEqual(action.count, 1)
89 89 else:
90 90 self.fail('Too many substrings.')
91 self.assertEquals(i, 1, 'Too few substrings.')
91 self.assertEqual(i, 1, 'Too few substrings.')
92 92
93 93 def test_formfeed(self):
94 94 """ Are formfeed characters processed correctly?
95 95 """
96 96 string = '\f' # form feed
97 self.assertEquals(list(self.processor.split_string(string)), [''])
98 self.assertEquals(len(self.processor.actions), 1)
97 self.assertEqual(list(self.processor.split_string(string)), [''])
98 self.assertEqual(len(self.processor.actions), 1)
99 99 action = self.processor.actions[0]
100 self.assertEquals(action.action, 'scroll')
101 self.assertEquals(action.dir, 'down')
102 self.assertEquals(action.unit, 'page')
103 self.assertEquals(action.count, 1)
100 self.assertEqual(action.action, 'scroll')
101 self.assertEqual(action.dir, 'down')
102 self.assertEqual(action.unit, 'page')
103 self.assertEqual(action.count, 1)
104 104
105 105 def test_carriage_return(self):
106 106 """ Are carriage return characters processed correctly?
@@ -111,8 +111,8 b' class TestAnsiCodeProcessor(unittest.TestCase):'
111 111 for split in self.processor.split_string(string):
112 112 splits.append(split)
113 113 actions.append([action.action for action in self.processor.actions])
114 self.assertEquals(splits, ['foo', None, 'bar'])
115 self.assertEquals(actions, [[], ['carriage-return'], []])
114 self.assertEqual(splits, ['foo', None, 'bar'])
115 self.assertEqual(actions, [[], ['carriage-return'], []])
116 116
117 117 def test_carriage_return_newline(self):
118 118 """transform CRLF to LF"""
@@ -123,8 +123,8 b' class TestAnsiCodeProcessor(unittest.TestCase):'
123 123 for split in self.processor.split_string(string):
124 124 splits.append(split)
125 125 actions.append([action.action for action in self.processor.actions])
126 self.assertEquals(splits, ['foo', None, 'bar', '\r\n', 'cat', '\r\n', '\n'])
127 self.assertEquals(actions, [[], ['carriage-return'], [], ['newline'], [], ['newline'], ['newline']])
126 self.assertEqual(splits, ['foo', None, 'bar', '\r\n', 'cat', '\r\n', '\n'])
127 self.assertEqual(actions, [[], ['carriage-return'], [], ['newline'], [], ['newline'], ['newline']])
128 128
129 129 def test_beep(self):
130 130 """ Are beep characters processed correctly?
@@ -135,8 +135,8 b' class TestAnsiCodeProcessor(unittest.TestCase):'
135 135 for split in self.processor.split_string(string):
136 136 splits.append(split)
137 137 actions.append([action.action for action in self.processor.actions])
138 self.assertEquals(splits, ['foo', None, 'bar'])
139 self.assertEquals(actions, [[], ['beep'], []])
138 self.assertEqual(splits, ['foo', None, 'bar'])
139 self.assertEqual(actions, [[], ['beep'], []])
140 140
141 141 def test_backspace(self):
142 142 """ Are backspace characters processed correctly?
@@ -147,8 +147,8 b' class TestAnsiCodeProcessor(unittest.TestCase):'
147 147 for split in self.processor.split_string(string):
148 148 splits.append(split)
149 149 actions.append([action.action for action in self.processor.actions])
150 self.assertEquals(splits, ['foo', None, 'bar'])
151 self.assertEquals(actions, [[], ['backspace'], []])
150 self.assertEqual(splits, ['foo', None, 'bar'])
151 self.assertEqual(actions, [[], ['backspace'], []])
152 152
153 153 def test_combined(self):
154 154 """ Are CR and BS characters processed correctly in combination?
@@ -163,8 +163,8 b' class TestAnsiCodeProcessor(unittest.TestCase):'
163 163 for split in self.processor.split_string(string):
164 164 splits.append(split)
165 165 actions.append([action.action for action in self.processor.actions])
166 self.assertEquals(splits, ['abc', None, 'def', None])
167 self.assertEquals(actions, [[], ['carriage-return'], [], ['backspace']])
166 self.assertEqual(splits, ['abc', None, 'def', None])
167 self.assertEqual(actions, [[], ['carriage-return'], [], ['backspace']])
168 168
169 169
170 170 if __name__ == '__main__':
@@ -16,31 +16,31 b' class TestCompletionLexer(unittest.TestCase):'
16 16 lexer = CompletionLexer(PythonLexer())
17 17
18 18 # Test simplest case.
19 self.assertEquals(lexer.get_context("foo.bar.baz"),
19 self.assertEqual(lexer.get_context("foo.bar.baz"),
20 20 [ "foo", "bar", "baz" ])
21 21
22 22 # Test trailing period.
23 self.assertEquals(lexer.get_context("foo.bar."), [ "foo", "bar", "" ])
23 self.assertEqual(lexer.get_context("foo.bar."), [ "foo", "bar", "" ])
24 24
25 25 # Test with prompt present.
26 self.assertEquals(lexer.get_context(">>> foo.bar.baz"),
26 self.assertEqual(lexer.get_context(">>> foo.bar.baz"),
27 27 [ "foo", "bar", "baz" ])
28 28
29 29 # Test spacing in name.
30 self.assertEquals(lexer.get_context("foo.bar. baz"), [ "baz" ])
30 self.assertEqual(lexer.get_context("foo.bar. baz"), [ "baz" ])
31 31
32 32 # Test parenthesis.
33 self.assertEquals(lexer.get_context("foo("), [])
33 self.assertEqual(lexer.get_context("foo("), [])
34 34
35 35 def testC(self):
36 36 """ Does the CompletionLexer work for C/C++?
37 37 """
38 38 lexer = CompletionLexer(CLexer())
39 self.assertEquals(lexer.get_context("foo.bar"), [ "foo", "bar" ])
40 self.assertEquals(lexer.get_context("foo->bar"), [ "foo", "bar" ])
39 self.assertEqual(lexer.get_context("foo.bar"), [ "foo", "bar" ])
40 self.assertEqual(lexer.get_context("foo->bar"), [ "foo", "bar" ])
41 41
42 42 lexer = CompletionLexer(CppLexer())
43 self.assertEquals(lexer.get_context("Foo::Bar"), [ "Foo", "Bar" ])
43 self.assertEqual(lexer.get_context("Foo::Bar"), [ "Foo", "Bar" ])
44 44
45 45
46 46 if __name__ == '__main__':
@@ -37,6 +37,6 b' class TestConsoleWidget(unittest.TestCase):'
37 37 w._insert_plain_text(cursor, text)
38 38 cursor.select(cursor.Document)
39 39 selection = cursor.selectedText()
40 self.assertEquals(expected_outputs[i], selection)
40 self.assertEqual(expected_outputs[i], selection)
41 41 # clear all the text
42 42 cursor.insertText('')
@@ -59,10 +59,10 b' class InteractiveShellTestCase(unittest.TestCase):'
59 59 hlen_b4_cell = ip._replace_rlhist_multiline(u'sourc€\nsource2',
60 60 hlen_b4_cell)
61 61
62 self.assertEquals(ip.readline.get_current_history_length(),
62 self.assertEqual(ip.readline.get_current_history_length(),
63 63 hlen_b4_cell)
64 64 hist = self.rl_hist_entries(ip.readline, 2)
65 self.assertEquals(hist, ghist)
65 self.assertEqual(hist, ghist)
66 66
67 67 @skipif(not get_ipython().has_readline, 'no readline')
68 68 @skipif(not hasattr(get_ipython().readline, 'remove_history_item'),
@@ -74,7 +74,7 b' class InteractiveShellTestCase(unittest.TestCase):'
74 74 hlen_b4_cell = ip.readline.get_current_history_length()
75 75 hlen_b4_cell = ip._replace_rlhist_multiline(u'sourc€', hlen_b4_cell)
76 76
77 self.assertEquals(hlen_b4_cell,
77 self.assertEqual(hlen_b4_cell,
78 78 ip.readline.get_current_history_length())
79 79
80 80 @skipif(not get_ipython().has_readline, 'no readline')
@@ -95,10 +95,10 b' class InteractiveShellTestCase(unittest.TestCase):'
95 95 hlen_b4_cell = ip._replace_rlhist_multiline(u'sourc€\nsource2',
96 96 hlen_b4_cell)
97 97
98 self.assertEquals(ip.readline.get_current_history_length(),
98 self.assertEqual(ip.readline.get_current_history_length(),
99 99 hlen_b4_cell)
100 100 hist = self.rl_hist_entries(ip.readline, 2)
101 self.assertEquals(hist, ghist)
101 self.assertEqual(hist, ghist)
102 102
103 103
104 104 @skipif(not get_ipython().has_readline, 'no readline')
@@ -123,14 +123,14 b' class InteractiveShellTestCase(unittest.TestCase):'
123 123 hlen_b4_cell = ip._replace_rlhist_multiline(u'l€ne3\nline4',
124 124 hlen_b4_cell)
125 125
126 self.assertEquals(ip.readline.get_current_history_length(),
126 self.assertEqual(ip.readline.get_current_history_length(),
127 127 hlen_b4_cell)
128 128 hist = self.rl_hist_entries(ip.readline, 3)
129 129 expected = [u'line0', u'l€ne1\nline2', u'l€ne3\nline4']
130 130 # perform encoding, in case of casting due to ASCII locale
131 131 enc = sys.stdin.encoding or "utf-8"
132 132 expected = [ py3compat.unicode_to_str(e, enc) for e in expected ]
133 self.assertEquals(hist, expected)
133 self.assertEqual(hist, expected)
134 134
135 135
136 136 @skipif(not get_ipython().has_readline, 'no readline')
@@ -160,7 +160,7 b' class InteractiveShellTestCase(unittest.TestCase):'
160 160 ip.readline.add_history('line4')
161 161 hlen_b4_cell = ip._replace_rlhist_multiline(u'line4', hlen_b4_cell)
162 162
163 self.assertEquals(ip.readline.get_current_history_length(),
163 self.assertEqual(ip.readline.get_current_history_length(),
164 164 hlen_b4_cell)
165 165 hist = self.rl_hist_entries(ip.readline, 4)
166 166 # expect no empty cells in history
@@ -168,4 +168,4 b' class InteractiveShellTestCase(unittest.TestCase):'
168 168 # perform encoding, in case of casting due to ASCII locale
169 169 enc = sys.stdin.encoding or "utf-8"
170 170 expected = [ py3compat.unicode_to_str(e, enc) for e in expected ]
171 self.assertEquals(hist, expected)
171 self.assertEqual(hist, expected)
@@ -8,7 +8,7 b' class TestJSON(TestCase):'
8 8
9 9 def test_roundtrip(self):
10 10 s = writes(nb0)
11 self.assertEquals(reads(s),nb0)
11 self.assertEqual(reads(s),nb0)
12 12
13 13
14 14
@@ -9,33 +9,33 b' class TestCell(TestCase):'
9 9
10 10 def test_empty_code_cell(self):
11 11 cc = new_code_cell()
12 self.assertEquals(cc.cell_type,'code')
13 self.assertEquals('code' not in cc, True)
14 self.assertEquals('prompt_number' not in cc, True)
12 self.assertEqual(cc.cell_type,'code')
13 self.assertEqual('code' not in cc, True)
14 self.assertEqual('prompt_number' not in cc, True)
15 15
16 16 def test_code_cell(self):
17 17 cc = new_code_cell(code='a=10', prompt_number=0)
18 self.assertEquals(cc.code, u'a=10')
19 self.assertEquals(cc.prompt_number, 0)
18 self.assertEqual(cc.code, u'a=10')
19 self.assertEqual(cc.prompt_number, 0)
20 20
21 21 def test_empty_text_cell(self):
22 22 tc = new_text_cell()
23 self.assertEquals(tc.cell_type, 'text')
24 self.assertEquals('text' not in tc, True)
23 self.assertEqual(tc.cell_type, 'text')
24 self.assertEqual('text' not in tc, True)
25 25
26 26 def test_text_cell(self):
27 27 tc = new_text_cell('hi')
28 self.assertEquals(tc.text, u'hi')
28 self.assertEqual(tc.text, u'hi')
29 29
30 30
31 31 class TestNotebook(TestCase):
32 32
33 33 def test_empty_notebook(self):
34 34 nb = new_notebook()
35 self.assertEquals(nb.cells, [])
35 self.assertEqual(nb.cells, [])
36 36
37 37 def test_notebooke(self):
38 38 cells = [new_code_cell(),new_text_cell()]
39 39 nb = new_notebook(cells=cells)
40 self.assertEquals(nb.cells,cells)
40 self.assertEqual(nb.cells,cells)
41 41
@@ -15,20 +15,20 b' class TestJSON(TestCase):'
15 15 # print pprint.pformat(reads(s),indent=2)
16 16 # print
17 17 # print s
18 self.assertEquals(reads(s),nb0)
18 self.assertEqual(reads(s),nb0)
19 19
20 20 def test_roundtrip_nosplit(self):
21 21 """Ensure that multiline blobs are still readable"""
22 22 # ensures that notebooks written prior to splitlines change
23 23 # are still readable.
24 24 s = writes(nb0, split_lines=False)
25 self.assertEquals(reads(s),nb0)
25 self.assertEqual(reads(s),nb0)
26 26
27 27 def test_roundtrip_split(self):
28 28 """Ensure that splitting multiline blocks is safe"""
29 29 # This won't differ from test_roundtrip unless the default changes
30 30 s = writes(nb0, split_lines=True)
31 self.assertEquals(reads(s),nb0)
31 self.assertEqual(reads(s),nb0)
32 32
33 33
34 34
@@ -10,104 +10,104 b' class TestCell(TestCase):'
10 10
11 11 def test_empty_code_cell(self):
12 12 cc = new_code_cell()
13 self.assertEquals(cc.cell_type,u'code')
14 self.assertEquals(u'input' not in cc, True)
15 self.assertEquals(u'prompt_number' not in cc, True)
16 self.assertEquals(cc.outputs, [])
17 self.assertEquals(cc.collapsed, False)
13 self.assertEqual(cc.cell_type,u'code')
14 self.assertEqual(u'input' not in cc, True)
15 self.assertEqual(u'prompt_number' not in cc, True)
16 self.assertEqual(cc.outputs, [])
17 self.assertEqual(cc.collapsed, False)
18 18
19 19 def test_code_cell(self):
20 20 cc = new_code_cell(input='a=10', prompt_number=0, collapsed=True)
21 21 cc.outputs = [new_output(output_type=u'pyout',
22 22 output_svg=u'foo',output_text=u'10',prompt_number=0)]
23 self.assertEquals(cc.input, u'a=10')
24 self.assertEquals(cc.prompt_number, 0)
25 self.assertEquals(cc.language, u'python')
26 self.assertEquals(cc.outputs[0].svg, u'foo')
27 self.assertEquals(cc.outputs[0].text, u'10')
28 self.assertEquals(cc.outputs[0].prompt_number, 0)
29 self.assertEquals(cc.collapsed, True)
23 self.assertEqual(cc.input, u'a=10')
24 self.assertEqual(cc.prompt_number, 0)
25 self.assertEqual(cc.language, u'python')
26 self.assertEqual(cc.outputs[0].svg, u'foo')
27 self.assertEqual(cc.outputs[0].text, u'10')
28 self.assertEqual(cc.outputs[0].prompt_number, 0)
29 self.assertEqual(cc.collapsed, True)
30 30
31 31 def test_pyerr(self):
32 32 o = new_output(output_type=u'pyerr', etype=u'NameError',
33 33 evalue=u'Name not found', traceback=[u'frame 0', u'frame 1', u'frame 2']
34 34 )
35 self.assertEquals(o.output_type, u'pyerr')
36 self.assertEquals(o.etype, u'NameError')
37 self.assertEquals(o.evalue, u'Name not found')
38 self.assertEquals(o.traceback, [u'frame 0', u'frame 1', u'frame 2'])
35 self.assertEqual(o.output_type, u'pyerr')
36 self.assertEqual(o.etype, u'NameError')
37 self.assertEqual(o.evalue, u'Name not found')
38 self.assertEqual(o.traceback, [u'frame 0', u'frame 1', u'frame 2'])
39 39
40 40 def test_empty_html_cell(self):
41 41 tc = new_text_cell(u'html')
42 self.assertEquals(tc.cell_type, u'html')
43 self.assertEquals(u'source' not in tc, True)
44 self.assertEquals(u'rendered' not in tc, True)
42 self.assertEqual(tc.cell_type, u'html')
43 self.assertEqual(u'source' not in tc, True)
44 self.assertEqual(u'rendered' not in tc, True)
45 45
46 46 def test_html_cell(self):
47 47 tc = new_text_cell(u'html', 'hi', 'hi')
48 self.assertEquals(tc.source, u'hi')
49 self.assertEquals(tc.rendered, u'hi')
48 self.assertEqual(tc.source, u'hi')
49 self.assertEqual(tc.rendered, u'hi')
50 50
51 51 def test_empty_markdown_cell(self):
52 52 tc = new_text_cell(u'markdown')
53 self.assertEquals(tc.cell_type, u'markdown')
54 self.assertEquals(u'source' not in tc, True)
55 self.assertEquals(u'rendered' not in tc, True)
53 self.assertEqual(tc.cell_type, u'markdown')
54 self.assertEqual(u'source' not in tc, True)
55 self.assertEqual(u'rendered' not in tc, True)
56 56
57 57 def test_markdown_cell(self):
58 58 tc = new_text_cell(u'markdown', 'hi', 'hi')
59 self.assertEquals(tc.source, u'hi')
60 self.assertEquals(tc.rendered, u'hi')
59 self.assertEqual(tc.source, u'hi')
60 self.assertEqual(tc.rendered, u'hi')
61 61
62 62
63 63 class TestWorksheet(TestCase):
64 64
65 65 def test_empty_worksheet(self):
66 66 ws = new_worksheet()
67 self.assertEquals(ws.cells,[])
68 self.assertEquals(u'name' not in ws, True)
67 self.assertEqual(ws.cells,[])
68 self.assertEqual(u'name' not in ws, True)
69 69
70 70 def test_worksheet(self):
71 71 cells = [new_code_cell(), new_text_cell(u'html')]
72 72 ws = new_worksheet(cells=cells,name=u'foo')
73 self.assertEquals(ws.cells,cells)
74 self.assertEquals(ws.name,u'foo')
73 self.assertEqual(ws.cells,cells)
74 self.assertEqual(ws.name,u'foo')
75 75
76 76 class TestNotebook(TestCase):
77 77
78 78 def test_empty_notebook(self):
79 79 nb = new_notebook()
80 self.assertEquals(nb.worksheets, [])
81 self.assertEquals(nb.metadata, NotebookNode())
82 self.assertEquals(nb.nbformat,2)
80 self.assertEqual(nb.worksheets, [])
81 self.assertEqual(nb.metadata, NotebookNode())
82 self.assertEqual(nb.nbformat,2)
83 83
84 84 def test_notebook(self):
85 85 worksheets = [new_worksheet(),new_worksheet()]
86 86 metadata = new_metadata(name=u'foo')
87 87 nb = new_notebook(metadata=metadata,worksheets=worksheets)
88 self.assertEquals(nb.metadata.name,u'foo')
89 self.assertEquals(nb.worksheets,worksheets)
90 self.assertEquals(nb.nbformat,2)
88 self.assertEqual(nb.metadata.name,u'foo')
89 self.assertEqual(nb.worksheets,worksheets)
90 self.assertEqual(nb.nbformat,2)
91 91
92 92 class TestMetadata(TestCase):
93 93
94 94 def test_empty_metadata(self):
95 95 md = new_metadata()
96 self.assertEquals(u'name' not in md, True)
97 self.assertEquals(u'authors' not in md, True)
98 self.assertEquals(u'license' not in md, True)
99 self.assertEquals(u'saved' not in md, True)
100 self.assertEquals(u'modified' not in md, True)
101 self.assertEquals(u'gistid' not in md, True)
96 self.assertEqual(u'name' not in md, True)
97 self.assertEqual(u'authors' not in md, True)
98 self.assertEqual(u'license' not in md, True)
99 self.assertEqual(u'saved' not in md, True)
100 self.assertEqual(u'modified' not in md, True)
101 self.assertEqual(u'gistid' not in md, True)
102 102
103 103 def test_metadata(self):
104 104 authors = [new_author(name='Bart Simpson',email='bsimpson@fox.com')]
105 105 md = new_metadata(name=u'foo',license=u'BSD',created=u'today',
106 106 modified=u'now',gistid=u'21341231',authors=authors)
107 self.assertEquals(md.name, u'foo')
108 self.assertEquals(md.license, u'BSD')
109 self.assertEquals(md.created, u'today')
110 self.assertEquals(md.modified, u'now')
111 self.assertEquals(md.gistid, u'21341231')
112 self.assertEquals(md.authors, authors)
107 self.assertEqual(md.name, u'foo')
108 self.assertEqual(md.license, u'BSD')
109 self.assertEqual(md.created, u'today')
110 self.assertEqual(md.modified, u'now')
111 self.assertEqual(md.gistid, u'21341231')
112 self.assertEqual(md.authors, authors)
113 113
@@ -13,5 +13,5 b' class TestPy(TestCase):'
13 13
14 14 def test_write(self):
15 15 s = writes(nb0)
16 self.assertEquals(s,nb0_py)
16 self.assertEqual(s,nb0_py)
17 17
@@ -33,12 +33,12 b' class NBFormatTest:'
33 33 shutil.rmtree(self.wd)
34 34
35 35 def assertNBEquals(self, nba, nbb):
36 self.assertEquals(nba, nbb)
36 self.assertEqual(nba, nbb)
37 37
38 38 def test_writes(self):
39 39 s = self.mod.writes(nb0)
40 40 if self.nb0_ref:
41 self.assertEquals(s, self.nb0_ref)
41 self.assertEqual(s, self.nb0_ref)
42 42
43 43 def test_reads(self):
44 44 s = self.mod.writes(nb0)
@@ -21,13 +21,13 b' class TestJSON(formattest.NBFormatTest, TestCase):'
21 21 # ensures that notebooks written prior to splitlines change
22 22 # are still readable.
23 23 s = writes(nb0, split_lines=False)
24 self.assertEquals(nbjson.reads(s),nb0)
24 self.assertEqual(nbjson.reads(s),nb0)
25 25
26 26 def test_roundtrip_split(self):
27 27 """Ensure that splitting multiline blocks is safe"""
28 28 # This won't differ from test_roundtrip unless the default changes
29 29 s = writes(nb0, split_lines=True)
30 self.assertEquals(nbjson.reads(s),nb0)
30 self.assertEqual(nbjson.reads(s),nb0)
31 31
32 32
33 33
@@ -10,134 +10,134 b' class TestCell(TestCase):'
10 10
11 11 def test_empty_code_cell(self):
12 12 cc = new_code_cell()
13 self.assertEquals(cc.cell_type,u'code')
14 self.assertEquals(u'input' not in cc, True)
15 self.assertEquals(u'prompt_number' not in cc, True)
16 self.assertEquals(cc.outputs, [])
17 self.assertEquals(cc.collapsed, False)
13 self.assertEqual(cc.cell_type,u'code')
14 self.assertEqual(u'input' not in cc, True)
15 self.assertEqual(u'prompt_number' not in cc, True)
16 self.assertEqual(cc.outputs, [])
17 self.assertEqual(cc.collapsed, False)
18 18
19 19 def test_code_cell(self):
20 20 cc = new_code_cell(input='a=10', prompt_number=0, collapsed=True)
21 21 cc.outputs = [new_output(output_type=u'pyout',
22 22 output_svg=u'foo',output_text=u'10',prompt_number=0)]
23 self.assertEquals(cc.input, u'a=10')
24 self.assertEquals(cc.prompt_number, 0)
25 self.assertEquals(cc.language, u'python')
26 self.assertEquals(cc.outputs[0].svg, u'foo')
27 self.assertEquals(cc.outputs[0].text, u'10')
28 self.assertEquals(cc.outputs[0].prompt_number, 0)
29 self.assertEquals(cc.collapsed, True)
23 self.assertEqual(cc.input, u'a=10')
24 self.assertEqual(cc.prompt_number, 0)
25 self.assertEqual(cc.language, u'python')
26 self.assertEqual(cc.outputs[0].svg, u'foo')
27 self.assertEqual(cc.outputs[0].text, u'10')
28 self.assertEqual(cc.outputs[0].prompt_number, 0)
29 self.assertEqual(cc.collapsed, True)
30 30
31 31 def test_pyerr(self):
32 32 o = new_output(output_type=u'pyerr', etype=u'NameError',
33 33 evalue=u'Name not found', traceback=[u'frame 0', u'frame 1', u'frame 2']
34 34 )
35 self.assertEquals(o.output_type, u'pyerr')
36 self.assertEquals(o.etype, u'NameError')
37 self.assertEquals(o.evalue, u'Name not found')
38 self.assertEquals(o.traceback, [u'frame 0', u'frame 1', u'frame 2'])
35 self.assertEqual(o.output_type, u'pyerr')
36 self.assertEqual(o.etype, u'NameError')
37 self.assertEqual(o.evalue, u'Name not found')
38 self.assertEqual(o.traceback, [u'frame 0', u'frame 1', u'frame 2'])
39 39
40 40 def test_empty_html_cell(self):
41 41 tc = new_text_cell(u'html')
42 self.assertEquals(tc.cell_type, u'html')
43 self.assertEquals(u'source' not in tc, True)
44 self.assertEquals(u'rendered' not in tc, True)
42 self.assertEqual(tc.cell_type, u'html')
43 self.assertEqual(u'source' not in tc, True)
44 self.assertEqual(u'rendered' not in tc, True)
45 45
46 46 def test_html_cell(self):
47 47 tc = new_text_cell(u'html', 'hi', 'hi')
48 self.assertEquals(tc.source, u'hi')
49 self.assertEquals(tc.rendered, u'hi')
48 self.assertEqual(tc.source, u'hi')
49 self.assertEqual(tc.rendered, u'hi')
50 50
51 51 def test_empty_markdown_cell(self):
52 52 tc = new_text_cell(u'markdown')
53 self.assertEquals(tc.cell_type, u'markdown')
54 self.assertEquals(u'source' not in tc, True)
55 self.assertEquals(u'rendered' not in tc, True)
53 self.assertEqual(tc.cell_type, u'markdown')
54 self.assertEqual(u'source' not in tc, True)
55 self.assertEqual(u'rendered' not in tc, True)
56 56
57 57 def test_markdown_cell(self):
58 58 tc = new_text_cell(u'markdown', 'hi', 'hi')
59 self.assertEquals(tc.source, u'hi')
60 self.assertEquals(tc.rendered, u'hi')
59 self.assertEqual(tc.source, u'hi')
60 self.assertEqual(tc.rendered, u'hi')
61 61
62 62 def test_empty_raw_cell(self):
63 63 tc = new_text_cell(u'raw')
64 self.assertEquals(tc.cell_type, u'raw')
65 self.assertEquals(u'source' not in tc, True)
66 self.assertEquals(u'rendered' not in tc, True)
64 self.assertEqual(tc.cell_type, u'raw')
65 self.assertEqual(u'source' not in tc, True)
66 self.assertEqual(u'rendered' not in tc, True)
67 67
68 68 def test_raw_cell(self):
69 69 tc = new_text_cell(u'raw', 'hi', 'hi')
70 self.assertEquals(tc.source, u'hi')
71 self.assertEquals(tc.rendered, u'hi')
70 self.assertEqual(tc.source, u'hi')
71 self.assertEqual(tc.rendered, u'hi')
72 72
73 73 def test_empty_heading_cell(self):
74 74 tc = new_heading_cell()
75 self.assertEquals(tc.cell_type, u'heading')
76 self.assertEquals(u'source' not in tc, True)
77 self.assertEquals(u'rendered' not in tc, True)
75 self.assertEqual(tc.cell_type, u'heading')
76 self.assertEqual(u'source' not in tc, True)
77 self.assertEqual(u'rendered' not in tc, True)
78 78
79 79 def test_heading_cell(self):
80 80 tc = new_heading_cell(u'hi', u'hi', level=2)
81 self.assertEquals(tc.source, u'hi')
82 self.assertEquals(tc.rendered, u'hi')
83 self.assertEquals(tc.level, 2)
81 self.assertEqual(tc.source, u'hi')
82 self.assertEqual(tc.rendered, u'hi')
83 self.assertEqual(tc.level, 2)
84 84
85 85
86 86 class TestWorksheet(TestCase):
87 87
88 88 def test_empty_worksheet(self):
89 89 ws = new_worksheet()
90 self.assertEquals(ws.cells,[])
91 self.assertEquals(u'name' not in ws, True)
90 self.assertEqual(ws.cells,[])
91 self.assertEqual(u'name' not in ws, True)
92 92
93 93 def test_worksheet(self):
94 94 cells = [new_code_cell(), new_text_cell(u'html')]
95 95 ws = new_worksheet(cells=cells,name=u'foo')
96 self.assertEquals(ws.cells,cells)
97 self.assertEquals(ws.name,u'foo')
96 self.assertEqual(ws.cells,cells)
97 self.assertEqual(ws.name,u'foo')
98 98
99 99 class TestNotebook(TestCase):
100 100
101 101 def test_empty_notebook(self):
102 102 nb = new_notebook()
103 self.assertEquals(nb.worksheets, [])
104 self.assertEquals(nb.metadata, NotebookNode())
105 self.assertEquals(nb.nbformat,nbformat)
103 self.assertEqual(nb.worksheets, [])
104 self.assertEqual(nb.metadata, NotebookNode())
105 self.assertEqual(nb.nbformat,nbformat)
106 106
107 107 def test_notebook(self):
108 108 worksheets = [new_worksheet(),new_worksheet()]
109 109 metadata = new_metadata(name=u'foo')
110 110 nb = new_notebook(metadata=metadata,worksheets=worksheets)
111 self.assertEquals(nb.metadata.name,u'foo')
112 self.assertEquals(nb.worksheets,worksheets)
113 self.assertEquals(nb.nbformat,nbformat)
111 self.assertEqual(nb.metadata.name,u'foo')
112 self.assertEqual(nb.worksheets,worksheets)
113 self.assertEqual(nb.nbformat,nbformat)
114 114
115 115 def test_notebook_name(self):
116 116 worksheets = [new_worksheet(),new_worksheet()]
117 117 nb = new_notebook(name='foo',worksheets=worksheets)
118 self.assertEquals(nb.metadata.name,u'foo')
119 self.assertEquals(nb.worksheets,worksheets)
120 self.assertEquals(nb.nbformat,nbformat)
118 self.assertEqual(nb.metadata.name,u'foo')
119 self.assertEqual(nb.worksheets,worksheets)
120 self.assertEqual(nb.nbformat,nbformat)
121 121
122 122 class TestMetadata(TestCase):
123 123
124 124 def test_empty_metadata(self):
125 125 md = new_metadata()
126 self.assertEquals(u'name' not in md, True)
127 self.assertEquals(u'authors' not in md, True)
128 self.assertEquals(u'license' not in md, True)
129 self.assertEquals(u'saved' not in md, True)
130 self.assertEquals(u'modified' not in md, True)
131 self.assertEquals(u'gistid' not in md, True)
126 self.assertEqual(u'name' not in md, True)
127 self.assertEqual(u'authors' not in md, True)
128 self.assertEqual(u'license' not in md, True)
129 self.assertEqual(u'saved' not in md, True)
130 self.assertEqual(u'modified' not in md, True)
131 self.assertEqual(u'gistid' not in md, True)
132 132
133 133 def test_metadata(self):
134 134 authors = [new_author(name='Bart Simpson',email='bsimpson@fox.com')]
135 135 md = new_metadata(name=u'foo',license=u'BSD',created=u'today',
136 136 modified=u'now',gistid=u'21341231',authors=authors)
137 self.assertEquals(md.name, u'foo')
138 self.assertEquals(md.license, u'BSD')
139 self.assertEquals(md.created, u'today')
140 self.assertEquals(md.modified, u'now')
141 self.assertEquals(md.gistid, u'21341231')
142 self.assertEquals(md.authors, authors)
137 self.assertEqual(md.name, u'foo')
138 self.assertEqual(md.license, u'BSD')
139 self.assertEqual(md.created, u'today')
140 self.assertEqual(md.modified, u'now')
141 self.assertEqual(md.gistid, u'21341231')
142 self.assertEqual(md.authors, authors)
143 143
@@ -36,7 +36,7 b' class TestPy(formattest.NBFormatTest, TestCase):'
36 36 # newlines in blocks through roundtrip
37 37 da = da.strip('\n')
38 38 db = db.strip('\n')
39 self.assertEquals(da, db)
39 self.assertEqual(da, db)
40 40 return True
41 41
42 42 def assertNBEquals(self, nba, nbb):
@@ -142,7 +142,7 b' class ClusterTestCase(BaseZMQTestCase):'
142 142 except error.CompositeError as e:
143 143 e.raise_exception()
144 144 except error.RemoteError as e:
145 self.assertEquals(etype.__name__, e.ename, "Should have raised %r, but raised %r"%(etype.__name__, e.ename))
145 self.assertEqual(etype.__name__, e.ename, "Should have raised %r, but raised %r"%(etype.__name__, e.ename))
146 146 else:
147 147 self.fail("should have raised a RemoteError")
148 148
@@ -39,25 +39,25 b' class AsyncResultTest(ClusterTestCase):'
39 39 """various one-target views get the right value for single_result"""
40 40 eid = self.client.ids[-1]
41 41 ar = self.client[eid].apply_async(lambda : 42)
42 self.assertEquals(ar.get(), 42)
42 self.assertEqual(ar.get(), 42)
43 43 ar = self.client[[eid]].apply_async(lambda : 42)
44 self.assertEquals(ar.get(), [42])
44 self.assertEqual(ar.get(), [42])
45 45 ar = self.client[-1:].apply_async(lambda : 42)
46 self.assertEquals(ar.get(), [42])
46 self.assertEqual(ar.get(), [42])
47 47
48 48 def test_get_after_done(self):
49 49 ar = self.client[-1].apply_async(lambda : 42)
50 50 ar.wait()
51 51 self.assertTrue(ar.ready())
52 self.assertEquals(ar.get(), 42)
53 self.assertEquals(ar.get(), 42)
52 self.assertEqual(ar.get(), 42)
53 self.assertEqual(ar.get(), 42)
54 54
55 55 def test_get_before_done(self):
56 56 ar = self.client[-1].apply_async(wait, 0.1)
57 57 self.assertRaises(TimeoutError, ar.get, 0)
58 58 ar.wait(0)
59 59 self.assertFalse(ar.ready())
60 self.assertEquals(ar.get(), 0.1)
60 self.assertEqual(ar.get(), 0.1)
61 61
62 62 def test_get_after_error(self):
63 63 ar = self.client[-1].apply_async(lambda : 1/0)
@@ -69,11 +69,11 b' class AsyncResultTest(ClusterTestCase):'
69 69 def test_get_dict(self):
70 70 n = len(self.client)
71 71 ar = self.client[:].apply_async(lambda : 5)
72 self.assertEquals(ar.get(), [5]*n)
72 self.assertEqual(ar.get(), [5]*n)
73 73 d = ar.get_dict()
74 self.assertEquals(sorted(d.keys()), sorted(self.client.ids))
74 self.assertEqual(sorted(d.keys()), sorted(self.client.ids))
75 75 for eid,r in d.iteritems():
76 self.assertEquals(r, 5)
76 self.assertEqual(r, 5)
77 77
78 78 def test_list_amr(self):
79 79 ar = self.client.load_balanced_view().map_async(wait, [0.1]*5)
@@ -93,7 +93,7 b' class AsyncResultTest(ClusterTestCase):'
93 93 self.assertRaises(AttributeError, lambda : ar.__length_hint__())
94 94 self.assertRaises(AttributeError, lambda : ar.foo)
95 95 self.assertTrue(isinstance(ar.engine_id, list))
96 self.assertEquals(ar.engine_id, ar['engine_id'])
96 self.assertEqual(ar.engine_id, ar['engine_id'])
97 97 self.assertFalse(hasattr(ar, '__length_hint__'))
98 98 self.assertFalse(hasattr(ar, 'foo'))
99 99 self.assertTrue(hasattr(ar, 'engine_id'))
@@ -105,7 +105,7 b' class AsyncResultTest(ClusterTestCase):'
105 105 ar.get(5)
106 106 self.assertRaises(KeyError, lambda : ar['foo'])
107 107 self.assertTrue(isinstance(ar['engine_id'], list))
108 self.assertEquals(ar.engine_id, ar['engine_id'])
108 self.assertEqual(ar.engine_id, ar['engine_id'])
109 109
110 110 def test_single_result(self):
111 111 ar = self.client[-1].apply_async(wait, 0.5)
@@ -114,7 +114,7 b' class AsyncResultTest(ClusterTestCase):'
114 114 self.assertTrue(ar.get(5) == 0.5)
115 115 self.assertTrue(isinstance(ar['engine_id'], int))
116 116 self.assertTrue(isinstance(ar.engine_id, int))
117 self.assertEquals(ar.engine_id, ar['engine_id'])
117 self.assertEqual(ar.engine_id, ar['engine_id'])
118 118
119 119 def test_abort(self):
120 120 e = self.client[-1]
@@ -127,11 +127,11 b' class AsyncResultTest(ClusterTestCase):'
127 127 def test_len(self):
128 128 v = self.client.load_balanced_view()
129 129 ar = v.map_async(lambda x: x, range(10))
130 self.assertEquals(len(ar), 10)
130 self.assertEqual(len(ar), 10)
131 131 ar = v.apply_async(lambda x: x, range(10))
132 self.assertEquals(len(ar), 1)
132 self.assertEqual(len(ar), 1)
133 133 ar = self.client[:].apply_async(lambda x: x, range(10))
134 self.assertEquals(len(ar), len(self.client.ids))
134 self.assertEqual(len(ar), len(self.client.ids))
135 135
136 136 def test_wall_time_single(self):
137 137 v = self.client.load_balanced_view()
@@ -199,7 +199,7 b' class AsyncResultTest(ClusterTestCase):'
199 199 self.assertTrue(hr.elapsed > 0., "got bad elapsed: %s" % hr.elapsed)
200 200 hr.get(1)
201 201 self.assertTrue(hr.wall_time < ar.wall_time + 0.2, "got bad wall_time: %s > %s" % (hr.wall_time, ar.wall_time))
202 self.assertEquals(hr.serial_time, ar.serial_time)
202 self.assertEqual(hr.serial_time, ar.serial_time)
203 203 finally:
204 204 rc2.close()
205 205
@@ -212,15 +212,15 b' class AsyncResultTest(ClusterTestCase):'
212 212 ar.get(5)
213 213 with capture_output() as io:
214 214 ar.display_outputs()
215 self.assertEquals(io.stderr, '')
216 self.assertEquals('5555\n', io.stdout)
215 self.assertEqual(io.stderr, '')
216 self.assertEqual('5555\n', io.stdout)
217 217
218 218 ar = v.execute("a=5")
219 219 ar.get(5)
220 220 with capture_output() as io:
221 221 ar.display_outputs()
222 self.assertEquals(io.stderr, '')
223 self.assertEquals(io.stdout, '')
222 self.assertEqual(io.stderr, '')
223 self.assertEqual(io.stdout, '')
224 224
225 225 def test_display_empty_streams_type(self):
226 226 """empty stdout/err are not displayed (groupby type)"""
@@ -231,17 +231,17 b' class AsyncResultTest(ClusterTestCase):'
231 231 ar.get(5)
232 232 with capture_output() as io:
233 233 ar.display_outputs()
234 self.assertEquals(io.stderr, '')
235 self.assertEquals(io.stdout.count('5555'), len(v), io.stdout)
234 self.assertEqual(io.stderr, '')
235 self.assertEqual(io.stdout.count('5555'), len(v), io.stdout)
236 236 self.assertFalse('\n\n' in io.stdout, io.stdout)
237 self.assertEquals(io.stdout.count('[stdout:'), len(v), io.stdout)
237 self.assertEqual(io.stdout.count('[stdout:'), len(v), io.stdout)
238 238
239 239 ar = v.execute("a=5")
240 240 ar.get(5)
241 241 with capture_output() as io:
242 242 ar.display_outputs()
243 self.assertEquals(io.stderr, '')
244 self.assertEquals(io.stdout, '')
243 self.assertEqual(io.stderr, '')
244 self.assertEqual(io.stdout, '')
245 245
246 246 def test_display_empty_streams_engine(self):
247 247 """empty stdout/err are not displayed (groupby engine)"""
@@ -252,16 +252,16 b' class AsyncResultTest(ClusterTestCase):'
252 252 ar.get(5)
253 253 with capture_output() as io:
254 254 ar.display_outputs('engine')
255 self.assertEquals(io.stderr, '')
256 self.assertEquals(io.stdout.count('5555'), len(v), io.stdout)
255 self.assertEqual(io.stderr, '')
256 self.assertEqual(io.stdout.count('5555'), len(v), io.stdout)
257 257 self.assertFalse('\n\n' in io.stdout, io.stdout)
258 self.assertEquals(io.stdout.count('[stdout:'), len(v), io.stdout)
258 self.assertEqual(io.stdout.count('[stdout:'), len(v), io.stdout)
259 259
260 260 ar = v.execute("a=5")
261 261 ar.get(5)
262 262 with capture_output() as io:
263 263 ar.display_outputs('engine')
264 self.assertEquals(io.stderr, '')
265 self.assertEquals(io.stdout, '')
264 self.assertEqual(io.stderr, '')
265 self.assertEqual(io.stdout, '')
266 266
267 267
@@ -40,58 +40,58 b' class TestClient(ClusterTestCase):'
40 40 def test_ids(self):
41 41 n = len(self.client.ids)
42 42 self.add_engines(2)
43 self.assertEquals(len(self.client.ids), n+2)
43 self.assertEqual(len(self.client.ids), n+2)
44 44
45 45 def test_view_indexing(self):
46 46 """test index access for views"""
47 47 self.minimum_engines(4)
48 48 targets = self.client._build_targets('all')[-1]
49 49 v = self.client[:]
50 self.assertEquals(v.targets, targets)
50 self.assertEqual(v.targets, targets)
51 51 t = self.client.ids[2]
52 52 v = self.client[t]
53 53 self.assert_(isinstance(v, DirectView))
54 self.assertEquals(v.targets, t)
54 self.assertEqual(v.targets, t)
55 55 t = self.client.ids[2:4]
56 56 v = self.client[t]
57 57 self.assert_(isinstance(v, DirectView))
58 self.assertEquals(v.targets, t)
58 self.assertEqual(v.targets, t)
59 59 v = self.client[::2]
60 60 self.assert_(isinstance(v, DirectView))
61 self.assertEquals(v.targets, targets[::2])
61 self.assertEqual(v.targets, targets[::2])
62 62 v = self.client[1::3]
63 63 self.assert_(isinstance(v, DirectView))
64 self.assertEquals(v.targets, targets[1::3])
64 self.assertEqual(v.targets, targets[1::3])
65 65 v = self.client[:-3]
66 66 self.assert_(isinstance(v, DirectView))
67 self.assertEquals(v.targets, targets[:-3])
67 self.assertEqual(v.targets, targets[:-3])
68 68 v = self.client[-1]
69 69 self.assert_(isinstance(v, DirectView))
70 self.assertEquals(v.targets, targets[-1])
70 self.assertEqual(v.targets, targets[-1])
71 71 self.assertRaises(TypeError, lambda : self.client[None])
72 72
73 73 def test_lbview_targets(self):
74 74 """test load_balanced_view targets"""
75 75 v = self.client.load_balanced_view()
76 self.assertEquals(v.targets, None)
76 self.assertEqual(v.targets, None)
77 77 v = self.client.load_balanced_view(-1)
78 self.assertEquals(v.targets, [self.client.ids[-1]])
78 self.assertEqual(v.targets, [self.client.ids[-1]])
79 79 v = self.client.load_balanced_view('all')
80 self.assertEquals(v.targets, None)
80 self.assertEqual(v.targets, None)
81 81
82 82 def test_dview_targets(self):
83 83 """test direct_view targets"""
84 84 v = self.client.direct_view()
85 self.assertEquals(v.targets, 'all')
85 self.assertEqual(v.targets, 'all')
86 86 v = self.client.direct_view('all')
87 self.assertEquals(v.targets, 'all')
87 self.assertEqual(v.targets, 'all')
88 88 v = self.client.direct_view(-1)
89 self.assertEquals(v.targets, self.client.ids[-1])
89 self.assertEqual(v.targets, self.client.ids[-1])
90 90
91 91 def test_lazy_all_targets(self):
92 92 """test lazy evaluation of rc.direct_view('all')"""
93 93 v = self.client.direct_view()
94 self.assertEquals(v.targets, 'all')
94 self.assertEqual(v.targets, 'all')
95 95
96 96 def double(x):
97 97 return x*2
@@ -104,11 +104,11 b' class TestClient(ClusterTestCase):'
104 104
105 105 # simple apply
106 106 r = v.apply_sync(lambda : 1)
107 self.assertEquals(r, [1] * n1)
107 self.assertEqual(r, [1] * n1)
108 108
109 109 # map goes through remotefunction
110 110 r = v.map_sync(double, seq)
111 self.assertEquals(r, ref)
111 self.assertEqual(r, ref)
112 112
113 113 # add a couple more engines, and try again
114 114 self.add_engines(2)
@@ -117,18 +117,18 b' class TestClient(ClusterTestCase):'
117 117
118 118 # apply
119 119 r = v.apply_sync(lambda : 1)
120 self.assertEquals(r, [1] * n2)
120 self.assertEqual(r, [1] * n2)
121 121
122 122 # map
123 123 r = v.map_sync(double, seq)
124 self.assertEquals(r, ref)
124 self.assertEqual(r, ref)
125 125
126 126 def test_targets(self):
127 127 """test various valid targets arguments"""
128 128 build = self.client._build_targets
129 129 ids = self.client.ids
130 130 idents,targets = build(None)
131 self.assertEquals(ids, targets)
131 self.assertEqual(ids, targets)
132 132
133 133 def test_clear(self):
134 134 """test clear behavior"""
@@ -154,7 +154,7 b' class TestClient(ClusterTestCase):'
154 154 time.sleep(.25)
155 155 ahr = self.client.get_result(ar.msg_ids)
156 156 self.assertTrue(isinstance(ahr, AsyncHubResult))
157 self.assertEquals(ahr.get(), ar.get())
157 self.assertEqual(ahr.get(), ar.get())
158 158 ar2 = self.client.get_result(ar.msg_ids)
159 159 self.assertFalse(isinstance(ar2, AsyncHubResult))
160 160 c.close()
@@ -173,7 +173,7 b' class TestClient(ClusterTestCase):'
173 173 time.sleep(.25)
174 174 ahr = self.client.get_result(ar.msg_ids)
175 175 self.assertTrue(isinstance(ahr, AsyncHubResult))
176 self.assertEquals(ahr.get().pyout, ar.get().pyout)
176 self.assertEqual(ahr.get().pyout, ar.get().pyout)
177 177 ar2 = self.client.get_result(ar.msg_ids)
178 178 self.assertFalse(isinstance(ar2, AsyncHubResult))
179 179 c.close()
@@ -181,7 +181,7 b' class TestClient(ClusterTestCase):'
181 181 def test_ids_list(self):
182 182 """test client.ids"""
183 183 ids = self.client.ids
184 self.assertEquals(ids, self.client._ids)
184 self.assertEqual(ids, self.client._ids)
185 185 self.assertFalse(ids is self.client._ids)
186 186 ids.remove(ids[-1])
187 187 self.assertNotEquals(ids, self.client._ids)
@@ -191,16 +191,16 b' class TestClient(ClusterTestCase):'
191 191 id0 = ids[0]
192 192 qs = self.client.queue_status(targets=id0)
193 193 self.assertTrue(isinstance(qs, dict))
194 self.assertEquals(sorted(qs.keys()), ['completed', 'queue', 'tasks'])
194 self.assertEqual(sorted(qs.keys()), ['completed', 'queue', 'tasks'])
195 195 allqs = self.client.queue_status()
196 196 self.assertTrue(isinstance(allqs, dict))
197 197 intkeys = list(allqs.keys())
198 198 intkeys.remove('unassigned')
199 self.assertEquals(sorted(intkeys), sorted(self.client.ids))
199 self.assertEqual(sorted(intkeys), sorted(self.client.ids))
200 200 unassigned = allqs.pop('unassigned')
201 201 for eid,qs in allqs.items():
202 202 self.assertTrue(isinstance(qs, dict))
203 self.assertEquals(sorted(qs.keys()), ['completed', 'queue', 'tasks'])
203 self.assertEqual(sorted(qs.keys()), ['completed', 'queue', 'tasks'])
204 204
205 205 def test_shutdown(self):
206 206 ids = self.client.ids
@@ -223,7 +223,7 b' class TestClient(ClusterTestCase):'
223 223 tic = middle['submitted']
224 224 before = self.client.db_query({'submitted' : {'$lt' : tic}})
225 225 after = self.client.db_query({'submitted' : {'$gte' : tic}})
226 self.assertEquals(len(before)+len(after),len(hist))
226 self.assertEqual(len(before)+len(after),len(hist))
227 227 for b in before:
228 228 self.assertTrue(b['submitted'] < tic)
229 229 for a in after:
@@ -236,7 +236,7 b' class TestClient(ClusterTestCase):'
236 236 """test extracting subset of record keys"""
237 237 found = self.client.db_query({'msg_id': {'$ne' : ''}},keys=['submitted', 'completed'])
238 238 for rec in found:
239 self.assertEquals(set(rec.keys()), set(['msg_id', 'submitted', 'completed']))
239 self.assertEqual(set(rec.keys()), set(['msg_id', 'submitted', 'completed']))
240 240
241 241 def test_db_query_default_keys(self):
242 242 """default db_query excludes buffers"""
@@ -277,10 +277,10 b' class TestClient(ClusterTestCase):'
277 277 odd = hist[1::2]
278 278 recs = self.client.db_query({ 'msg_id' : {'$in' : even}})
279 279 found = [ r['msg_id'] for r in recs ]
280 self.assertEquals(set(even), set(found))
280 self.assertEqual(set(even), set(found))
281 281 recs = self.client.db_query({ 'msg_id' : {'$nin' : even}})
282 282 found = [ r['msg_id'] for r in recs ]
283 self.assertEquals(set(odd), set(found))
283 self.assertEqual(set(odd), set(found))
284 284
285 285 def test_hub_history(self):
286 286 hist = self.client.hub_history()
@@ -298,7 +298,7 b' class TestClient(ClusterTestCase):'
298 298 ar = self.client[-1].apply_async(lambda : 1)
299 299 ar.get()
300 300 time.sleep(0.25)
301 self.assertEquals(self.client.hub_history()[-1:],ar.msg_ids)
301 self.assertEqual(self.client.hub_history()[-1:],ar.msg_ids)
302 302
303 303 def _wait_for_idle(self):
304 304 """wait for an engine to become idle, according to the Hub"""
@@ -314,9 +314,9 b' class TestClient(ClusterTestCase):'
314 314 break
315 315
316 316 # ensure Hub up to date:
317 self.assertEquals(qs['unassigned'], 0)
317 self.assertEqual(qs['unassigned'], 0)
318 318 for eid in rc.ids:
319 self.assertEquals(qs[eid]['tasks'], 0)
319 self.assertEqual(qs[eid]['tasks'], 0)
320 320
321 321
322 322 def test_resubmit(self):
@@ -366,7 +366,7 b' class TestClient(ClusterTestCase):'
366 366 if key in ('msg_id', 'date'):
367 367 self.assertNotEquals(h1[key], h2[key])
368 368 else:
369 self.assertEquals(h1[key], h2[key])
369 self.assertEqual(h1[key], h2[key])
370 370
371 371 def test_resubmit_aborted(self):
372 372 def f():
@@ -414,14 +414,14 b' class TestClient(ClusterTestCase):'
414 414 ahr.wait(10)
415 415 self.client.purge_results(hist[-1])
416 416 newhist = self.client.hub_history()
417 self.assertEquals(len(newhist)+1,len(hist))
417 self.assertEqual(len(newhist)+1,len(hist))
418 418 rc2.spin()
419 419 rc2.close()
420 420
421 421 def test_purge_all_results(self):
422 422 self.client.purge_results('all')
423 423 hist = self.client.hub_history()
424 self.assertEquals(len(hist), 0)
424 self.assertEqual(len(hist), 0)
425 425
426 426 def test_spin_thread(self):
427 427 self.client.spin_thread(0.01)
@@ -448,8 +448,8 b' class TestClient(ClusterTestCase):'
448 448 v0 = self.client.activate(-1, '0')
449 449 self.assertTrue('px0' in magics['line'])
450 450 self.assertTrue('px0' in magics['cell'])
451 self.assertEquals(v0.targets, self.client.ids[-1])
451 self.assertEqual(v0.targets, self.client.ids[-1])
452 452 v0 = self.client.activate('all', 'all')
453 453 self.assertTrue('pxall' in magics['line'])
454 454 self.assertTrue('pxall' in magics['cell'])
455 self.assertEquals(v0.targets, 'all')
455 self.assertEqual(v0.targets, 'all')
@@ -72,8 +72,8 b' class TestDictBackend(TestCase):'
72 72 before = self.db.get_history()
73 73 self.load_records(5)
74 74 after = self.db.get_history()
75 self.assertEquals(len(after), len(before)+5)
76 self.assertEquals(after[:-5],before)
75 self.assertEqual(len(after), len(before)+5)
76 self.assertEqual(after[:-5],before)
77 77
78 78 def test_drop_record(self):
79 79 msg_id = self.load_records()[-1]
@@ -95,10 +95,10 b' class TestDictBackend(TestCase):'
95 95 data = {'stdout': 'hello there', 'completed' : now}
96 96 self.db.update_record(msg_id, data)
97 97 rec2 = self.db.get_record(msg_id)
98 self.assertEquals(rec2['stdout'], 'hello there')
99 self.assertEquals(rec2['completed'], now)
98 self.assertEqual(rec2['stdout'], 'hello there')
99 self.assertEqual(rec2['completed'], now)
100 100 rec1.update(data)
101 self.assertEquals(rec1, rec2)
101 self.assertEqual(rec1, rec2)
102 102
103 103 # def test_update_record_bad(self):
104 104 # """test updating nonexistant records"""
@@ -113,7 +113,7 b' class TestDictBackend(TestCase):'
113 113 tic = middle['submitted']
114 114 before = self.db.find_records({'submitted' : {'$lt' : tic}})
115 115 after = self.db.find_records({'submitted' : {'$gte' : tic}})
116 self.assertEquals(len(before)+len(after),len(hist))
116 self.assertEqual(len(before)+len(after),len(hist))
117 117 for b in before:
118 118 self.assertTrue(b['submitted'] < tic)
119 119 for a in after:
@@ -126,7 +126,7 b' class TestDictBackend(TestCase):'
126 126 """test extracting subset of record keys"""
127 127 found = self.db.find_records({'msg_id': {'$ne' : ''}},keys=['submitted', 'completed'])
128 128 for rec in found:
129 self.assertEquals(set(rec.keys()), set(['msg_id', 'submitted', 'completed']))
129 self.assertEqual(set(rec.keys()), set(['msg_id', 'submitted', 'completed']))
130 130
131 131 def test_find_records_msg_id(self):
132 132 """ensure msg_id is always in found records"""
@@ -147,10 +147,10 b' class TestDictBackend(TestCase):'
147 147 odd = hist[1::2]
148 148 recs = self.db.find_records({ 'msg_id' : {'$in' : even}})
149 149 found = [ r['msg_id'] for r in recs ]
150 self.assertEquals(set(even), set(found))
150 self.assertEqual(set(even), set(found))
151 151 recs = self.db.find_records({ 'msg_id' : {'$nin' : even}})
152 152 found = [ r['msg_id'] for r in recs ]
153 self.assertEquals(set(odd), set(found))
153 self.assertEqual(set(odd), set(found))
154 154
155 155 def test_get_history(self):
156 156 msg_ids = self.db.get_history()
@@ -161,7 +161,7 b' class TestDictBackend(TestCase):'
161 161 self.assertTrue(newt >= latest)
162 162 latest = newt
163 163 msg_id = self.load_records(1)[-1]
164 self.assertEquals(self.db.get_history()[-1],msg_id)
164 self.assertEqual(self.db.get_history()[-1],msg_id)
165 165
166 166 def test_datetime(self):
167 167 """get/set timestamps with datetime objects"""
@@ -177,7 +177,7 b' class TestDictBackend(TestCase):'
177 177 query = {'msg_id' : {'$in':msg_ids}}
178 178 self.db.drop_matching_records(query)
179 179 recs = self.db.find_records(query)
180 self.assertEquals(len(recs), 0)
180 self.assertEqual(len(recs), 0)
181 181
182 182 def test_null(self):
183 183 """test None comparison queries"""
@@ -185,7 +185,7 b' class TestDictBackend(TestCase):'
185 185
186 186 query = {'msg_id' : None}
187 187 recs = self.db.find_records(query)
188 self.assertEquals(len(recs), 0)
188 self.assertEqual(len(recs), 0)
189 189
190 190 query = {'msg_id' : {'$ne' : None}}
191 191 recs = self.db.find_records(query)
@@ -201,7 +201,7 b' class TestDictBackend(TestCase):'
201 201 rec2 = self.db.get_record(msg_id)
202 202 self.assertTrue('buffers' in rec2)
203 203 self.assertFalse('garbage' in rec2)
204 self.assertEquals(rec2['header']['msg_id'], msg_id)
204 self.assertEqual(rec2['header']['msg_id'], msg_id)
205 205
206 206 def test_pop_safe_find(self):
207 207 """editing query results shouldn't affect record [find]"""
@@ -213,7 +213,7 b' class TestDictBackend(TestCase):'
213 213 rec2 = self.db.find_records({'msg_id' : msg_id})[0]
214 214 self.assertTrue('buffers' in rec2)
215 215 self.assertFalse('garbage' in rec2)
216 self.assertEquals(rec2['header']['msg_id'], msg_id)
216 self.assertEqual(rec2['header']['msg_id'], msg_id)
217 217
218 218 def test_pop_safe_find_keys(self):
219 219 """editing query results shouldn't affect record [find+keys]"""
@@ -225,7 +225,7 b' class TestDictBackend(TestCase):'
225 225 rec2 = self.db.find_records({'msg_id' : msg_id})[0]
226 226 self.assertTrue('buffers' in rec2)
227 227 self.assertFalse('garbage' in rec2)
228 self.assertEquals(rec2['header']['msg_id'], msg_id)
228 self.assertEqual(rec2['header']['msg_id'], msg_id)
229 229
230 230
231 231 class TestSQLiteBackend(TestDictBackend):
@@ -75,7 +75,7 b' class DependencyTest(ClusterTestCase):'
75 75 def encode(dikt):
76 76 return urllib.urlencode(dikt)
77 77 # must pass through canning to properly connect namespaces
78 self.assertEquals(encode(dict(a=5)), 'a=5')
78 self.assertEqual(encode(dict(a=5)), 'a=5')
79 79
80 80 def test_success_only(self):
81 81 dep = pmod.Dependency(mixed, success=True, failure=False)
@@ -56,7 +56,7 b' class TestLoadBalancedView(ClusterTestCase):'
56 56 return x**2
57 57 data = range(16)
58 58 r = self.view.map_sync(f, data)
59 self.assertEquals(r, map(f, data))
59 self.assertEqual(r, map(f, data))
60 60
61 61 def test_map_unordered(self):
62 62 def f(x):
@@ -75,7 +75,7 b' class TestLoadBalancedView(ClusterTestCase):'
75 75 astheycame = [ r for r in amr ]
76 76 # Ensure that at least one result came out of order:
77 77 self.assertNotEquals(astheycame, reference, "should not have preserved order")
78 self.assertEquals(sorted(astheycame, reverse=True), reference, "result corrupted")
78 self.assertEqual(sorted(astheycame, reverse=True), reference, "result corrupted")
79 79
80 80 def test_map_ordered(self):
81 81 def f(x):
@@ -93,8 +93,8 b' class TestLoadBalancedView(ClusterTestCase):'
93 93 # list(amr) uses __iter__
94 94 astheycame = list(amr)
95 95 # Ensure that results came in order
96 self.assertEquals(astheycame, reference)
97 self.assertEquals(amr.result, reference)
96 self.assertEqual(astheycame, reference)
97 self.assertEqual(amr.result, reference)
98 98
99 99 def test_map_iterable(self):
100 100 """test map on iterables (balanced)"""
@@ -104,7 +104,7 b' class TestLoadBalancedView(ClusterTestCase):'
104 104 # so that it will be an iterator, even in Python 3
105 105 it = iter(arr)
106 106 r = view.map_sync(lambda x:x, arr)
107 self.assertEquals(r, list(arr))
107 self.assertEqual(r, list(arr))
108 108
109 109
110 110 def test_abort(self):
@@ -163,7 +163,7 b' class TestLoadBalancedView(ClusterTestCase):'
163 163 ars.append(self.view.apply_async(lambda : 1))
164 164 self.view.wait(ars)
165 165 for ar in ars:
166 self.assertEquals(ar.engine_id, first_id)
166 self.assertEqual(ar.engine_id, first_id)
167 167
168 168 def test_after(self):
169 169 view = self.view
@@ -48,9 +48,9 b' class TestParallelMagics(ClusterTestCase, ParametricTestCase):'
48 48 v.block=True
49 49
50 50 ip.magic('px a=5')
51 self.assertEquals(v['a'], [5])
51 self.assertEqual(v['a'], [5])
52 52 ip.magic('px a=10')
53 self.assertEquals(v['a'], [10])
53 self.assertEqual(v['a'], [10])
54 54 # just 'print a' works ~99% of the time, but this ensures that
55 55 # the stdout message has arrived when the result is finished:
56 56 with capture_output() as io:
@@ -72,7 +72,7 b' class TestParallelMagics(ClusterTestCase, ParametricTestCase):'
72 72
73 73 self.assertFalse('\n\n' in stderr, stderr)
74 74 lines = stderr.splitlines()
75 self.assertEquals(len(lines), len(expected), stderr)
75 self.assertEqual(len(lines), len(expected), stderr)
76 76 for line,expect in zip(lines, expected):
77 77 if isinstance(expect, str):
78 78 expect = [expect]
@@ -128,7 +128,7 b' class TestParallelMagics(ClusterTestCase, ParametricTestCase):'
128 128 r'Out\[\d+:\d+\]:.*IPython\.core\.display\.Math',
129 129 ] * len(v)
130 130
131 self.assertEquals(len(lines), len(expected), io.stdout)
131 self.assertEqual(len(lines), len(expected), io.stdout)
132 132 for line,expect in zip(lines, expected):
133 133 if isinstance(expect, str):
134 134 expect = [expect]
@@ -170,7 +170,7 b' class TestParallelMagics(ClusterTestCase, ParametricTestCase):'
170 170 r'Out\[\d+:\d+\]:.*IPython\.core\.display\.Math'
171 171 ] * len(v))
172 172
173 self.assertEquals(len(lines), len(expected), io.stdout)
173 self.assertEqual(len(lines), len(expected), io.stdout)
174 174 for line,expect in zip(lines, expected):
175 175 if isinstance(expect, str):
176 176 expect = [expect]
@@ -209,7 +209,7 b' class TestParallelMagics(ClusterTestCase, ParametricTestCase):'
209 209 (r'Out\[\d+:\d+\]', r'IPython\.core\.display\.Math')
210 210 ] * len(v))
211 211
212 self.assertEquals(len(lines), len(expected), io.stdout)
212 self.assertEqual(len(lines), len(expected), io.stdout)
213 213 for line,expect in zip(lines, expected):
214 214 if isinstance(expect, str):
215 215 expect = [expect]
@@ -226,9 +226,9 b' class TestParallelMagics(ClusterTestCase, ParametricTestCase):'
226 226 v.block=False
227 227
228 228 ip.magic('px a=5')
229 self.assertEquals(v['a'], [5])
229 self.assertEqual(v['a'], [5])
230 230 ip.magic('px a=10')
231 self.assertEquals(v['a'], [10])
231 self.assertEqual(v['a'], [10])
232 232 ip.magic('pxconfig --verbose')
233 233 with capture_output() as io:
234 234 ar = ip.magic('px print (a)')
@@ -263,8 +263,8 b' class TestParallelMagics(ClusterTestCase, ParametricTestCase):'
263 263 self.assertTrue('\nOut[' in output, output)
264 264 self.assertTrue(': 24690' in output, output)
265 265 ar = v.get_result(-1)
266 self.assertEquals(v['a'], 5)
267 self.assertEquals(v['b'], 24690)
266 self.assertEqual(v['a'], 5)
267 self.assertEqual(v['b'], 24690)
268 268 self.assertRaisesRemote(ZeroDivisionError, ar.get)
269 269
270 270 def test_autopx_nonblocking(self):
@@ -291,9 +291,9 b' class TestParallelMagics(ClusterTestCase, ParametricTestCase):'
291 291 self.assertRaisesRemote(ZeroDivisionError, ar.get)
292 292 # prevent TaskAborted on pulls, due to ZeroDivisionError
293 293 time.sleep(0.5)
294 self.assertEquals(v['a'], 5)
294 self.assertEqual(v['a'], 5)
295 295 # b*=2 will not fire, due to abort
296 self.assertEquals(v['b'], 10)
296 self.assertEqual(v['b'], 10)
297 297
298 298 def test_result(self):
299 299 ip = get_ipython()
@@ -335,26 +335,26 b' class TestParallelMagics(ClusterTestCase, ParametricTestCase):'
335 335 ip = get_ipython()
336 336 rc = self.client
337 337 v = rc.activate(-1, '_tst')
338 self.assertEquals(v.targets, rc.ids[-1])
338 self.assertEqual(v.targets, rc.ids[-1])
339 339 ip.magic("%pxconfig_tst -t :")
340 self.assertEquals(v.targets, rc.ids)
340 self.assertEqual(v.targets, rc.ids)
341 341 ip.magic("%pxconfig_tst -t ::2")
342 self.assertEquals(v.targets, rc.ids[::2])
342 self.assertEqual(v.targets, rc.ids[::2])
343 343 ip.magic("%pxconfig_tst -t 1::2")
344 self.assertEquals(v.targets, rc.ids[1::2])
344 self.assertEqual(v.targets, rc.ids[1::2])
345 345 ip.magic("%pxconfig_tst -t 1")
346 self.assertEquals(v.targets, 1)
346 self.assertEqual(v.targets, 1)
347 347 ip.magic("%pxconfig_tst --block")
348 self.assertEquals(v.block, True)
348 self.assertEqual(v.block, True)
349 349 ip.magic("%pxconfig_tst --noblock")
350 self.assertEquals(v.block, False)
350 self.assertEqual(v.block, False)
351 351
352 352 def test_cellpx_targets(self):
353 353 """%%px --targets doesn't change defaults"""
354 354 ip = get_ipython()
355 355 rc = self.client
356 356 view = rc.activate(rc.ids)
357 self.assertEquals(view.targets, rc.ids)
357 self.assertEqual(view.targets, rc.ids)
358 358 ip.magic('pxconfig --verbose')
359 359 for cell in ("pass", "1/0"):
360 360 with capture_output() as io:
@@ -363,7 +363,7 b' class TestParallelMagics(ClusterTestCase, ParametricTestCase):'
363 363 except pmod.RemoteError:
364 364 pass
365 365 self.assertTrue('engine(s): all' in io.stdout)
366 self.assertEquals(view.targets, rc.ids)
366 self.assertEqual(view.targets, rc.ids)
367 367
368 368
369 369 def test_cellpx_block(self):
@@ -372,7 +372,7 b' class TestParallelMagics(ClusterTestCase, ParametricTestCase):'
372 372 rc = self.client
373 373 view = rc.activate(rc.ids)
374 374 view.block = False
375 self.assertEquals(view.targets, rc.ids)
375 self.assertEqual(view.targets, rc.ids)
376 376 ip.magic('pxconfig --verbose')
377 377 for cell in ("pass", "1/0"):
378 378 with capture_output() as io:
@@ -60,7 +60,7 b' class CanningTestCase(TestCase):'
60 60 s = ns.serialize(us)
61 61 uus = ns.unserialize(s)
62 62 self.assertTrue(isinstance(s, ns.SerializeIt))
63 self.assertEquals(uus, us)
63 self.assertEqual(uus, us)
64 64
65 65 def test_pickle_serialized(self):
66 66 obj = {'a':1.45345, 'b':'asdfsdf', 'c':10000L}
@@ -69,16 +69,16 b' class CanningTestCase(TestCase):'
69 69 firstData = originalSer.getData()
70 70 firstTD = originalSer.getTypeDescriptor()
71 71 firstMD = originalSer.getMetadata()
72 self.assertEquals(firstTD, 'pickle')
73 self.assertEquals(firstMD, {})
72 self.assertEqual(firstTD, 'pickle')
73 self.assertEqual(firstMD, {})
74 74 unSerialized = ns.UnSerializeIt(originalSer)
75 75 secondObj = unSerialized.getObject()
76 76 for k, v in secondObj.iteritems():
77 self.assertEquals(obj[k], v)
77 self.assertEqual(obj[k], v)
78 78 secondSer = ns.SerializeIt(ns.UnSerialized(secondObj))
79 self.assertEquals(firstData, secondSer.getData())
80 self.assertEquals(firstTD, secondSer.getTypeDescriptor() )
81 self.assertEquals(firstMD, secondSer.getMetadata())
79 self.assertEqual(firstData, secondSer.getData())
80 self.assertEqual(firstTD, secondSer.getTypeDescriptor() )
81 self.assertEqual(firstMD, secondSer.getMetadata())
82 82
83 83 @skip_without('numpy')
84 84 def test_ndarray_serialized(self):
@@ -87,18 +87,18 b' class CanningTestCase(TestCase):'
87 87 unSer1 = ns.UnSerialized(a)
88 88 ser1 = ns.SerializeIt(unSer1)
89 89 td = ser1.getTypeDescriptor()
90 self.assertEquals(td, 'ndarray')
90 self.assertEqual(td, 'ndarray')
91 91 md = ser1.getMetadata()
92 self.assertEquals(md['shape'], a.shape)
93 self.assertEquals(md['dtype'], a.dtype)
92 self.assertEqual(md['shape'], a.shape)
93 self.assertEqual(md['dtype'], a.dtype)
94 94 buff = ser1.getData()
95 self.assertEquals(buff, buffer(a))
95 self.assertEqual(buff, buffer(a))
96 96 s = ns.Serialized(buff, td, md)
97 97 final = ns.unserialize(s)
98 self.assertEquals(buffer(a), buffer(final))
98 self.assertEqual(buffer(a), buffer(final))
99 99 self.assertTrue((a==final).all())
100 self.assertEquals(a.dtype, final.dtype)
101 self.assertEquals(a.shape, final.shape)
100 self.assertEqual(a.dtype, final.dtype)
101 self.assertEqual(a.shape, final.shape)
102 102 # test non-copying:
103 103 a[2] = 1e9
104 104 self.assertTrue((a==final).all())
@@ -75,20 +75,20 b' class TestView(ClusterTestCase, ParametricTestCase):'
75 75 nengines = len(self.client)
76 76 push({'data':data})
77 77 d = pull('data')
78 self.assertEquals(d, data)
78 self.assertEqual(d, data)
79 79 self.client[:].push({'data':data})
80 80 d = self.client[:].pull('data', block=True)
81 self.assertEquals(d, nengines*[data])
81 self.assertEqual(d, nengines*[data])
82 82 ar = push({'data':data}, block=False)
83 83 self.assertTrue(isinstance(ar, AsyncResult))
84 84 r = ar.get()
85 85 ar = self.client[:].pull('data', block=False)
86 86 self.assertTrue(isinstance(ar, AsyncResult))
87 87 r = ar.get()
88 self.assertEquals(r, nengines*[data])
88 self.assertEqual(r, nengines*[data])
89 89 self.client[:].push(dict(a=10,b=20))
90 90 r = self.client[:].pull(('a','b'), block=True)
91 self.assertEquals(r, nengines*[[10,20]])
91 self.assertEqual(r, nengines*[[10,20]])
92 92
93 93 def test_push_pull_function(self):
94 94 "test pushing and pulling functions"
@@ -106,7 +106,7 b' class TestView(ClusterTestCase, ParametricTestCase):'
106 106 self.assertEqual(r(1.0), testf(1.0))
107 107 execute('r = testf(10)')
108 108 r = pull('r')
109 self.assertEquals(r, testf(10))
109 self.assertEqual(r, testf(10))
110 110 ar = self.client[:].push({'testf':testf}, block=False)
111 111 ar.get()
112 112 ar = self.client[:].pull('testf', block=False)
@@ -115,7 +115,7 b' class TestView(ClusterTestCase, ParametricTestCase):'
115 115 self.assertEqual(r(1.0), testf(1.0))
116 116 execute("def g(x): return x*x")
117 117 r = pull(('testf','g'))
118 self.assertEquals((r[0](10),r[1](10)), (testf(10), 100))
118 self.assertEqual((r[0](10),r[1](10)), (testf(10), 100))
119 119
120 120 def test_push_function_globals(self):
121 121 """test that pushed functions have access to globals"""
@@ -129,7 +129,7 b' class TestView(ClusterTestCase, ParametricTestCase):'
129 129 self.assertRaisesRemote(NameError, v.execute, 'b=f()')
130 130 v.execute('a=5')
131 131 v.execute('b=f()')
132 self.assertEquals(v['b'], 5)
132 self.assertEqual(v['b'], 5)
133 133
134 134 def test_push_function_defaults(self):
135 135 """test that pushed functions preserve default args"""
@@ -139,7 +139,7 b' class TestView(ClusterTestCase, ParametricTestCase):'
139 139 v.block=True
140 140 v['f'] = echo
141 141 v.execute('b=f()')
142 self.assertEquals(v['b'], 10)
142 self.assertEqual(v['b'], 10)
143 143
144 144 def test_get_result(self):
145 145 """test getting results from the Hub."""
@@ -153,7 +153,7 b' class TestView(ClusterTestCase, ParametricTestCase):'
153 153 time.sleep(.25)
154 154 ahr = v2.get_result(ar.msg_ids)
155 155 self.assertTrue(isinstance(ahr, AsyncHubResult))
156 self.assertEquals(ahr.get(), ar.get())
156 self.assertEqual(ahr.get(), ar.get())
157 157 ar2 = v2.get_result(ar.msg_ids)
158 158 self.assertFalse(isinstance(ar2, AsyncHubResult))
159 159 c.spin()
@@ -168,7 +168,7 b' class TestView(ClusterTestCase, ParametricTestCase):'
168 168 """)
169 169 v = self.client[-1]
170 170 v.run(tmpfile, block=True)
171 self.assertEquals(v.apply_sync(lambda f: f(), pmod.Reference('g')), 5)
171 self.assertEqual(v.apply_sync(lambda f: f(), pmod.Reference('g')), 5)
172 172
173 173 def test_apply_tracked(self):
174 174 """test tracking for apply"""
@@ -184,7 +184,7 b' class TestView(ClusterTestCase, ParametricTestCase):'
184 184 self.assertTrue(ar.sent)
185 185 ar = echo(track=True)
186 186 self.assertTrue(isinstance(ar._tracker, zmq.MessageTracker))
187 self.assertEquals(ar.sent, ar._tracker.done)
187 self.assertEqual(ar.sent, ar._tracker.done)
188 188 ar._tracker.wait()
189 189 self.assertTrue(ar.sent)
190 190
@@ -199,7 +199,7 b' class TestView(ClusterTestCase, ParametricTestCase):'
199 199 ar = v.push(ns, block=False, track=True)
200 200 self.assertTrue(isinstance(ar._tracker, zmq.MessageTracker))
201 201 ar._tracker.wait()
202 self.assertEquals(ar.sent, ar._tracker.done)
202 self.assertEqual(ar.sent, ar._tracker.done)
203 203 self.assertTrue(ar.sent)
204 204 ar.get()
205 205
@@ -212,7 +212,7 b' class TestView(ClusterTestCase, ParametricTestCase):'
212 212
213 213 ar = self.client[t].scatter('x', x, block=False, track=True)
214 214 self.assertTrue(isinstance(ar._tracker, zmq.MessageTracker))
215 self.assertEquals(ar.sent, ar._tracker.done)
215 self.assertEqual(ar.sent, ar._tracker.done)
216 216 ar._tracker.wait()
217 217 self.assertTrue(ar.sent)
218 218 ar.get()
@@ -222,7 +222,7 b' class TestView(ClusterTestCase, ParametricTestCase):'
222 222 v['a'] = 123
223 223 ra = pmod.Reference('a')
224 224 b = v.apply_sync(lambda x: x, ra)
225 self.assertEquals(b, 123)
225 self.assertEqual(b, 123)
226 226
227 227
228 228 def test_scatter_gather(self):
@@ -230,7 +230,7 b' class TestView(ClusterTestCase, ParametricTestCase):'
230 230 seq1 = range(16)
231 231 view.scatter('a', seq1)
232 232 seq2 = view.gather('a', block=True)
233 self.assertEquals(seq2, seq1)
233 self.assertEqual(seq2, seq1)
234 234 self.assertRaisesRemote(NameError, view.gather, 'asdf', block=True)
235 235
236 236 @skip_without('numpy')
@@ -249,7 +249,7 b' class TestView(ClusterTestCase, ParametricTestCase):'
249 249 x = range(64)
250 250 view.scatter('x', x)
251 251 gathered = view.gather('x', block=True)
252 self.assertEquals(gathered, x)
252 self.assertEqual(gathered, x)
253 253
254 254
255 255 @dec.known_failure_py3
@@ -301,10 +301,10 b' class TestView(ClusterTestCase, ParametricTestCase):'
301 301 R2 = view['RR']
302 302
303 303 r_dtype, r_shape = view.apply_sync(interactive(lambda : (RR.dtype, RR.shape)))
304 self.assertEquals(r_dtype, R.dtype)
305 self.assertEquals(r_shape, R.shape)
306 self.assertEquals(R2.dtype, R.dtype)
307 self.assertEquals(R2.shape, R.shape)
304 self.assertEqual(r_dtype, R.dtype)
305 self.assertEqual(r_shape, R.shape)
306 self.assertEqual(R2.dtype, R.dtype)
307 self.assertEqual(R2.shape, R.shape)
308 308 assert_array_equal(R2, R)
309 309
310 310 def test_map(self):
@@ -313,7 +313,7 b' class TestView(ClusterTestCase, ParametricTestCase):'
313 313 return x**2
314 314 data = range(16)
315 315 r = view.map_sync(f, data)
316 self.assertEquals(r, map(f, data))
316 self.assertEqual(r, map(f, data))
317 317
318 318 def test_map_iterable(self):
319 319 """test map on iterables (direct)"""
@@ -323,14 +323,14 b' class TestView(ClusterTestCase, ParametricTestCase):'
323 323 # ensure it will be an iterator, even in Python 3
324 324 it = iter(arr)
325 325 r = view.map_sync(lambda x:x, arr)
326 self.assertEquals(r, list(arr))
326 self.assertEqual(r, list(arr))
327 327
328 328 def test_scatterGatherNonblocking(self):
329 329 data = range(16)
330 330 view = self.client[:]
331 331 view.scatter('a', data, block=False)
332 332 ar = view.gather('a', block=False)
333 self.assertEquals(ar.get(), data)
333 self.assertEqual(ar.get(), data)
334 334
335 335 @skip_without('numpy')
336 336 def test_scatter_gather_numpy_nonblocking(self):
@@ -352,9 +352,9 b' class TestView(ClusterTestCase, ParametricTestCase):'
352 352 self.assertTrue(isinstance(ar, AsyncResult))
353 353 ar = execute('d=[0,1,2]', block=False)
354 354 self.client.wait(ar, 1)
355 self.assertEquals(len(ar.get()), len(self.client))
355 self.assertEqual(len(ar.get()), len(self.client))
356 356 for c in view['c']:
357 self.assertEquals(c, 30)
357 self.assertEqual(c, 30)
358 358
359 359 def test_abort(self):
360 360 view = self.client[-1]
@@ -396,7 +396,7 b' class TestView(ClusterTestCase, ParametricTestCase):'
396 396 re = globals()['re']
397 397 return re.findall(pat, s)
398 398
399 self.assertEquals(view.apply_sync(findall, '\w+', 'hello world'), 'hello world'.split())
399 self.assertEqual(view.apply_sync(findall, '\w+', 'hello world'), 'hello world'.split())
400 400
401 401 def test_unicode_execute(self):
402 402 """test executing unicode strings"""
@@ -407,13 +407,13 b' class TestView(ClusterTestCase, ParametricTestCase):'
407 407 else:
408 408 code=u"a=u'é'"
409 409 v.execute(code)
410 self.assertEquals(v['a'], u'é')
410 self.assertEqual(v['a'], u'é')
411 411
412 412 def test_unicode_apply_result(self):
413 413 """test unicode apply results"""
414 414 v = self.client[-1]
415 415 r = v.apply_sync(lambda : u'é')
416 self.assertEquals(r, u'é')
416 self.assertEqual(r, u'é')
417 417
418 418 def test_unicode_apply_arg(self):
419 419 """test passing unicode arguments to apply"""
@@ -444,7 +444,7 b' class TestView(ClusterTestCase, ParametricTestCase):'
444 444 mlist = nlist[::-1]
445 445 expected = [ m*n for m,n in zip(mlist, nlist) ]
446 446 result = v.map_sync(rf, mlist, nlist)
447 self.assertEquals(result, expected)
447 self.assertEqual(result, expected)
448 448
449 449 def test_apply_reference(self):
450 450 """view.apply(<Reference>, *args) should work"""
@@ -454,14 +454,14 b' class TestView(ClusterTestCase, ParametricTestCase):'
454 454 rf = pmod.Reference('f')
455 455 result = v.apply_sync(rf, 5)
456 456 expected = [ 5*id for id in self.client.ids ]
457 self.assertEquals(result, expected)
457 self.assertEqual(result, expected)
458 458
459 459 def test_eval_reference(self):
460 460 v = self.client[self.client.ids[0]]
461 461 v['g'] = range(5)
462 462 rg = pmod.Reference('g[0]')
463 463 echo = lambda x:x
464 self.assertEquals(v.apply_sync(echo, rg), 0)
464 self.assertEqual(v.apply_sync(echo, rg), 0)
465 465
466 466 def test_reference_nameerror(self):
467 467 v = self.client[self.client.ids[0]]
@@ -474,22 +474,22 b' class TestView(ClusterTestCase, ParametricTestCase):'
474 474 r = range(5)
475 475 check = [ -1*i for i in r ]
476 476 result = e0.map_sync(lambda x: -1*x, r)
477 self.assertEquals(result, check)
477 self.assertEqual(result, check)
478 478
479 479 def test_len(self):
480 480 """len(view) makes sense"""
481 481 e0 = self.client[self.client.ids[0]]
482 yield self.assertEquals(len(e0), 1)
482 yield self.assertEqual(len(e0), 1)
483 483 v = self.client[:]
484 yield self.assertEquals(len(v), len(self.client.ids))
484 yield self.assertEqual(len(v), len(self.client.ids))
485 485 v = self.client.direct_view('all')
486 yield self.assertEquals(len(v), len(self.client.ids))
486 yield self.assertEqual(len(v), len(self.client.ids))
487 487 v = self.client[:2]
488 yield self.assertEquals(len(v), 2)
488 yield self.assertEqual(len(v), 2)
489 489 v = self.client[:1]
490 yield self.assertEquals(len(v), 1)
490 yield self.assertEqual(len(v), 1)
491 491 v = self.client.load_balanced_view()
492 yield self.assertEquals(len(v), len(self.client.ids))
492 yield self.assertEqual(len(v), len(self.client.ids))
493 493 # parametric tests seem to require manual closing?
494 494 self.client.close()
495 495
@@ -501,15 +501,15 b' class TestView(ClusterTestCase, ParametricTestCase):'
501 501 e0.block = True
502 502 ar = e0.execute("5", silent=False)
503 503 er = ar.get()
504 self.assertEquals(str(er), "<ExecuteReply[%i]: 5>" % er.execution_count)
505 self.assertEquals(er.pyout['data']['text/plain'], '5')
504 self.assertEqual(str(er), "<ExecuteReply[%i]: 5>" % er.execution_count)
505 self.assertEqual(er.pyout['data']['text/plain'], '5')
506 506
507 507 def test_execute_reply_stdout(self):
508 508 e0 = self.client[self.client.ids[0]]
509 509 e0.block = True
510 510 ar = e0.execute("print (5)", silent=False)
511 511 er = ar.get()
512 self.assertEquals(er.stdout.strip(), '5')
512 self.assertEqual(er.stdout.strip(), '5')
513 513
514 514 def test_execute_pyout(self):
515 515 """execute triggers pyout with silent=False"""
@@ -518,14 +518,14 b' class TestView(ClusterTestCase, ParametricTestCase):'
518 518
519 519 expected = [{'text/plain' : '5'}] * len(view)
520 520 mimes = [ out['data'] for out in ar.pyout ]
521 self.assertEquals(mimes, expected)
521 self.assertEqual(mimes, expected)
522 522
523 523 def test_execute_silent(self):
524 524 """execute does not trigger pyout with silent=True"""
525 525 view = self.client[:]
526 526 ar = view.execute("5", block=True)
527 527 expected = [None] * len(view)
528 self.assertEquals(ar.pyout, expected)
528 self.assertEqual(ar.pyout, expected)
529 529
530 530 def test_execute_magic(self):
531 531 """execute accepts IPython commands"""
@@ -536,7 +536,7 b' class TestView(ClusterTestCase, ParametricTestCase):'
536 536 ar.get(5)
537 537 for stdout in ar.stdout:
538 538 lines = stdout.splitlines()
539 self.assertEquals(lines[0].split(), ['Variable', 'Type', 'Data/Info'])
539 self.assertEqual(lines[0].split(), ['Variable', 'Type', 'Data/Info'])
540 540 found = False
541 541 for line in lines[2:]:
542 542 split = line.split()
@@ -554,7 +554,7 b' class TestView(ClusterTestCase, ParametricTestCase):'
554 554 expected = [ {u'text/plain' : unicode(j)} for j in range(5) ]
555 555 for outputs in ar.outputs:
556 556 mimes = [ out['data'] for out in outputs ]
557 self.assertEquals(mimes, expected)
557 self.assertEqual(mimes, expected)
558 558
559 559 def test_apply_displaypub(self):
560 560 """apply tracks display_pub output"""
@@ -570,7 +570,7 b' class TestView(ClusterTestCase, ParametricTestCase):'
570 570 expected = [ {u'text/plain' : unicode(j)} for j in range(5) ]
571 571 for outputs in ar.outputs:
572 572 mimes = [ out['data'] for out in outputs ]
573 self.assertEquals(mimes, expected)
573 self.assertEqual(mimes, expected)
574 574
575 575 def test_execute_raises(self):
576 576 """exceptions in execute requests raise appropriately"""
@@ -588,7 +588,7 b' class TestView(ClusterTestCase, ParametricTestCase):'
588 588 # include imports, in case user config
589 589 ar = view.execute("plot(rand(100))", silent=False)
590 590 reply = ar.get(5)
591 self.assertEquals(len(reply.outputs), 1)
591 self.assertEqual(len(reply.outputs), 1)
592 592 output = reply.outputs[0]
593 593 self.assertTrue("data" in output)
594 594 data = output['data']
@@ -103,29 +103,29 b' class SubProcessTestCase(TestCase, tt.TempFileMixin):'
103 103
104 104 def test_system(self):
105 105 status = system('python "%s"' % self.fname)
106 self.assertEquals(status, 0)
106 self.assertEqual(status, 0)
107 107
108 108 def test_system_quotes(self):
109 109 status = system('python -c "import sys"')
110 self.assertEquals(status, 0)
110 self.assertEqual(status, 0)
111 111
112 112 def test_getoutput(self):
113 113 out = getoutput('python "%s"' % self.fname)
114 self.assertEquals(out, 'on stdout')
114 self.assertEqual(out, 'on stdout')
115 115
116 116 def test_getoutput_quoted(self):
117 117 out = getoutput('python -c "print (1)"')
118 self.assertEquals(out.strip(), '1')
118 self.assertEqual(out.strip(), '1')
119 119
120 120 #Invalid quoting on windows
121 121 @dec.skip_win32
122 122 def test_getoutput_quoted2(self):
123 123 out = getoutput("python -c 'print (1)'")
124 self.assertEquals(out.strip(), '1')
124 self.assertEqual(out.strip(), '1')
125 125 out = getoutput("python -c 'print (\"1\")'")
126 self.assertEquals(out.strip(), '1')
126 self.assertEqual(out.strip(), '1')
127 127
128 128 def test_getoutput(self):
129 129 out, err = getoutputerror('python "%s"' % self.fname)
130 self.assertEquals(out, 'on stdout')
131 self.assertEquals(err, 'on stderr')
130 self.assertEqual(out, 'on stdout')
131 self.assertEqual(err, 'on stderr')
@@ -60,7 +60,7 b' class TestTraitType(TestCase):'
60 60 class A(HasTraits):
61 61 a = TraitType
62 62 a = A()
63 self.assertEquals(a.a, Undefined)
63 self.assertEqual(a.a, Undefined)
64 64
65 65 def test_set(self):
66 66 class A(HasTraitsStub):
@@ -68,10 +68,10 b' class TestTraitType(TestCase):'
68 68
69 69 a = A()
70 70 a.a = 10
71 self.assertEquals(a.a, 10)
72 self.assertEquals(a._notify_name, 'a')
73 self.assertEquals(a._notify_old, Undefined)
74 self.assertEquals(a._notify_new, 10)
71 self.assertEqual(a.a, 10)
72 self.assertEqual(a._notify_name, 'a')
73 self.assertEqual(a._notify_old, Undefined)
74 self.assertEqual(a._notify_new, 10)
75 75
76 76 def test_validate(self):
77 77 class MyTT(TraitType):
@@ -82,7 +82,7 b' class TestTraitType(TestCase):'
82 82
83 83 a = A()
84 84 a.tt = 10
85 self.assertEquals(a.tt, -1)
85 self.assertEqual(a.tt, -1)
86 86
87 87 def test_default_validate(self):
88 88 class MyIntTT(TraitType):
@@ -93,7 +93,7 b' class TestTraitType(TestCase):'
93 93 class A(HasTraits):
94 94 tt = MyIntTT(10)
95 95 a = A()
96 self.assertEquals(a.tt, 10)
96 self.assertEqual(a.tt, 10)
97 97
98 98 # Defaults are validated when the HasTraits is instantiated
99 99 class B(HasTraits):
@@ -109,7 +109,7 b' class TestTraitType(TestCase):'
109 109
110 110 a = A()
111 111 a.tt = 10
112 self.assertEquals(a.tt, 10)
112 self.assertEqual(a.tt, 10)
113 113
114 114 def test_value_for(self):
115 115 class MyTT(TraitType):
@@ -120,13 +120,13 b' class TestTraitType(TestCase):'
120 120
121 121 a = A()
122 122 a.tt = 10
123 self.assertEquals(a.tt, 20)
123 self.assertEqual(a.tt, 20)
124 124
125 125 def test_info(self):
126 126 class A(HasTraits):
127 127 tt = TraitType
128 128 a = A()
129 self.assertEquals(A.tt.info(), 'any value')
129 self.assertEqual(A.tt.info(), 'any value')
130 130
131 131 def test_error(self):
132 132 class A(HasTraits):
@@ -146,59 +146,59 b' class TestTraitType(TestCase):'
146 146 return 21
147 147
148 148 a = A()
149 self.assertEquals(a._trait_values, {})
150 self.assertEquals(a._trait_dyn_inits.keys(), ['x'])
151 self.assertEquals(a.x, 11)
152 self.assertEquals(a._trait_values, {'x': 11})
149 self.assertEqual(a._trait_values, {})
150 self.assertEqual(a._trait_dyn_inits.keys(), ['x'])
151 self.assertEqual(a.x, 11)
152 self.assertEqual(a._trait_values, {'x': 11})
153 153 b = B()
154 self.assertEquals(b._trait_values, {'x': 20})
155 self.assertEquals(a._trait_dyn_inits.keys(), ['x'])
156 self.assertEquals(b.x, 20)
154 self.assertEqual(b._trait_values, {'x': 20})
155 self.assertEqual(a._trait_dyn_inits.keys(), ['x'])
156 self.assertEqual(b.x, 20)
157 157 c = C()
158 self.assertEquals(c._trait_values, {})
159 self.assertEquals(a._trait_dyn_inits.keys(), ['x'])
160 self.assertEquals(c.x, 21)
161 self.assertEquals(c._trait_values, {'x': 21})
158 self.assertEqual(c._trait_values, {})
159 self.assertEqual(a._trait_dyn_inits.keys(), ['x'])
160 self.assertEqual(c.x, 21)
161 self.assertEqual(c._trait_values, {'x': 21})
162 162 # Ensure that the base class remains unmolested when the _default
163 163 # initializer gets overridden in a subclass.
164 164 a = A()
165 165 c = C()
166 self.assertEquals(a._trait_values, {})
167 self.assertEquals(a._trait_dyn_inits.keys(), ['x'])
168 self.assertEquals(a.x, 11)
169 self.assertEquals(a._trait_values, {'x': 11})
166 self.assertEqual(a._trait_values, {})
167 self.assertEqual(a._trait_dyn_inits.keys(), ['x'])
168 self.assertEqual(a.x, 11)
169 self.assertEqual(a._trait_values, {'x': 11})
170 170
171 171
172 172
173 173 class TestHasTraitsMeta(TestCase):
174 174
175 175 def test_metaclass(self):
176 self.assertEquals(type(HasTraits), MetaHasTraits)
176 self.assertEqual(type(HasTraits), MetaHasTraits)
177 177
178 178 class A(HasTraits):
179 179 a = Int
180 180
181 181 a = A()
182 self.assertEquals(type(a.__class__), MetaHasTraits)
183 self.assertEquals(a.a,0)
182 self.assertEqual(type(a.__class__), MetaHasTraits)
183 self.assertEqual(a.a,0)
184 184 a.a = 10
185 self.assertEquals(a.a,10)
185 self.assertEqual(a.a,10)
186 186
187 187 class B(HasTraits):
188 188 b = Int()
189 189
190 190 b = B()
191 self.assertEquals(b.b,0)
191 self.assertEqual(b.b,0)
192 192 b.b = 10
193 self.assertEquals(b.b,10)
193 self.assertEqual(b.b,10)
194 194
195 195 class C(HasTraits):
196 196 c = Int(30)
197 197
198 198 c = C()
199 self.assertEquals(c.c,30)
199 self.assertEqual(c.c,30)
200 200 c.c = 10
201 self.assertEquals(c.c,10)
201 self.assertEqual(c.c,10)
202 202
203 203 def test_this_class(self):
204 204 class A(HasTraits):
@@ -207,10 +207,10 b' class TestHasTraitsMeta(TestCase):'
207 207 class B(A):
208 208 tt = This()
209 209 ttt = This()
210 self.assertEquals(A.t.this_class, A)
211 self.assertEquals(B.t.this_class, A)
212 self.assertEquals(B.tt.this_class, B)
213 self.assertEquals(B.ttt.this_class, B)
210 self.assertEqual(A.t.this_class, A)
211 self.assertEqual(B.t.this_class, A)
212 self.assertEqual(B.tt.this_class, B)
213 self.assertEqual(B.ttt.this_class, B)
214 214
215 215 class TestHasTraitsNotify(TestCase):
216 216
@@ -233,9 +233,9 b' class TestHasTraitsNotify(TestCase):'
233 233 a = A()
234 234 a.on_trait_change(self.notify1)
235 235 a.a = 0
236 self.assertEquals(len(self._notify1),0)
236 self.assertEqual(len(self._notify1),0)
237 237 a.b = 0.0
238 self.assertEquals(len(self._notify1),0)
238 self.assertEqual(len(self._notify1),0)
239 239 a.a = 10
240 240 self.assert_(('a',0,10) in self._notify1)
241 241 a.b = 10.0
@@ -246,7 +246,7 b' class TestHasTraitsNotify(TestCase):'
246 246 a.on_trait_change(self.notify1,remove=True)
247 247 a.a = 20
248 248 a.b = 20.0
249 self.assertEquals(len(self._notify1),0)
249 self.assertEqual(len(self._notify1),0)
250 250
251 251 def test_notify_one(self):
252 252
@@ -257,7 +257,7 b' class TestHasTraitsNotify(TestCase):'
257 257 a = A()
258 258 a.on_trait_change(self.notify1, 'a')
259 259 a.a = 0
260 self.assertEquals(len(self._notify1),0)
260 self.assertEqual(len(self._notify1),0)
261 261 a.a = 10
262 262 self.assert_(('a',0,10) in self._notify1)
263 263 self.assertRaises(TraitError,setattr,a,'a','bad string')
@@ -271,12 +271,12 b' class TestHasTraitsNotify(TestCase):'
271 271 b = Float
272 272
273 273 b = B()
274 self.assertEquals(b.a,0)
275 self.assertEquals(b.b,0.0)
274 self.assertEqual(b.a,0)
275 self.assertEqual(b.b,0.0)
276 276 b.a = 100
277 277 b.b = 100.0
278 self.assertEquals(b.a,100)
279 self.assertEquals(b.b,100.0)
278 self.assertEqual(b.a,100)
279 self.assertEqual(b.b,100.0)
280 280
281 281 def test_notify_subclass(self):
282 282
@@ -291,8 +291,8 b' class TestHasTraitsNotify(TestCase):'
291 291 b.on_trait_change(self.notify2, 'b')
292 292 b.a = 0
293 293 b.b = 0.0
294 self.assertEquals(len(self._notify1),0)
295 self.assertEquals(len(self._notify2),0)
294 self.assertEqual(len(self._notify1),0)
295 self.assertEqual(len(self._notify2),0)
296 296 b.a = 10
297 297 b.b = 10.0
298 298 self.assert_(('a',0,10) in self._notify1)
@@ -309,7 +309,7 b' class TestHasTraitsNotify(TestCase):'
309 309 a = A()
310 310 a.a = 0
311 311 # This is broken!!!
312 self.assertEquals(len(a._notify1),0)
312 self.assertEqual(len(a._notify1),0)
313 313 a.a = 10
314 314 self.assert_(('a',0,10) in a._notify1)
315 315
@@ -342,25 +342,25 b' class TestHasTraitsNotify(TestCase):'
342 342 a = A()
343 343 a.on_trait_change(callback0, 'a')
344 344 a.a = 10
345 self.assertEquals(self.cb,())
345 self.assertEqual(self.cb,())
346 346 a.on_trait_change(callback0, 'a', remove=True)
347 347
348 348 a.on_trait_change(callback1, 'a')
349 349 a.a = 100
350 self.assertEquals(self.cb,('a',))
350 self.assertEqual(self.cb,('a',))
351 351 a.on_trait_change(callback1, 'a', remove=True)
352 352
353 353 a.on_trait_change(callback2, 'a')
354 354 a.a = 1000
355 self.assertEquals(self.cb,('a',1000))
355 self.assertEqual(self.cb,('a',1000))
356 356 a.on_trait_change(callback2, 'a', remove=True)
357 357
358 358 a.on_trait_change(callback3, 'a')
359 359 a.a = 10000
360 self.assertEquals(self.cb,('a',1000,10000))
360 self.assertEqual(self.cb,('a',1000,10000))
361 361 a.on_trait_change(callback3, 'a', remove=True)
362 362
363 self.assertEquals(len(a._trait_notifiers['a']),0)
363 self.assertEqual(len(a._trait_notifiers['a']),0)
364 364
365 365
366 366 class TestHasTraits(TestCase):
@@ -370,22 +370,22 b' class TestHasTraits(TestCase):'
370 370 i = Int
371 371 f = Float
372 372 a = A()
373 self.assertEquals(sorted(a.trait_names()),['f','i'])
374 self.assertEquals(sorted(A.class_trait_names()),['f','i'])
373 self.assertEqual(sorted(a.trait_names()),['f','i'])
374 self.assertEqual(sorted(A.class_trait_names()),['f','i'])
375 375
376 376 def test_trait_metadata(self):
377 377 class A(HasTraits):
378 378 i = Int(config_key='MY_VALUE')
379 379 a = A()
380 self.assertEquals(a.trait_metadata('i','config_key'), 'MY_VALUE')
380 self.assertEqual(a.trait_metadata('i','config_key'), 'MY_VALUE')
381 381
382 382 def test_traits(self):
383 383 class A(HasTraits):
384 384 i = Int
385 385 f = Float
386 386 a = A()
387 self.assertEquals(a.traits(), dict(i=A.i, f=A.f))
388 self.assertEquals(A.class_traits(), dict(i=A.i, f=A.f))
387 self.assertEqual(a.traits(), dict(i=A.i, f=A.f))
388 self.assertEqual(A.class_traits(), dict(i=A.i, f=A.f))
389 389
390 390 def test_traits_metadata(self):
391 391 class A(HasTraits):
@@ -393,22 +393,22 b' class TestHasTraits(TestCase):'
393 393 f = Float(config_key='VALUE3', other_thing='VALUE2')
394 394 j = Int(0)
395 395 a = A()
396 self.assertEquals(a.traits(), dict(i=A.i, f=A.f, j=A.j))
396 self.assertEqual(a.traits(), dict(i=A.i, f=A.f, j=A.j))
397 397 traits = a.traits(config_key='VALUE1', other_thing='VALUE2')
398 self.assertEquals(traits, dict(i=A.i))
398 self.assertEqual(traits, dict(i=A.i))
399 399
400 400 # This passes, but it shouldn't because I am replicating a bug in
401 401 # traits.
402 402 traits = a.traits(config_key=lambda v: True)
403 self.assertEquals(traits, dict(i=A.i, f=A.f, j=A.j))
403 self.assertEqual(traits, dict(i=A.i, f=A.f, j=A.j))
404 404
405 405 def test_init(self):
406 406 class A(HasTraits):
407 407 i = Int()
408 408 x = Float()
409 409 a = A(i=1, x=10.0)
410 self.assertEquals(a.i, 1)
411 self.assertEquals(a.x, 10.0)
410 self.assertEqual(a.i, 1)
411 self.assertEqual(a.x, 10.0)
412 412
413 413 #-----------------------------------------------------------------------------
414 414 # Tests for specific trait types
@@ -424,10 +424,10 b' class TestType(TestCase):'
424 424 klass = Type
425 425
426 426 a = A()
427 self.assertEquals(a.klass, None)
427 self.assertEqual(a.klass, None)
428 428
429 429 a.klass = B
430 self.assertEquals(a.klass, B)
430 self.assertEqual(a.klass, B)
431 431 self.assertRaises(TraitError, setattr, a, 'klass', 10)
432 432
433 433 def test_value(self):
@@ -438,7 +438,7 b' class TestType(TestCase):'
438 438 klass = Type(B)
439 439
440 440 a = A()
441 self.assertEquals(a.klass, B)
441 self.assertEqual(a.klass, B)
442 442 self.assertRaises(TraitError, setattr, a, 'klass', C)
443 443 self.assertRaises(TraitError, setattr, a, 'klass', object)
444 444 a.klass = B
@@ -451,10 +451,10 b' class TestType(TestCase):'
451 451 klass = Type(B, allow_none=False)
452 452
453 453 a = A()
454 self.assertEquals(a.klass, B)
454 self.assertEqual(a.klass, B)
455 455 self.assertRaises(TraitError, setattr, a, 'klass', None)
456 456 a.klass = C
457 self.assertEquals(a.klass, C)
457 self.assertEqual(a.klass, C)
458 458
459 459 def test_validate_klass(self):
460 460
@@ -489,7 +489,7 b' class TestType(TestCase):'
489 489 from IPython.utils.ipstruct import Struct
490 490 a = A()
491 491 a.klass = Struct
492 self.assertEquals(a.klass, Struct)
492 self.assertEqual(a.klass, Struct)
493 493
494 494 self.assertRaises(TraitError, setattr, a, 'klass', 10)
495 495
@@ -533,13 +533,13 b' class TestInstance(TestCase):'
533 533 class A(HasTraits):
534 534 inst = Instance(Foo, (10,))
535 535 a = A()
536 self.assertEquals(a.inst.c, 10)
536 self.assertEqual(a.inst.c, 10)
537 537
538 538 class B(HasTraits):
539 539 inst = Instance(Bah, args=(10,), kw=dict(d=20))
540 540 b = B()
541 self.assertEquals(b.inst.c, 10)
542 self.assertEquals(b.inst.d, 20)
541 self.assertEqual(b.inst.c, 10)
542 self.assertEqual(b.inst.d, 20)
543 543
544 544 class C(HasTraits):
545 545 inst = Instance(Foo)
@@ -571,10 +571,10 b' class TestThis(TestCase):'
571 571 this = This
572 572
573 573 f = Foo()
574 self.assertEquals(f.this, None)
574 self.assertEqual(f.this, None)
575 575 g = Foo()
576 576 f.this = g
577 self.assertEquals(f.this, g)
577 self.assertEqual(f.this, g)
578 578 self.assertRaises(TraitError, setattr, f, 'this', 10)
579 579
580 580 def test_this_inst(self):
@@ -594,8 +594,8 b' class TestThis(TestCase):'
594 594 b = Bar()
595 595 f.t = b
596 596 b.t = f
597 self.assertEquals(f.t, b)
598 self.assertEquals(b.t, f)
597 self.assertEqual(f.t, b)
598 self.assertEqual(b.t, f)
599 599
600 600 def test_subclass_override(self):
601 601 class Foo(HasTraits):
@@ -605,7 +605,7 b' class TestThis(TestCase):'
605 605 f = Foo()
606 606 b = Bar()
607 607 f.t = b
608 self.assertEquals(f.t, b)
608 self.assertEqual(f.t, b)
609 609 self.assertRaises(TraitError, setattr, b, 't', f)
610 610
611 611 class TraitTestBase(TestCase):
@@ -621,7 +621,7 b' class TraitTestBase(TestCase):'
621 621 if hasattr(self, '_good_values'):
622 622 for value in self._good_values:
623 623 self.assign(value)
624 self.assertEquals(self.obj.value, self.coerce(value))
624 self.assertEqual(self.obj.value, self.coerce(value))
625 625
626 626 def test_bad_values(self):
627 627 if hasattr(self, '_bad_values'):
@@ -633,7 +633,7 b' class TraitTestBase(TestCase):'
633 633
634 634 def test_default_value(self):
635 635 if hasattr(self, '_default_value'):
636 self.assertEquals(self._default_value, self.obj.value)
636 self.assertEqual(self._default_value, self.obj.value)
637 637
638 638 def tearDown(self):
639 639 # restore default value after tests, if set
@@ -692,7 +692,7 b' class TestLong(TraitTestBase):'
692 692 def test_cast_small(self):
693 693 """Long casts ints to long"""
694 694 self.obj.value = 10
695 self.assertEquals(type(self.obj.value), long)
695 self.assertEqual(type(self.obj.value), long)
696 696
697 697
698 698 class IntegerTrait(HasTraits):
@@ -712,7 +712,7 b' class TestInteger(TestLong):'
712 712 raise SkipTest("not relevant on py3")
713 713
714 714 self.obj.value = 100L
715 self.assertEquals(type(self.obj.value), int)
715 self.assertEqual(type(self.obj.value), int)
716 716
717 717
718 718 class FloatTrait(HasTraits):
@@ -49,28 +49,28 b' class TestSession(SessionTestCase):'
49 49 msg = self.session.msg('execute')
50 50 thekeys = set('header parent_header content msg_type msg_id'.split())
51 51 s = set(msg.keys())
52 self.assertEquals(s, thekeys)
52 self.assertEqual(s, thekeys)
53 53 self.assertTrue(isinstance(msg['content'],dict))
54 54 self.assertTrue(isinstance(msg['header'],dict))
55 55 self.assertTrue(isinstance(msg['parent_header'],dict))
56 56 self.assertTrue(isinstance(msg['msg_id'],str))
57 57 self.assertTrue(isinstance(msg['msg_type'],str))
58 self.assertEquals(msg['header']['msg_type'], 'execute')
59 self.assertEquals(msg['msg_type'], 'execute')
58 self.assertEqual(msg['header']['msg_type'], 'execute')
59 self.assertEqual(msg['msg_type'], 'execute')
60 60
61 61 def test_serialize(self):
62 62 msg = self.session.msg('execute', content=dict(a=10, b=1.1))
63 63 msg_list = self.session.serialize(msg, ident=b'foo')
64 64 ident, msg_list = self.session.feed_identities(msg_list)
65 65 new_msg = self.session.unserialize(msg_list)
66 self.assertEquals(ident[0], b'foo')
67 self.assertEquals(new_msg['msg_id'],msg['msg_id'])
68 self.assertEquals(new_msg['msg_type'],msg['msg_type'])
69 self.assertEquals(new_msg['header'],msg['header'])
70 self.assertEquals(new_msg['content'],msg['content'])
71 self.assertEquals(new_msg['parent_header'],msg['parent_header'])
66 self.assertEqual(ident[0], b'foo')
67 self.assertEqual(new_msg['msg_id'],msg['msg_id'])
68 self.assertEqual(new_msg['msg_type'],msg['msg_type'])
69 self.assertEqual(new_msg['header'],msg['header'])
70 self.assertEqual(new_msg['content'],msg['content'])
71 self.assertEqual(new_msg['parent_header'],msg['parent_header'])
72 72 # ensure floats don't come out as Decimal:
73 self.assertEquals(type(new_msg['content']['b']),type(new_msg['content']['b']))
73 self.assertEqual(type(new_msg['content']['b']),type(new_msg['content']['b']))
74 74
75 75 def test_send(self):
76 76 socket = MockSocket(zmq.Context.instance(),zmq.PAIR)
@@ -79,13 +79,13 b' class TestSession(SessionTestCase):'
79 79 self.session.send(socket, msg, ident=b'foo', buffers=[b'bar'])
80 80 ident, msg_list = self.session.feed_identities(socket.data)
81 81 new_msg = self.session.unserialize(msg_list)
82 self.assertEquals(ident[0], b'foo')
83 self.assertEquals(new_msg['msg_id'],msg['msg_id'])
84 self.assertEquals(new_msg['msg_type'],msg['msg_type'])
85 self.assertEquals(new_msg['header'],msg['header'])
86 self.assertEquals(new_msg['content'],msg['content'])
87 self.assertEquals(new_msg['parent_header'],msg['parent_header'])
88 self.assertEquals(new_msg['buffers'],[b'bar'])
82 self.assertEqual(ident[0], b'foo')
83 self.assertEqual(new_msg['msg_id'],msg['msg_id'])
84 self.assertEqual(new_msg['msg_type'],msg['msg_type'])
85 self.assertEqual(new_msg['header'],msg['header'])
86 self.assertEqual(new_msg['content'],msg['content'])
87 self.assertEqual(new_msg['parent_header'],msg['parent_header'])
88 self.assertEqual(new_msg['buffers'],[b'bar'])
89 89
90 90 socket.data = []
91 91
@@ -97,25 +97,25 b' class TestSession(SessionTestCase):'
97 97 header=header, ident=b'foo', buffers=[b'bar'])
98 98 ident, msg_list = self.session.feed_identities(socket.data)
99 99 new_msg = self.session.unserialize(msg_list)
100 self.assertEquals(ident[0], b'foo')
101 self.assertEquals(new_msg['msg_id'],msg['msg_id'])
102 self.assertEquals(new_msg['msg_type'],msg['msg_type'])
103 self.assertEquals(new_msg['header'],msg['header'])
104 self.assertEquals(new_msg['content'],msg['content'])
105 self.assertEquals(new_msg['parent_header'],msg['parent_header'])
106 self.assertEquals(new_msg['buffers'],[b'bar'])
100 self.assertEqual(ident[0], b'foo')
101 self.assertEqual(new_msg['msg_id'],msg['msg_id'])
102 self.assertEqual(new_msg['msg_type'],msg['msg_type'])
103 self.assertEqual(new_msg['header'],msg['header'])
104 self.assertEqual(new_msg['content'],msg['content'])
105 self.assertEqual(new_msg['parent_header'],msg['parent_header'])
106 self.assertEqual(new_msg['buffers'],[b'bar'])
107 107
108 108 socket.data = []
109 109
110 110 self.session.send(socket, msg, ident=b'foo', buffers=[b'bar'])
111 111 ident, new_msg = self.session.recv(socket)
112 self.assertEquals(ident[0], b'foo')
113 self.assertEquals(new_msg['msg_id'],msg['msg_id'])
114 self.assertEquals(new_msg['msg_type'],msg['msg_type'])
115 self.assertEquals(new_msg['header'],msg['header'])
116 self.assertEquals(new_msg['content'],msg['content'])
117 self.assertEquals(new_msg['parent_header'],msg['parent_header'])
118 self.assertEquals(new_msg['buffers'],[b'bar'])
112 self.assertEqual(ident[0], b'foo')
113 self.assertEqual(new_msg['msg_id'],msg['msg_id'])
114 self.assertEqual(new_msg['msg_type'],msg['msg_type'])
115 self.assertEqual(new_msg['header'],msg['header'])
116 self.assertEqual(new_msg['content'],msg['content'])
117 self.assertEqual(new_msg['parent_header'],msg['parent_header'])
118 self.assertEqual(new_msg['buffers'],[b'bar'])
119 119
120 120 socket.close()
121 121
@@ -124,17 +124,17 b' class TestSession(SessionTestCase):'
124 124 s = self.session
125 125 self.assertTrue(s.pack is ss.default_packer)
126 126 self.assertTrue(s.unpack is ss.default_unpacker)
127 self.assertEquals(s.username, os.environ.get('USER', u'username'))
127 self.assertEqual(s.username, os.environ.get('USER', u'username'))
128 128
129 129 s = ss.Session()
130 self.assertEquals(s.username, os.environ.get('USER', u'username'))
130 self.assertEqual(s.username, os.environ.get('USER', u'username'))
131 131
132 132 self.assertRaises(TypeError, ss.Session, pack='hi')
133 133 self.assertRaises(TypeError, ss.Session, unpack='hi')
134 134 u = str(uuid.uuid4())
135 135 s = ss.Session(username=u'carrot', session=u)
136 self.assertEquals(s.session, u)
137 self.assertEquals(s.username, u'carrot')
136 self.assertEqual(s.session, u)
137 self.assertEqual(s.username, u'carrot')
138 138
139 139 def test_tracking(self):
140 140 """test tracking messages"""
@@ -162,12 +162,12 b' class TestSession(SessionTestCase):'
162 162 # d = {'0': uuid.uuid4(), 1:uuid.uuid4(), 'asdf':uuid.uuid4()}
163 163 # d2 = {0:d['0'],1:d[1],'asdf':d['asdf']}
164 164 # rd = ss.rekey(d)
165 # self.assertEquals(d2,rd)
165 # self.assertEqual(d2,rd)
166 166 #
167 167 # d = {'1.5':uuid.uuid4(),'1':uuid.uuid4()}
168 168 # d2 = {1.5:d['1.5'],1:d['1']}
169 169 # rd = ss.rekey(d)
170 # self.assertEquals(d2,rd)
170 # self.assertEqual(d2,rd)
171 171 #
172 172 # d = {'1.0':uuid.uuid4(),'1':uuid.uuid4()}
173 173 # self.assertRaises(KeyError, ss.rekey, d)
@@ -193,20 +193,20 b' class TestSession(SessionTestCase):'
193 193 # get bs before us
194 194 bs = session.bsession
195 195 us = session.session
196 self.assertEquals(us.encode('ascii'), bs)
196 self.assertEqual(us.encode('ascii'), bs)
197 197 session = ss.Session()
198 198 # get us before bs
199 199 us = session.session
200 200 bs = session.bsession
201 self.assertEquals(us.encode('ascii'), bs)
201 self.assertEqual(us.encode('ascii'), bs)
202 202 # change propagates:
203 203 session.session = 'something else'
204 204 bs = session.bsession
205 205 us = session.session
206 self.assertEquals(us.encode('ascii'), bs)
206 self.assertEqual(us.encode('ascii'), bs)
207 207 session = ss.Session(session='stuff')
208 208 # get us before bs
209 self.assertEquals(session.bsession, session.session.encode('ascii'))
210 self.assertEquals(b'stuff', session.bsession)
209 self.assertEqual(session.bsession, session.session.encode('ascii'))
210 self.assertEqual(b'stuff', session.bsession)
211 211
212 212
General Comments 0
You need to be logged in to leave comments. Login now