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