From 4a6836ce8d8414d944e10b6cf67a143d9cd7e908 2012-07-17 15:30:53 From: Bradley M. Froehle Date: 2012-07-17 15:30:53 Subject: [PATCH] s/assertEquals/assertEqual/ --- diff --git a/IPython/config/tests/test_application.py b/IPython/config/tests/test_application.py index 0fae929..63b9301 100644 --- a/IPython/config/tests/test_application.py +++ b/IPython/config/tests/test_application.py @@ -82,94 +82,94 @@ class TestApplication(TestCase): def test_basic(self): app = MyApp() - self.assertEquals(app.name, u'myapp') - self.assertEquals(app.running, False) - self.assertEquals(app.classes, [MyApp,Bar,Foo]) - self.assertEquals(app.config_file, u'') + self.assertEqual(app.name, u'myapp') + self.assertEqual(app.running, False) + self.assertEqual(app.classes, [MyApp,Bar,Foo]) + self.assertEqual(app.config_file, u'') def test_config(self): app = MyApp() app.parse_command_line(["--i=10","--Foo.j=10","--enabled=False","--log-level=50"]) config = app.config - self.assertEquals(config.Foo.i, 10) - self.assertEquals(config.Foo.j, 10) - self.assertEquals(config.Bar.enabled, False) - self.assertEquals(config.MyApp.log_level,50) + self.assertEqual(config.Foo.i, 10) + self.assertEqual(config.Foo.j, 10) + self.assertEqual(config.Bar.enabled, False) + self.assertEqual(config.MyApp.log_level,50) def test_config_propagation(self): app = MyApp() app.parse_command_line(["--i=10","--Foo.j=10","--enabled=False","--log-level=50"]) app.init_foo() app.init_bar() - self.assertEquals(app.foo.i, 10) - self.assertEquals(app.foo.j, 10) - self.assertEquals(app.bar.enabled, False) + self.assertEqual(app.foo.i, 10) + self.assertEqual(app.foo.j, 10) + self.assertEqual(app.bar.enabled, False) def test_flags(self): app = MyApp() app.parse_command_line(["--disable"]) app.init_bar() - self.assertEquals(app.bar.enabled, False) + self.assertEqual(app.bar.enabled, False) app.parse_command_line(["--enable"]) app.init_bar() - self.assertEquals(app.bar.enabled, True) + self.assertEqual(app.bar.enabled, True) def test_aliases(self): app = MyApp() app.parse_command_line(["--i=5", "--j=10"]) app.init_foo() - self.assertEquals(app.foo.i, 5) + self.assertEqual(app.foo.i, 5) app.init_foo() - self.assertEquals(app.foo.j, 10) + self.assertEqual(app.foo.j, 10) def test_flag_clobber(self): """test that setting flags doesn't clobber existing settings""" app = MyApp() app.parse_command_line(["--Bar.b=5", "--disable"]) app.init_bar() - self.assertEquals(app.bar.enabled, False) - self.assertEquals(app.bar.b, 5) + self.assertEqual(app.bar.enabled, False) + self.assertEqual(app.bar.b, 5) app.parse_command_line(["--enable", "--Bar.b=10"]) app.init_bar() - self.assertEquals(app.bar.enabled, True) - self.assertEquals(app.bar.b, 10) + self.assertEqual(app.bar.enabled, True) + self.assertEqual(app.bar.b, 10) def test_flatten_flags(self): cfg = Config() cfg.MyApp.log_level = logging.WARN app = MyApp() app.update_config(cfg) - self.assertEquals(app.log_level, logging.WARN) - self.assertEquals(app.config.MyApp.log_level, logging.WARN) + self.assertEqual(app.log_level, logging.WARN) + self.assertEqual(app.config.MyApp.log_level, logging.WARN) app.initialize(["--crit"]) - self.assertEquals(app.log_level, logging.CRITICAL) + self.assertEqual(app.log_level, logging.CRITICAL) # this would be app.config.Application.log_level if it failed: - self.assertEquals(app.config.MyApp.log_level, logging.CRITICAL) + self.assertEqual(app.config.MyApp.log_level, logging.CRITICAL) def test_flatten_aliases(self): cfg = Config() cfg.MyApp.log_level = logging.WARN app = MyApp() app.update_config(cfg) - self.assertEquals(app.log_level, logging.WARN) - self.assertEquals(app.config.MyApp.log_level, logging.WARN) + self.assertEqual(app.log_level, logging.WARN) + self.assertEqual(app.config.MyApp.log_level, logging.WARN) app.initialize(["--log-level", "CRITICAL"]) - self.assertEquals(app.log_level, logging.CRITICAL) + self.assertEqual(app.log_level, logging.CRITICAL) # this would be app.config.Application.log_level if it failed: - self.assertEquals(app.config.MyApp.log_level, "CRITICAL") + self.assertEqual(app.config.MyApp.log_level, "CRITICAL") def test_extra_args(self): app = MyApp() app.parse_command_line(["--Bar.b=5", 'extra', "--disable", 'args']) app.init_bar() - self.assertEquals(app.bar.enabled, False) - self.assertEquals(app.bar.b, 5) - self.assertEquals(app.extra_args, ['extra', 'args']) + self.assertEqual(app.bar.enabled, False) + self.assertEqual(app.bar.b, 5) + self.assertEqual(app.extra_args, ['extra', 'args']) app = MyApp() app.parse_command_line(["--Bar.b=5", '--', 'extra', "--disable", 'args']) app.init_bar() - self.assertEquals(app.bar.enabled, True) - self.assertEquals(app.bar.b, 5) - self.assertEquals(app.extra_args, ['extra', '--disable', 'args']) + self.assertEqual(app.bar.enabled, True) + self.assertEqual(app.bar.b, 5) + self.assertEqual(app.extra_args, ['extra', '--disable', 'args']) diff --git a/IPython/config/tests/test_configurable.py b/IPython/config/tests/test_configurable.py index 88f2077..acc41f5 100644 --- a/IPython/config/tests/test_configurable.py +++ b/IPython/config/tests/test_configurable.py @@ -83,8 +83,8 @@ class TestConfigurable(TestCase): c1 = Configurable() c2 = Configurable(config=c1.config) c3 = Configurable(config=c2.config) - self.assertEquals(c1.config, c2.config) - self.assertEquals(c2.config, c3.config) + self.assertEqual(c1.config, c2.config) + self.assertEqual(c2.config, c3.config) def test_custom(self): config = Config() @@ -93,9 +93,9 @@ class TestConfigurable(TestCase): c1 = Configurable(config=config) c2 = Configurable(config=c1.config) c3 = Configurable(config=c2.config) - self.assertEquals(c1.config, config) - self.assertEquals(c2.config, config) - self.assertEquals(c3.config, config) + self.assertEqual(c1.config, config) + self.assertEqual(c2.config, config) + self.assertEqual(c3.config, config) # Test that copies are not made self.assert_(c1.config is config) self.assert_(c2.config is config) @@ -109,10 +109,10 @@ class TestConfigurable(TestCase): config.MyConfigurable.b = 2.0 c1 = MyConfigurable(config=config) c2 = MyConfigurable(config=c1.config) - self.assertEquals(c1.a, config.MyConfigurable.a) - self.assertEquals(c1.b, config.MyConfigurable.b) - self.assertEquals(c2.a, config.MyConfigurable.a) - self.assertEquals(c2.b, config.MyConfigurable.b) + self.assertEqual(c1.a, config.MyConfigurable.a) + self.assertEqual(c1.b, config.MyConfigurable.b) + self.assertEqual(c2.a, config.MyConfigurable.a) + self.assertEqual(c2.b, config.MyConfigurable.b) def test_parent(self): config = Config() @@ -122,19 +122,19 @@ class TestConfigurable(TestCase): config.Bar.c = 100.0 f = Foo(config=config) b = Bar(config=f.config) - self.assertEquals(f.a, 10) - self.assertEquals(f.b, 'wow') - self.assertEquals(b.b, 'gotit') - self.assertEquals(b.c, 100.0) + self.assertEqual(f.a, 10) + self.assertEqual(f.b, 'wow') + self.assertEqual(b.b, 'gotit') + self.assertEqual(b.c, 100.0) def test_override1(self): config = Config() config.MyConfigurable.a = 2 config.MyConfigurable.b = 2.0 c = MyConfigurable(a=3, config=config) - self.assertEquals(c.a, 3) - self.assertEquals(c.b, config.MyConfigurable.b) - self.assertEquals(c.c, 'no config') + self.assertEqual(c.a, 3) + self.assertEqual(c.b, config.MyConfigurable.b) + self.assertEqual(c.c, 'no config') def test_override2(self): config = Config() @@ -142,20 +142,20 @@ class TestConfigurable(TestCase): config.Bar.b = 'or' # Up above b is config=False, so this won't do it. config.Bar.c = 10.0 c = Bar(config=config) - self.assertEquals(c.a, config.Foo.a) - self.assertEquals(c.b, 'gotit') - self.assertEquals(c.c, config.Bar.c) + self.assertEqual(c.a, config.Foo.a) + self.assertEqual(c.b, 'gotit') + self.assertEqual(c.c, config.Bar.c) c = Bar(a=2, b='and', c=20.0, config=config) - self.assertEquals(c.a, 2) - self.assertEquals(c.b, 'and') - self.assertEquals(c.c, 20.0) + self.assertEqual(c.a, 2) + self.assertEqual(c.b, 'and') + self.assertEqual(c.c, 20.0) def test_help(self): - self.assertEquals(MyConfigurable.class_get_help(), mc_help) + self.assertEqual(MyConfigurable.class_get_help(), mc_help) def test_help_inst(self): inst = MyConfigurable(a=5, b=4) - self.assertEquals(MyConfigurable.class_get_help(inst), mc_help_inst) + self.assertEqual(MyConfigurable.class_get_help(inst), mc_help_inst) class TestSingletonConfigurable(TestCase): @@ -163,21 +163,21 @@ class TestSingletonConfigurable(TestCase): def test_instance(self): from IPython.config.configurable import SingletonConfigurable class Foo(SingletonConfigurable): pass - self.assertEquals(Foo.initialized(), False) + self.assertEqual(Foo.initialized(), False) foo = Foo.instance() - self.assertEquals(Foo.initialized(), True) - self.assertEquals(foo, Foo.instance()) - self.assertEquals(SingletonConfigurable._instance, None) + self.assertEqual(Foo.initialized(), True) + self.assertEqual(foo, Foo.instance()) + self.assertEqual(SingletonConfigurable._instance, None) def test_inheritance(self): class Bar(SingletonConfigurable): pass class Bam(Bar): pass - self.assertEquals(Bar.initialized(), False) - self.assertEquals(Bam.initialized(), False) + self.assertEqual(Bar.initialized(), False) + self.assertEqual(Bam.initialized(), False) bam = Bam.instance() bam == Bar.instance() - self.assertEquals(Bar.initialized(), True) - self.assertEquals(Bam.initialized(), True) - self.assertEquals(bam, Bam._instance) - self.assertEquals(bam, Bar._instance) - self.assertEquals(SingletonConfigurable._instance, None) + self.assertEqual(Bar.initialized(), True) + self.assertEqual(Bam.initialized(), True) + self.assertEqual(bam, Bam._instance) + self.assertEqual(bam, Bar._instance) + self.assertEqual(SingletonConfigurable._instance, None) diff --git a/IPython/config/tests/test_loader.py b/IPython/config/tests/test_loader.py index 9b23a18..bcb0be6 100644 --- a/IPython/config/tests/test_loader.py +++ b/IPython/config/tests/test_loader.py @@ -63,11 +63,11 @@ class TestPyFileCL(TestCase): # Unlink the file cl = PyFileConfigLoader(fname) config = cl.load_config() - self.assertEquals(config.a, 10) - self.assertEquals(config.b, 20) - self.assertEquals(config.Foo.Bar.value, 10) - self.assertEquals(config.Foo.Bam.value, range(10)) - self.assertEquals(config.D.C.value, 'hi there') + self.assertEqual(config.a, 10) + self.assertEqual(config.b, 20) + self.assertEqual(config.Foo.Bar.value, 10) + self.assertEqual(config.Foo.Bam.value, range(10)) + self.assertEqual(config.D.C.value, 'hi there') class MyLoader1(ArgParseConfigLoader): def _add_arguments(self, aliases=None, flags=None): @@ -90,31 +90,31 @@ class TestArgParseCL(TestCase): def test_basic(self): cl = MyLoader1() config = cl.load_config('-f hi -b 10 -n wow'.split()) - self.assertEquals(config.Global.foo, 'hi') - self.assertEquals(config.MyClass.bar, 10) - self.assertEquals(config.n, True) - self.assertEquals(config.Global.bam, 'wow') + self.assertEqual(config.Global.foo, 'hi') + self.assertEqual(config.MyClass.bar, 10) + self.assertEqual(config.n, True) + self.assertEqual(config.Global.bam, 'wow') config = cl.load_config(['wow']) - self.assertEquals(config.keys(), ['Global']) - self.assertEquals(config.Global.keys(), ['bam']) - self.assertEquals(config.Global.bam, 'wow') + self.assertEqual(config.keys(), ['Global']) + self.assertEqual(config.Global.keys(), ['bam']) + self.assertEqual(config.Global.bam, 'wow') def test_add_arguments(self): cl = MyLoader2() config = cl.load_config('2 frobble'.split()) - self.assertEquals(config.subparser_name, '2') - self.assertEquals(config.y, 'frobble') + self.assertEqual(config.subparser_name, '2') + self.assertEqual(config.y, 'frobble') config = cl.load_config('1 -x frobble'.split()) - self.assertEquals(config.subparser_name, '1') - self.assertEquals(config.Global.x, 'frobble') + self.assertEqual(config.subparser_name, '1') + self.assertEqual(config.Global.x, 'frobble') def test_argv(self): cl = MyLoader1(argv='-f hi -b 10 -n wow'.split()) config = cl.load_config() - self.assertEquals(config.Global.foo, 'hi') - self.assertEquals(config.MyClass.bar, 10) - self.assertEquals(config.n, True) - self.assertEquals(config.Global.bam, 'wow') + self.assertEqual(config.Global.foo, 'hi') + self.assertEqual(config.MyClass.bar, 10) + self.assertEqual(config.n, True) + self.assertEqual(config.Global.bam, 'wow') class TestKeyValueCL(TestCase): @@ -125,39 +125,39 @@ class TestKeyValueCL(TestCase): argv = ['--'+s.strip('c.') for s in pyfile.split('\n')[2:-1]] with mute_warn(): config = cl.load_config(argv) - self.assertEquals(config.a, 10) - self.assertEquals(config.b, 20) - self.assertEquals(config.Foo.Bar.value, 10) - self.assertEquals(config.Foo.Bam.value, range(10)) - self.assertEquals(config.D.C.value, 'hi there') + self.assertEqual(config.a, 10) + self.assertEqual(config.b, 20) + self.assertEqual(config.Foo.Bar.value, 10) + self.assertEqual(config.Foo.Bam.value, range(10)) + self.assertEqual(config.D.C.value, 'hi there') def test_expanduser(self): cl = self.klass() argv = ['--a=~/1/2/3', '--b=~', '--c=~/', '--d="~/"'] with mute_warn(): config = cl.load_config(argv) - self.assertEquals(config.a, os.path.expanduser('~/1/2/3')) - self.assertEquals(config.b, os.path.expanduser('~')) - self.assertEquals(config.c, os.path.expanduser('~/')) - self.assertEquals(config.d, '~/') + self.assertEqual(config.a, os.path.expanduser('~/1/2/3')) + self.assertEqual(config.b, os.path.expanduser('~')) + self.assertEqual(config.c, os.path.expanduser('~/')) + self.assertEqual(config.d, '~/') def test_extra_args(self): cl = self.klass() with mute_warn(): config = cl.load_config(['--a=5', 'b', '--c=10', 'd']) - self.assertEquals(cl.extra_args, ['b', 'd']) - self.assertEquals(config.a, 5) - self.assertEquals(config.c, 10) + self.assertEqual(cl.extra_args, ['b', 'd']) + self.assertEqual(config.a, 5) + self.assertEqual(config.c, 10) with mute_warn(): config = cl.load_config(['--', '--a=5', '--c=10']) - self.assertEquals(cl.extra_args, ['--a=5', '--c=10']) + self.assertEqual(cl.extra_args, ['--a=5', '--c=10']) def test_unicode_args(self): cl = self.klass() argv = [u'--a=épsîlön'] with mute_warn(): config = cl.load_config(argv) - self.assertEquals(config.a, u'épsîlön') + self.assertEqual(config.a, u'épsîlön') def test_unicode_bytes_args(self): uarg = u'--a=é' @@ -169,14 +169,14 @@ class TestKeyValueCL(TestCase): cl = self.klass() with mute_warn(): config = cl.load_config([barg]) - self.assertEquals(config.a, u'é') + self.assertEqual(config.a, u'é') def test_unicode_alias(self): cl = self.klass() argv = [u'--a=épsîlön'] with mute_warn(): config = cl.load_config(argv, aliases=dict(a='A.a')) - self.assertEquals(config.A.a, u'épsîlön') + self.assertEqual(config.A.a, u'épsîlön') class TestArgParseKVCL(TestKeyValueCL): @@ -187,15 +187,15 @@ class TestArgParseKVCL(TestKeyValueCL): argv = ['-a', '~/1/2/3', '--b', "'~/1/2/3'"] with mute_warn(): config = cl.load_config(argv, aliases=dict(a='A.a', b='A.b')) - self.assertEquals(config.A.a, os.path.expanduser('~/1/2/3')) - self.assertEquals(config.A.b, '~/1/2/3') + self.assertEqual(config.A.a, os.path.expanduser('~/1/2/3')) + self.assertEqual(config.A.b, '~/1/2/3') def test_eval(self): cl = self.klass() argv = ['-c', 'a=5'] with mute_warn(): config = cl.load_config(argv, aliases=dict(c='A.c')) - self.assertEquals(config.A.c, u"a=5") + self.assertEqual(config.A.c, u"a=5") class TestConfig(TestCase): @@ -203,19 +203,19 @@ class TestConfig(TestCase): def test_setget(self): c = Config() c.a = 10 - self.assertEquals(c.a, 10) - self.assertEquals('b' in c, False) + self.assertEqual(c.a, 10) + self.assertEqual('b' in c, False) def test_auto_section(self): c = Config() - self.assertEquals('A' in c, True) - self.assertEquals(c._has_section('A'), False) + self.assertEqual('A' in c, True) + self.assertEqual(c._has_section('A'), False) A = c.A A.foo = 'hi there' - self.assertEquals(c._has_section('A'), True) - self.assertEquals(c.A.foo, 'hi there') + self.assertEqual(c._has_section('A'), True) + self.assertEqual(c.A.foo, 'hi there') del c.A - self.assertEquals(len(c.A.keys()),0) + self.assertEqual(len(c.A.keys()),0) def test_merge_doesnt_exist(self): c1 = Config() @@ -223,11 +223,11 @@ class TestConfig(TestCase): c2.bar = 10 c2.Foo.bar = 10 c1._merge(c2) - self.assertEquals(c1.Foo.bar, 10) - self.assertEquals(c1.bar, 10) + self.assertEqual(c1.Foo.bar, 10) + self.assertEqual(c1.bar, 10) c2.Bar.bar = 10 c1._merge(c2) - self.assertEquals(c1.Bar.bar, 10) + self.assertEqual(c1.Bar.bar, 10) def test_merge_exists(self): c1 = Config() @@ -237,12 +237,12 @@ class TestConfig(TestCase): c2.Foo.bar = 20 c2.Foo.wow = 40 c1._merge(c2) - self.assertEquals(c1.Foo.bam, 30) - self.assertEquals(c1.Foo.bar, 20) - self.assertEquals(c1.Foo.wow, 40) + self.assertEqual(c1.Foo.bam, 30) + self.assertEqual(c1.Foo.bar, 20) + self.assertEqual(c1.Foo.wow, 40) c2.Foo.Bam.bam = 10 c1._merge(c2) - self.assertEquals(c1.Foo.Bam.bam, 10) + self.assertEqual(c1.Foo.Bam.bam, 10) def test_deepcopy(self): c1 = Config() @@ -252,12 +252,12 @@ class TestConfig(TestCase): c1.b = range(10) import copy c2 = copy.deepcopy(c1) - self.assertEquals(c1, c2) + self.assertEqual(c1, c2) self.assert_(c1 is not c2) self.assert_(c1.Foo is not c2.Foo) def test_builtin(self): c1 = Config() exec 'foo = True' in c1 - self.assertEquals(c1.foo, True) + self.assertEqual(c1.foo, True) self.assertRaises(ConfigError, setattr, c1, 'ValueError', 10) diff --git a/IPython/core/tests/test_interactiveshell.py b/IPython/core/tests/test_interactiveshell.py index 98c6b58..7d255cd 100644 --- a/IPython/core/tests/test_interactiveshell.py +++ b/IPython/core/tests/test_interactiveshell.py @@ -50,17 +50,17 @@ class InteractiveShellTestCase(unittest.TestCase): """Test that cells with only naked strings are fully executed""" # First, single-line inputs ip.run_cell('"a"\n') - self.assertEquals(ip.user_ns['_'], 'a') + self.assertEqual(ip.user_ns['_'], 'a') # And also multi-line cells ip.run_cell('"""a\nb"""\n') - self.assertEquals(ip.user_ns['_'], 'a\nb') + self.assertEqual(ip.user_ns['_'], 'a\nb') def test_run_empty_cell(self): """Just make sure we don't get a horrible error with a blank cell of input. Yes, I did overlook that.""" old_xc = ip.execution_count ip.run_cell('') - self.assertEquals(ip.execution_count, old_xc) + self.assertEqual(ip.execution_count, old_xc) def test_run_cell_multiline(self): """Multi-block, multi-line cells must execute correctly. @@ -71,38 +71,38 @@ class InteractiveShellTestCase(unittest.TestCase): " x += 1", " y += 1",]) ip.run_cell(src) - self.assertEquals(ip.user_ns['x'], 2) - self.assertEquals(ip.user_ns['y'], 3) + self.assertEqual(ip.user_ns['x'], 2) + self.assertEqual(ip.user_ns['y'], 3) def test_multiline_string_cells(self): "Code sprinkled with multiline strings should execute (GH-306)" ip.run_cell('tmp=0') - self.assertEquals(ip.user_ns['tmp'], 0) + self.assertEqual(ip.user_ns['tmp'], 0) ip.run_cell('tmp=1;"""a\nb"""\n') - self.assertEquals(ip.user_ns['tmp'], 1) + self.assertEqual(ip.user_ns['tmp'], 1) def test_dont_cache_with_semicolon(self): "Ending a line with semicolon should not cache the returned object (GH-307)" oldlen = len(ip.user_ns['Out']) a = ip.run_cell('1;', store_history=True) newlen = len(ip.user_ns['Out']) - self.assertEquals(oldlen, newlen) + self.assertEqual(oldlen, newlen) #also test the default caching behavior ip.run_cell('1', store_history=True) newlen = len(ip.user_ns['Out']) - self.assertEquals(oldlen+1, newlen) + self.assertEqual(oldlen+1, newlen) def test_In_variable(self): "Verify that In variable grows with user input (GH-284)" oldlen = len(ip.user_ns['In']) ip.run_cell('1;', store_history=True) newlen = len(ip.user_ns['In']) - self.assertEquals(oldlen+1, newlen) - self.assertEquals(ip.user_ns['In'][-1],'1;') + self.assertEqual(oldlen+1, newlen) + self.assertEqual(ip.user_ns['In'][-1],'1;') def test_magic_names_in_string(self): ip.run_cell('a = """\n%exit\n"""') - self.assertEquals(ip.user_ns['a'], '\n%exit\n') + self.assertEqual(ip.user_ns['a'], '\n%exit\n') def test_alias_crash(self): """Errors in prefilter can't crash IPython""" @@ -113,7 +113,7 @@ class InteractiveShellTestCase(unittest.TestCase): ip.run_cell('parts 1') err = io.stderr.getvalue() io.stderr = save_err - self.assertEquals(err.split(':')[0], 'ERROR') + self.assertEqual(err.split(':')[0], 'ERROR') def test_trailing_newline(self): """test that running !(command) does not raise a SyntaxError""" @@ -192,9 +192,9 @@ class InteractiveShellTestCase(unittest.TestCase): # capture stderr io.stderr = StringIO() ip.set_custom_exc((IOError,), lambda etype,value,tb: 1/0) - self.assertEquals(ip.custom_exceptions, (IOError,)) + self.assertEqual(ip.custom_exceptions, (IOError,)) ip.run_cell(u'raise IOError("foo")') - self.assertEquals(ip.custom_exceptions, ()) + self.assertEqual(ip.custom_exceptions, ()) self.assertTrue("Custom TB Handler failed" in io.stderr.getvalue()) finally: io.stderr = save_stderr @@ -207,9 +207,9 @@ class InteractiveShellTestCase(unittest.TestCase): # capture stderr io.stderr = StringIO() ip.set_custom_exc((NameError,),lambda etype,value,tb, tb_offset=None: 1) - self.assertEquals(ip.custom_exceptions, (NameError,)) + self.assertEqual(ip.custom_exceptions, (NameError,)) ip.run_cell(u'a=abracadabra') - self.assertEquals(ip.custom_exceptions, ()) + self.assertEqual(ip.custom_exceptions, ()) self.assertTrue("Custom TB Handler failed" in io.stderr.getvalue()) finally: io.stderr = save_stderr @@ -288,11 +288,11 @@ class InteractiveShellTestCase(unittest.TestCase): # silent should force store_history=False ip.run_cell("1", store_history=True, silent=True) - self.assertEquals(ec, ip.execution_count) + self.assertEqual(ec, ip.execution_count) # double-check that non-silent exec did what we expected # silent to avoid ip.run_cell("1", store_history=True) - self.assertEquals(ec+1, ip.execution_count) + self.assertEqual(ec+1, ip.execution_count) def test_silent_nodisplayhook(self): """run_cell(silent=True) doesn't trigger displayhook""" diff --git a/IPython/core/tests/test_plugin.py b/IPython/core/tests/test_plugin.py index 92ff22b..440dba8 100644 --- a/IPython/core/tests/test_plugin.py +++ b/IPython/core/tests/test_plugin.py @@ -30,10 +30,10 @@ class PluginTest(TestCase): self.manager = PluginManager() def test_register_get(self): - self.assertEquals(None, self.manager.get_plugin('foo')) + self.assertEqual(None, self.manager.get_plugin('foo')) foo = FooPlugin() self.manager.register_plugin('foo', foo) - self.assertEquals(foo, self.manager.get_plugin('foo')) + self.assertEqual(foo, self.manager.get_plugin('foo')) bar = BarPlugin() self.assertRaises(KeyError, self.manager.register_plugin, 'foo', bar) bad = BadPlugin() @@ -43,4 +43,4 @@ class PluginTest(TestCase): foo = FooPlugin() self.manager.register_plugin('foo', foo) self.manager.unregister_plugin('foo') - self.assertEquals(None, self.manager.get_plugin('foo')) + self.assertEqual(None, self.manager.get_plugin('foo')) diff --git a/IPython/core/tests/test_prompts.py b/IPython/core/tests/test_prompts.py index 8d04b2b..f72fed5 100644 --- a/IPython/core/tests/test_prompts.py +++ b/IPython/core/tests/test_prompts.py @@ -47,19 +47,19 @@ class PromptTests(unittest.TestCase): ip.ex("foo='bar'") self.pm.in_template = "In [{foo}]" prompt = self.pm.render('in') - self.assertEquals(prompt, u'In [bar]') + self.assertEqual(prompt, u'In [bar]') def test_builtins(self): self.pm.color_scheme = 'NoColor' self.pm.in_template = "In [{int}]" prompt = self.pm.render('in') - self.assertEquals(prompt, u"In [%r]" % int) + self.assertEqual(prompt, u"In [%r]" % int) def test_undefined(self): self.pm.color_scheme = 'NoColor' self.pm.in_template = "In [{foo_dne}]" prompt = self.pm.render('in') - self.assertEquals(prompt, u"In []") + self.assertEqual(prompt, u"In []") def test_render(self): self.pm.in_template = r'\#>' @@ -71,32 +71,32 @@ class PromptTests(unittest.TestCase): os.chdir(td) self.pm.in_template = r'\w [\#]' p = self.pm.render('in', color=False) - self.assertEquals(p, u"%s [%i]" % (os.getcwdu(), ip.execution_count)) + self.assertEqual(p, u"%s [%i]" % (os.getcwdu(), ip.execution_count)) os.chdir(save) def test_lazy_eval_unicode(self): u = u'ünicødé' lz = LazyEvaluate(lambda : u) # str(lz) would fail - self.assertEquals(unicode(lz), u) - self.assertEquals(format(lz), u) + self.assertEqual(unicode(lz), u) + self.assertEqual(format(lz), u) def test_lazy_eval_nonascii_bytes(self): u = u'ünicødé' b = u.encode('utf8') lz = LazyEvaluate(lambda : b) # unicode(lz) would fail - self.assertEquals(str(lz), str(b)) - self.assertEquals(format(lz), str(b)) + self.assertEqual(str(lz), str(b)) + self.assertEqual(format(lz), str(b)) def test_lazy_eval_float(self): f = 0.503 lz = LazyEvaluate(lambda : f) - self.assertEquals(str(lz), str(f)) - self.assertEquals(unicode(lz), unicode(f)) - self.assertEquals(format(lz), str(f)) - self.assertEquals(format(lz, '.1'), '0.5') + self.assertEqual(str(lz), str(f)) + self.assertEqual(unicode(lz), unicode(f)) + self.assertEqual(format(lz), str(f)) + self.assertEqual(format(lz, '.1'), '0.5') @dec.skip_win32 def test_cwd_x(self): @@ -105,7 +105,7 @@ class PromptTests(unittest.TestCase): os.chdir(os.path.expanduser('~')) p = self.pm.render('in', color=False) try: - self.assertEquals(p, '~') + self.assertEqual(p, '~') finally: os.chdir(save) diff --git a/IPython/frontend/html/notebook/tests/test_kernelsession.py b/IPython/frontend/html/notebook/tests/test_kernelsession.py index 8b457f5..032c226 100644 --- a/IPython/frontend/html/notebook/tests/test_kernelsession.py +++ b/IPython/frontend/html/notebook/tests/test_kernelsession.py @@ -10,12 +10,12 @@ class TestKernelManager(TestCase): km = MultiKernelManager() kid = km.start_kernel() self.assert_(kid in km) - self.assertEquals(len(km),1) + self.assertEqual(len(km),1) km.kill_kernel(kid) self.assert_(not kid in km) kid = km.start_kernel() - self.assertEquals('127.0.0.1',km.get_kernel_ip(kid)) + self.assertEqual('127.0.0.1',km.get_kernel_ip(kid)) port_dict = km.get_kernel_ports(kid) self.assert_('stdin_port' in port_dict) self.assert_('iopub_port' in port_dict) diff --git a/IPython/frontend/html/notebook/tests/test_nbmanager.py b/IPython/frontend/html/notebook/tests/test_nbmanager.py index 8158725..41290d9 100644 --- a/IPython/frontend/html/notebook/tests/test_nbmanager.py +++ b/IPython/frontend/html/notebook/tests/test_nbmanager.py @@ -14,13 +14,13 @@ class TestNotebookManager(TestCase): def test_nb_dir(self): with TemporaryDirectory() as td: km = NotebookManager(notebook_dir=td) - self.assertEquals(km.notebook_dir, td) + self.assertEqual(km.notebook_dir, td) def test_create_nb_dir(self): with TemporaryDirectory() as td: nbdir = os.path.join(td, 'notebooks') km = NotebookManager(notebook_dir=nbdir) - self.assertEquals(km.notebook_dir, nbdir) + self.assertEqual(km.notebook_dir, nbdir) def test_missing_nb_dir(self): with TemporaryDirectory() as td: diff --git a/IPython/frontend/qt/console/tests/test_ansi_code_processor.py b/IPython/frontend/qt/console/tests/test_ansi_code_processor.py index 569c369..0e8de98 100644 --- a/IPython/frontend/qt/console/tests/test_ansi_code_processor.py +++ b/IPython/frontend/qt/console/tests/test_ansi_code_processor.py @@ -17,20 +17,20 @@ class TestAnsiCodeProcessor(unittest.TestCase): i = -1 for i, substring in enumerate(self.processor.split_string(string)): if i == 0: - self.assertEquals(len(self.processor.actions), 1) + self.assertEqual(len(self.processor.actions), 1) action = self.processor.actions[0] - self.assertEquals(action.action, 'erase') - self.assertEquals(action.area, 'screen') - self.assertEquals(action.erase_to, 'all') + self.assertEqual(action.action, 'erase') + self.assertEqual(action.area, 'screen') + self.assertEqual(action.erase_to, 'all') elif i == 1: - self.assertEquals(len(self.processor.actions), 1) + self.assertEqual(len(self.processor.actions), 1) action = self.processor.actions[0] - self.assertEquals(action.action, 'erase') - self.assertEquals(action.area, 'line') - self.assertEquals(action.erase_to, 'end') + self.assertEqual(action.action, 'erase') + self.assertEqual(action.area, 'line') + self.assertEqual(action.erase_to, 'end') else: self.fail('Too many substrings.') - self.assertEquals(i, 1, 'Too few substrings.') + self.assertEqual(i, 1, 'Too few substrings.') def test_colors(self): """ Do basic controls sequences for colors work? @@ -39,17 +39,17 @@ class TestAnsiCodeProcessor(unittest.TestCase): i = -1 for i, substring in enumerate(self.processor.split_string(string)): if i == 0: - self.assertEquals(substring, 'first') - self.assertEquals(self.processor.foreground_color, None) + self.assertEqual(substring, 'first') + self.assertEqual(self.processor.foreground_color, None) elif i == 1: - self.assertEquals(substring, 'blue') - self.assertEquals(self.processor.foreground_color, 4) + self.assertEqual(substring, 'blue') + self.assertEqual(self.processor.foreground_color, 4) elif i == 2: - self.assertEquals(substring, 'last') - self.assertEquals(self.processor.foreground_color, None) + self.assertEqual(substring, 'last') + self.assertEqual(self.processor.foreground_color, None) else: self.fail('Too many substrings.') - self.assertEquals(i, 2, 'Too few substrings.') + self.assertEqual(i, 2, 'Too few substrings.') def test_colors_xterm(self): """ Do xterm-specific control sequences for colors work? @@ -59,12 +59,12 @@ class TestAnsiCodeProcessor(unittest.TestCase): substrings = list(self.processor.split_string(string)) desired = { 20 : (255, 255, 255), 25 : (255, 255, 255) } - self.assertEquals(self.processor.color_map, desired) + self.assertEqual(self.processor.color_map, desired) string = '\x1b[38;5;20m\x1b[48;5;25m' substrings = list(self.processor.split_string(string)) - self.assertEquals(self.processor.foreground_color, 20) - self.assertEquals(self.processor.background_color, 25) + self.assertEqual(self.processor.foreground_color, 20) + self.assertEqual(self.processor.background_color, 25) def test_scroll(self): """ Do control sequences for scrolling the buffer work? @@ -73,34 +73,34 @@ class TestAnsiCodeProcessor(unittest.TestCase): i = -1 for i, substring in enumerate(self.processor.split_string(string)): if i == 0: - self.assertEquals(len(self.processor.actions), 1) + self.assertEqual(len(self.processor.actions), 1) action = self.processor.actions[0] - self.assertEquals(action.action, 'scroll') - self.assertEquals(action.dir, 'up') - self.assertEquals(action.unit, 'line') - self.assertEquals(action.count, 5) + self.assertEqual(action.action, 'scroll') + self.assertEqual(action.dir, 'up') + self.assertEqual(action.unit, 'line') + self.assertEqual(action.count, 5) elif i == 1: - self.assertEquals(len(self.processor.actions), 1) + self.assertEqual(len(self.processor.actions), 1) action = self.processor.actions[0] - self.assertEquals(action.action, 'scroll') - self.assertEquals(action.dir, 'down') - self.assertEquals(action.unit, 'line') - self.assertEquals(action.count, 1) + self.assertEqual(action.action, 'scroll') + self.assertEqual(action.dir, 'down') + self.assertEqual(action.unit, 'line') + self.assertEqual(action.count, 1) else: self.fail('Too many substrings.') - self.assertEquals(i, 1, 'Too few substrings.') + self.assertEqual(i, 1, 'Too few substrings.') def test_formfeed(self): """ Are formfeed characters processed correctly? """ string = '\f' # form feed - self.assertEquals(list(self.processor.split_string(string)), ['']) - self.assertEquals(len(self.processor.actions), 1) + self.assertEqual(list(self.processor.split_string(string)), ['']) + self.assertEqual(len(self.processor.actions), 1) action = self.processor.actions[0] - self.assertEquals(action.action, 'scroll') - self.assertEquals(action.dir, 'down') - self.assertEquals(action.unit, 'page') - self.assertEquals(action.count, 1) + self.assertEqual(action.action, 'scroll') + self.assertEqual(action.dir, 'down') + self.assertEqual(action.unit, 'page') + self.assertEqual(action.count, 1) def test_carriage_return(self): """ Are carriage return characters processed correctly? @@ -111,8 +111,8 @@ class TestAnsiCodeProcessor(unittest.TestCase): for split in self.processor.split_string(string): splits.append(split) actions.append([action.action for action in self.processor.actions]) - self.assertEquals(splits, ['foo', None, 'bar']) - self.assertEquals(actions, [[], ['carriage-return'], []]) + self.assertEqual(splits, ['foo', None, 'bar']) + self.assertEqual(actions, [[], ['carriage-return'], []]) def test_carriage_return_newline(self): """transform CRLF to LF""" @@ -123,8 +123,8 @@ class TestAnsiCodeProcessor(unittest.TestCase): for split in self.processor.split_string(string): splits.append(split) actions.append([action.action for action in self.processor.actions]) - self.assertEquals(splits, ['foo', None, 'bar', '\r\n', 'cat', '\r\n', '\n']) - self.assertEquals(actions, [[], ['carriage-return'], [], ['newline'], [], ['newline'], ['newline']]) + self.assertEqual(splits, ['foo', None, 'bar', '\r\n', 'cat', '\r\n', '\n']) + self.assertEqual(actions, [[], ['carriage-return'], [], ['newline'], [], ['newline'], ['newline']]) def test_beep(self): """ Are beep characters processed correctly? @@ -135,8 +135,8 @@ class TestAnsiCodeProcessor(unittest.TestCase): for split in self.processor.split_string(string): splits.append(split) actions.append([action.action for action in self.processor.actions]) - self.assertEquals(splits, ['foo', None, 'bar']) - self.assertEquals(actions, [[], ['beep'], []]) + self.assertEqual(splits, ['foo', None, 'bar']) + self.assertEqual(actions, [[], ['beep'], []]) def test_backspace(self): """ Are backspace characters processed correctly? @@ -147,8 +147,8 @@ class TestAnsiCodeProcessor(unittest.TestCase): for split in self.processor.split_string(string): splits.append(split) actions.append([action.action for action in self.processor.actions]) - self.assertEquals(splits, ['foo', None, 'bar']) - self.assertEquals(actions, [[], ['backspace'], []]) + self.assertEqual(splits, ['foo', None, 'bar']) + self.assertEqual(actions, [[], ['backspace'], []]) def test_combined(self): """ Are CR and BS characters processed correctly in combination? @@ -163,8 +163,8 @@ class TestAnsiCodeProcessor(unittest.TestCase): for split in self.processor.split_string(string): splits.append(split) actions.append([action.action for action in self.processor.actions]) - self.assertEquals(splits, ['abc', None, 'def', None]) - self.assertEquals(actions, [[], ['carriage-return'], [], ['backspace']]) + self.assertEqual(splits, ['abc', None, 'def', None]) + self.assertEqual(actions, [[], ['carriage-return'], [], ['backspace']]) if __name__ == '__main__': diff --git a/IPython/frontend/qt/console/tests/test_completion_lexer.py b/IPython/frontend/qt/console/tests/test_completion_lexer.py index ed958d8..6c948c6 100644 --- a/IPython/frontend/qt/console/tests/test_completion_lexer.py +++ b/IPython/frontend/qt/console/tests/test_completion_lexer.py @@ -16,31 +16,31 @@ class TestCompletionLexer(unittest.TestCase): lexer = CompletionLexer(PythonLexer()) # Test simplest case. - self.assertEquals(lexer.get_context("foo.bar.baz"), + self.assertEqual(lexer.get_context("foo.bar.baz"), [ "foo", "bar", "baz" ]) # Test trailing period. - self.assertEquals(lexer.get_context("foo.bar."), [ "foo", "bar", "" ]) + self.assertEqual(lexer.get_context("foo.bar."), [ "foo", "bar", "" ]) # Test with prompt present. - self.assertEquals(lexer.get_context(">>> foo.bar.baz"), + self.assertEqual(lexer.get_context(">>> foo.bar.baz"), [ "foo", "bar", "baz" ]) # Test spacing in name. - self.assertEquals(lexer.get_context("foo.bar. baz"), [ "baz" ]) + self.assertEqual(lexer.get_context("foo.bar. baz"), [ "baz" ]) # Test parenthesis. - self.assertEquals(lexer.get_context("foo("), []) + self.assertEqual(lexer.get_context("foo("), []) def testC(self): """ Does the CompletionLexer work for C/C++? """ lexer = CompletionLexer(CLexer()) - self.assertEquals(lexer.get_context("foo.bar"), [ "foo", "bar" ]) - self.assertEquals(lexer.get_context("foo->bar"), [ "foo", "bar" ]) + self.assertEqual(lexer.get_context("foo.bar"), [ "foo", "bar" ]) + self.assertEqual(lexer.get_context("foo->bar"), [ "foo", "bar" ]) lexer = CompletionLexer(CppLexer()) - self.assertEquals(lexer.get_context("Foo::Bar"), [ "Foo", "Bar" ]) + self.assertEqual(lexer.get_context("Foo::Bar"), [ "Foo", "Bar" ]) if __name__ == '__main__': diff --git a/IPython/frontend/qt/console/tests/test_console_widget.py b/IPython/frontend/qt/console/tests/test_console_widget.py index 6cc5b04..969fdf5 100644 --- a/IPython/frontend/qt/console/tests/test_console_widget.py +++ b/IPython/frontend/qt/console/tests/test_console_widget.py @@ -37,6 +37,6 @@ class TestConsoleWidget(unittest.TestCase): w._insert_plain_text(cursor, text) cursor.select(cursor.Document) selection = cursor.selectedText() - self.assertEquals(expected_outputs[i], selection) + self.assertEqual(expected_outputs[i], selection) # clear all the text cursor.insertText('') diff --git a/IPython/frontend/terminal/tests/test_interactivshell.py b/IPython/frontend/terminal/tests/test_interactivshell.py index 6c60699..3285efe 100644 --- a/IPython/frontend/terminal/tests/test_interactivshell.py +++ b/IPython/frontend/terminal/tests/test_interactivshell.py @@ -59,10 +59,10 @@ class InteractiveShellTestCase(unittest.TestCase): hlen_b4_cell = ip._replace_rlhist_multiline(u'sourc€\nsource2', hlen_b4_cell) - self.assertEquals(ip.readline.get_current_history_length(), + self.assertEqual(ip.readline.get_current_history_length(), hlen_b4_cell) hist = self.rl_hist_entries(ip.readline, 2) - self.assertEquals(hist, ghist) + self.assertEqual(hist, ghist) @skipif(not get_ipython().has_readline, 'no readline') @skipif(not hasattr(get_ipython().readline, 'remove_history_item'), @@ -74,7 +74,7 @@ class InteractiveShellTestCase(unittest.TestCase): hlen_b4_cell = ip.readline.get_current_history_length() hlen_b4_cell = ip._replace_rlhist_multiline(u'sourc€', hlen_b4_cell) - self.assertEquals(hlen_b4_cell, + self.assertEqual(hlen_b4_cell, ip.readline.get_current_history_length()) @skipif(not get_ipython().has_readline, 'no readline') @@ -95,10 +95,10 @@ class InteractiveShellTestCase(unittest.TestCase): hlen_b4_cell = ip._replace_rlhist_multiline(u'sourc€\nsource2', hlen_b4_cell) - self.assertEquals(ip.readline.get_current_history_length(), + self.assertEqual(ip.readline.get_current_history_length(), hlen_b4_cell) hist = self.rl_hist_entries(ip.readline, 2) - self.assertEquals(hist, ghist) + self.assertEqual(hist, ghist) @skipif(not get_ipython().has_readline, 'no readline') @@ -123,14 +123,14 @@ class InteractiveShellTestCase(unittest.TestCase): hlen_b4_cell = ip._replace_rlhist_multiline(u'l€ne3\nline4', hlen_b4_cell) - self.assertEquals(ip.readline.get_current_history_length(), + self.assertEqual(ip.readline.get_current_history_length(), hlen_b4_cell) hist = self.rl_hist_entries(ip.readline, 3) expected = [u'line0', u'l€ne1\nline2', u'l€ne3\nline4'] # perform encoding, in case of casting due to ASCII locale enc = sys.stdin.encoding or "utf-8" expected = [ py3compat.unicode_to_str(e, enc) for e in expected ] - self.assertEquals(hist, expected) + self.assertEqual(hist, expected) @skipif(not get_ipython().has_readline, 'no readline') @@ -160,7 +160,7 @@ class InteractiveShellTestCase(unittest.TestCase): ip.readline.add_history('line4') hlen_b4_cell = ip._replace_rlhist_multiline(u'line4', hlen_b4_cell) - self.assertEquals(ip.readline.get_current_history_length(), + self.assertEqual(ip.readline.get_current_history_length(), hlen_b4_cell) hist = self.rl_hist_entries(ip.readline, 4) # expect no empty cells in history @@ -168,4 +168,4 @@ class InteractiveShellTestCase(unittest.TestCase): # perform encoding, in case of casting due to ASCII locale enc = sys.stdin.encoding or "utf-8" expected = [ py3compat.unicode_to_str(e, enc) for e in expected ] - self.assertEquals(hist, expected) + self.assertEqual(hist, expected) diff --git a/IPython/nbformat/v1/tests/test_json.py b/IPython/nbformat/v1/tests/test_json.py index 09d1c4e..ec7c3f9 100644 --- a/IPython/nbformat/v1/tests/test_json.py +++ b/IPython/nbformat/v1/tests/test_json.py @@ -8,7 +8,7 @@ class TestJSON(TestCase): def test_roundtrip(self): s = writes(nb0) - self.assertEquals(reads(s),nb0) + self.assertEqual(reads(s),nb0) diff --git a/IPython/nbformat/v1/tests/test_nbbase.py b/IPython/nbformat/v1/tests/test_nbbase.py index 19fe6d1..6331060 100644 --- a/IPython/nbformat/v1/tests/test_nbbase.py +++ b/IPython/nbformat/v1/tests/test_nbbase.py @@ -9,33 +9,33 @@ class TestCell(TestCase): def test_empty_code_cell(self): cc = new_code_cell() - self.assertEquals(cc.cell_type,'code') - self.assertEquals('code' not in cc, True) - self.assertEquals('prompt_number' not in cc, True) + self.assertEqual(cc.cell_type,'code') + self.assertEqual('code' not in cc, True) + self.assertEqual('prompt_number' not in cc, True) def test_code_cell(self): cc = new_code_cell(code='a=10', prompt_number=0) - self.assertEquals(cc.code, u'a=10') - self.assertEquals(cc.prompt_number, 0) + self.assertEqual(cc.code, u'a=10') + self.assertEqual(cc.prompt_number, 0) def test_empty_text_cell(self): tc = new_text_cell() - self.assertEquals(tc.cell_type, 'text') - self.assertEquals('text' not in tc, True) + self.assertEqual(tc.cell_type, 'text') + self.assertEqual('text' not in tc, True) def test_text_cell(self): tc = new_text_cell('hi') - self.assertEquals(tc.text, u'hi') + self.assertEqual(tc.text, u'hi') class TestNotebook(TestCase): def test_empty_notebook(self): nb = new_notebook() - self.assertEquals(nb.cells, []) + self.assertEqual(nb.cells, []) def test_notebooke(self): cells = [new_code_cell(),new_text_cell()] nb = new_notebook(cells=cells) - self.assertEquals(nb.cells,cells) + self.assertEqual(nb.cells,cells) diff --git a/IPython/nbformat/v2/tests/test_json.py b/IPython/nbformat/v2/tests/test_json.py index d6cc5d3..453d6c4 100644 --- a/IPython/nbformat/v2/tests/test_json.py +++ b/IPython/nbformat/v2/tests/test_json.py @@ -15,20 +15,20 @@ class TestJSON(TestCase): # print pprint.pformat(reads(s),indent=2) # print # print s - self.assertEquals(reads(s),nb0) + self.assertEqual(reads(s),nb0) def test_roundtrip_nosplit(self): """Ensure that multiline blobs are still readable""" # ensures that notebooks written prior to splitlines change # are still readable. s = writes(nb0, split_lines=False) - self.assertEquals(reads(s),nb0) + self.assertEqual(reads(s),nb0) def test_roundtrip_split(self): """Ensure that splitting multiline blocks is safe""" # This won't differ from test_roundtrip unless the default changes s = writes(nb0, split_lines=True) - self.assertEquals(reads(s),nb0) + self.assertEqual(reads(s),nb0) diff --git a/IPython/nbformat/v2/tests/test_nbbase.py b/IPython/nbformat/v2/tests/test_nbbase.py index d711bcf..62d49bf 100644 --- a/IPython/nbformat/v2/tests/test_nbbase.py +++ b/IPython/nbformat/v2/tests/test_nbbase.py @@ -10,104 +10,104 @@ class TestCell(TestCase): def test_empty_code_cell(self): cc = new_code_cell() - self.assertEquals(cc.cell_type,u'code') - self.assertEquals(u'input' not in cc, True) - self.assertEquals(u'prompt_number' not in cc, True) - self.assertEquals(cc.outputs, []) - self.assertEquals(cc.collapsed, False) + self.assertEqual(cc.cell_type,u'code') + self.assertEqual(u'input' not in cc, True) + self.assertEqual(u'prompt_number' not in cc, True) + self.assertEqual(cc.outputs, []) + self.assertEqual(cc.collapsed, False) def test_code_cell(self): cc = new_code_cell(input='a=10', prompt_number=0, collapsed=True) cc.outputs = [new_output(output_type=u'pyout', output_svg=u'foo',output_text=u'10',prompt_number=0)] - self.assertEquals(cc.input, u'a=10') - self.assertEquals(cc.prompt_number, 0) - self.assertEquals(cc.language, u'python') - self.assertEquals(cc.outputs[0].svg, u'foo') - self.assertEquals(cc.outputs[0].text, u'10') - self.assertEquals(cc.outputs[0].prompt_number, 0) - self.assertEquals(cc.collapsed, True) + self.assertEqual(cc.input, u'a=10') + self.assertEqual(cc.prompt_number, 0) + self.assertEqual(cc.language, u'python') + self.assertEqual(cc.outputs[0].svg, u'foo') + self.assertEqual(cc.outputs[0].text, u'10') + self.assertEqual(cc.outputs[0].prompt_number, 0) + self.assertEqual(cc.collapsed, True) def test_pyerr(self): o = new_output(output_type=u'pyerr', etype=u'NameError', evalue=u'Name not found', traceback=[u'frame 0', u'frame 1', u'frame 2'] ) - self.assertEquals(o.output_type, u'pyerr') - self.assertEquals(o.etype, u'NameError') - self.assertEquals(o.evalue, u'Name not found') - self.assertEquals(o.traceback, [u'frame 0', u'frame 1', u'frame 2']) + self.assertEqual(o.output_type, u'pyerr') + self.assertEqual(o.etype, u'NameError') + self.assertEqual(o.evalue, u'Name not found') + self.assertEqual(o.traceback, [u'frame 0', u'frame 1', u'frame 2']) def test_empty_html_cell(self): tc = new_text_cell(u'html') - self.assertEquals(tc.cell_type, u'html') - self.assertEquals(u'source' not in tc, True) - self.assertEquals(u'rendered' not in tc, True) + self.assertEqual(tc.cell_type, u'html') + self.assertEqual(u'source' not in tc, True) + self.assertEqual(u'rendered' not in tc, True) def test_html_cell(self): tc = new_text_cell(u'html', 'hi', 'hi') - self.assertEquals(tc.source, u'hi') - self.assertEquals(tc.rendered, u'hi') + self.assertEqual(tc.source, u'hi') + self.assertEqual(tc.rendered, u'hi') def test_empty_markdown_cell(self): tc = new_text_cell(u'markdown') - self.assertEquals(tc.cell_type, u'markdown') - self.assertEquals(u'source' not in tc, True) - self.assertEquals(u'rendered' not in tc, True) + self.assertEqual(tc.cell_type, u'markdown') + self.assertEqual(u'source' not in tc, True) + self.assertEqual(u'rendered' not in tc, True) def test_markdown_cell(self): tc = new_text_cell(u'markdown', 'hi', 'hi') - self.assertEquals(tc.source, u'hi') - self.assertEquals(tc.rendered, u'hi') + self.assertEqual(tc.source, u'hi') + self.assertEqual(tc.rendered, u'hi') class TestWorksheet(TestCase): def test_empty_worksheet(self): ws = new_worksheet() - self.assertEquals(ws.cells,[]) - self.assertEquals(u'name' not in ws, True) + self.assertEqual(ws.cells,[]) + self.assertEqual(u'name' not in ws, True) def test_worksheet(self): cells = [new_code_cell(), new_text_cell(u'html')] ws = new_worksheet(cells=cells,name=u'foo') - self.assertEquals(ws.cells,cells) - self.assertEquals(ws.name,u'foo') + self.assertEqual(ws.cells,cells) + self.assertEqual(ws.name,u'foo') class TestNotebook(TestCase): def test_empty_notebook(self): nb = new_notebook() - self.assertEquals(nb.worksheets, []) - self.assertEquals(nb.metadata, NotebookNode()) - self.assertEquals(nb.nbformat,2) + self.assertEqual(nb.worksheets, []) + self.assertEqual(nb.metadata, NotebookNode()) + self.assertEqual(nb.nbformat,2) def test_notebook(self): worksheets = [new_worksheet(),new_worksheet()] metadata = new_metadata(name=u'foo') nb = new_notebook(metadata=metadata,worksheets=worksheets) - self.assertEquals(nb.metadata.name,u'foo') - self.assertEquals(nb.worksheets,worksheets) - self.assertEquals(nb.nbformat,2) + self.assertEqual(nb.metadata.name,u'foo') + self.assertEqual(nb.worksheets,worksheets) + self.assertEqual(nb.nbformat,2) class TestMetadata(TestCase): def test_empty_metadata(self): md = new_metadata() - self.assertEquals(u'name' not in md, True) - self.assertEquals(u'authors' not in md, True) - self.assertEquals(u'license' not in md, True) - self.assertEquals(u'saved' not in md, True) - self.assertEquals(u'modified' not in md, True) - self.assertEquals(u'gistid' not in md, True) + self.assertEqual(u'name' not in md, True) + self.assertEqual(u'authors' not in md, True) + self.assertEqual(u'license' not in md, True) + self.assertEqual(u'saved' not in md, True) + self.assertEqual(u'modified' not in md, True) + self.assertEqual(u'gistid' not in md, True) def test_metadata(self): authors = [new_author(name='Bart Simpson',email='bsimpson@fox.com')] md = new_metadata(name=u'foo',license=u'BSD',created=u'today', modified=u'now',gistid=u'21341231',authors=authors) - self.assertEquals(md.name, u'foo') - self.assertEquals(md.license, u'BSD') - self.assertEquals(md.created, u'today') - self.assertEquals(md.modified, u'now') - self.assertEquals(md.gistid, u'21341231') - self.assertEquals(md.authors, authors) + self.assertEqual(md.name, u'foo') + self.assertEqual(md.license, u'BSD') + self.assertEqual(md.created, u'today') + self.assertEqual(md.modified, u'now') + self.assertEqual(md.gistid, u'21341231') + self.assertEqual(md.authors, authors) diff --git a/IPython/nbformat/v2/tests/test_nbpy.py b/IPython/nbformat/v2/tests/test_nbpy.py index 4c12c4e..956c5a6 100644 --- a/IPython/nbformat/v2/tests/test_nbpy.py +++ b/IPython/nbformat/v2/tests/test_nbpy.py @@ -13,5 +13,5 @@ class TestPy(TestCase): def test_write(self): s = writes(nb0) - self.assertEquals(s,nb0_py) + self.assertEqual(s,nb0_py) diff --git a/IPython/nbformat/v3/tests/formattest.py b/IPython/nbformat/v3/tests/formattest.py index d19725c..e866758 100644 --- a/IPython/nbformat/v3/tests/formattest.py +++ b/IPython/nbformat/v3/tests/formattest.py @@ -33,12 +33,12 @@ class NBFormatTest: shutil.rmtree(self.wd) def assertNBEquals(self, nba, nbb): - self.assertEquals(nba, nbb) + self.assertEqual(nba, nbb) def test_writes(self): s = self.mod.writes(nb0) if self.nb0_ref: - self.assertEquals(s, self.nb0_ref) + self.assertEqual(s, self.nb0_ref) def test_reads(self): s = self.mod.writes(nb0) diff --git a/IPython/nbformat/v3/tests/test_json.py b/IPython/nbformat/v3/tests/test_json.py index bd5f8a5..9897443 100644 --- a/IPython/nbformat/v3/tests/test_json.py +++ b/IPython/nbformat/v3/tests/test_json.py @@ -21,13 +21,13 @@ class TestJSON(formattest.NBFormatTest, TestCase): # ensures that notebooks written prior to splitlines change # are still readable. s = writes(nb0, split_lines=False) - self.assertEquals(nbjson.reads(s),nb0) + self.assertEqual(nbjson.reads(s),nb0) def test_roundtrip_split(self): """Ensure that splitting multiline blocks is safe""" # This won't differ from test_roundtrip unless the default changes s = writes(nb0, split_lines=True) - self.assertEquals(nbjson.reads(s),nb0) + self.assertEqual(nbjson.reads(s),nb0) diff --git a/IPython/nbformat/v3/tests/test_nbbase.py b/IPython/nbformat/v3/tests/test_nbbase.py index 6800d69..bc2b04e 100644 --- a/IPython/nbformat/v3/tests/test_nbbase.py +++ b/IPython/nbformat/v3/tests/test_nbbase.py @@ -10,134 +10,134 @@ class TestCell(TestCase): def test_empty_code_cell(self): cc = new_code_cell() - self.assertEquals(cc.cell_type,u'code') - self.assertEquals(u'input' not in cc, True) - self.assertEquals(u'prompt_number' not in cc, True) - self.assertEquals(cc.outputs, []) - self.assertEquals(cc.collapsed, False) + self.assertEqual(cc.cell_type,u'code') + self.assertEqual(u'input' not in cc, True) + self.assertEqual(u'prompt_number' not in cc, True) + self.assertEqual(cc.outputs, []) + self.assertEqual(cc.collapsed, False) def test_code_cell(self): cc = new_code_cell(input='a=10', prompt_number=0, collapsed=True) cc.outputs = [new_output(output_type=u'pyout', output_svg=u'foo',output_text=u'10',prompt_number=0)] - self.assertEquals(cc.input, u'a=10') - self.assertEquals(cc.prompt_number, 0) - self.assertEquals(cc.language, u'python') - self.assertEquals(cc.outputs[0].svg, u'foo') - self.assertEquals(cc.outputs[0].text, u'10') - self.assertEquals(cc.outputs[0].prompt_number, 0) - self.assertEquals(cc.collapsed, True) + self.assertEqual(cc.input, u'a=10') + self.assertEqual(cc.prompt_number, 0) + self.assertEqual(cc.language, u'python') + self.assertEqual(cc.outputs[0].svg, u'foo') + self.assertEqual(cc.outputs[0].text, u'10') + self.assertEqual(cc.outputs[0].prompt_number, 0) + self.assertEqual(cc.collapsed, True) def test_pyerr(self): o = new_output(output_type=u'pyerr', etype=u'NameError', evalue=u'Name not found', traceback=[u'frame 0', u'frame 1', u'frame 2'] ) - self.assertEquals(o.output_type, u'pyerr') - self.assertEquals(o.etype, u'NameError') - self.assertEquals(o.evalue, u'Name not found') - self.assertEquals(o.traceback, [u'frame 0', u'frame 1', u'frame 2']) + self.assertEqual(o.output_type, u'pyerr') + self.assertEqual(o.etype, u'NameError') + self.assertEqual(o.evalue, u'Name not found') + self.assertEqual(o.traceback, [u'frame 0', u'frame 1', u'frame 2']) def test_empty_html_cell(self): tc = new_text_cell(u'html') - self.assertEquals(tc.cell_type, u'html') - self.assertEquals(u'source' not in tc, True) - self.assertEquals(u'rendered' not in tc, True) + self.assertEqual(tc.cell_type, u'html') + self.assertEqual(u'source' not in tc, True) + self.assertEqual(u'rendered' not in tc, True) def test_html_cell(self): tc = new_text_cell(u'html', 'hi', 'hi') - self.assertEquals(tc.source, u'hi') - self.assertEquals(tc.rendered, u'hi') + self.assertEqual(tc.source, u'hi') + self.assertEqual(tc.rendered, u'hi') def test_empty_markdown_cell(self): tc = new_text_cell(u'markdown') - self.assertEquals(tc.cell_type, u'markdown') - self.assertEquals(u'source' not in tc, True) - self.assertEquals(u'rendered' not in tc, True) + self.assertEqual(tc.cell_type, u'markdown') + self.assertEqual(u'source' not in tc, True) + self.assertEqual(u'rendered' not in tc, True) def test_markdown_cell(self): tc = new_text_cell(u'markdown', 'hi', 'hi') - self.assertEquals(tc.source, u'hi') - self.assertEquals(tc.rendered, u'hi') + self.assertEqual(tc.source, u'hi') + self.assertEqual(tc.rendered, u'hi') def test_empty_raw_cell(self): tc = new_text_cell(u'raw') - self.assertEquals(tc.cell_type, u'raw') - self.assertEquals(u'source' not in tc, True) - self.assertEquals(u'rendered' not in tc, True) + self.assertEqual(tc.cell_type, u'raw') + self.assertEqual(u'source' not in tc, True) + self.assertEqual(u'rendered' not in tc, True) def test_raw_cell(self): tc = new_text_cell(u'raw', 'hi', 'hi') - self.assertEquals(tc.source, u'hi') - self.assertEquals(tc.rendered, u'hi') + self.assertEqual(tc.source, u'hi') + self.assertEqual(tc.rendered, u'hi') def test_empty_heading_cell(self): tc = new_heading_cell() - self.assertEquals(tc.cell_type, u'heading') - self.assertEquals(u'source' not in tc, True) - self.assertEquals(u'rendered' not in tc, True) + self.assertEqual(tc.cell_type, u'heading') + self.assertEqual(u'source' not in tc, True) + self.assertEqual(u'rendered' not in tc, True) def test_heading_cell(self): tc = new_heading_cell(u'hi', u'hi', level=2) - self.assertEquals(tc.source, u'hi') - self.assertEquals(tc.rendered, u'hi') - self.assertEquals(tc.level, 2) + self.assertEqual(tc.source, u'hi') + self.assertEqual(tc.rendered, u'hi') + self.assertEqual(tc.level, 2) class TestWorksheet(TestCase): def test_empty_worksheet(self): ws = new_worksheet() - self.assertEquals(ws.cells,[]) - self.assertEquals(u'name' not in ws, True) + self.assertEqual(ws.cells,[]) + self.assertEqual(u'name' not in ws, True) def test_worksheet(self): cells = [new_code_cell(), new_text_cell(u'html')] ws = new_worksheet(cells=cells,name=u'foo') - self.assertEquals(ws.cells,cells) - self.assertEquals(ws.name,u'foo') + self.assertEqual(ws.cells,cells) + self.assertEqual(ws.name,u'foo') class TestNotebook(TestCase): def test_empty_notebook(self): nb = new_notebook() - self.assertEquals(nb.worksheets, []) - self.assertEquals(nb.metadata, NotebookNode()) - self.assertEquals(nb.nbformat,nbformat) + self.assertEqual(nb.worksheets, []) + self.assertEqual(nb.metadata, NotebookNode()) + self.assertEqual(nb.nbformat,nbformat) def test_notebook(self): worksheets = [new_worksheet(),new_worksheet()] metadata = new_metadata(name=u'foo') nb = new_notebook(metadata=metadata,worksheets=worksheets) - self.assertEquals(nb.metadata.name,u'foo') - self.assertEquals(nb.worksheets,worksheets) - self.assertEquals(nb.nbformat,nbformat) + self.assertEqual(nb.metadata.name,u'foo') + self.assertEqual(nb.worksheets,worksheets) + self.assertEqual(nb.nbformat,nbformat) def test_notebook_name(self): worksheets = [new_worksheet(),new_worksheet()] nb = new_notebook(name='foo',worksheets=worksheets) - self.assertEquals(nb.metadata.name,u'foo') - self.assertEquals(nb.worksheets,worksheets) - self.assertEquals(nb.nbformat,nbformat) + self.assertEqual(nb.metadata.name,u'foo') + self.assertEqual(nb.worksheets,worksheets) + self.assertEqual(nb.nbformat,nbformat) class TestMetadata(TestCase): def test_empty_metadata(self): md = new_metadata() - self.assertEquals(u'name' not in md, True) - self.assertEquals(u'authors' not in md, True) - self.assertEquals(u'license' not in md, True) - self.assertEquals(u'saved' not in md, True) - self.assertEquals(u'modified' not in md, True) - self.assertEquals(u'gistid' not in md, True) + self.assertEqual(u'name' not in md, True) + self.assertEqual(u'authors' not in md, True) + self.assertEqual(u'license' not in md, True) + self.assertEqual(u'saved' not in md, True) + self.assertEqual(u'modified' not in md, True) + self.assertEqual(u'gistid' not in md, True) def test_metadata(self): authors = [new_author(name='Bart Simpson',email='bsimpson@fox.com')] md = new_metadata(name=u'foo',license=u'BSD',created=u'today', modified=u'now',gistid=u'21341231',authors=authors) - self.assertEquals(md.name, u'foo') - self.assertEquals(md.license, u'BSD') - self.assertEquals(md.created, u'today') - self.assertEquals(md.modified, u'now') - self.assertEquals(md.gistid, u'21341231') - self.assertEquals(md.authors, authors) + self.assertEqual(md.name, u'foo') + self.assertEqual(md.license, u'BSD') + self.assertEqual(md.created, u'today') + self.assertEqual(md.modified, u'now') + self.assertEqual(md.gistid, u'21341231') + self.assertEqual(md.authors, authors) diff --git a/IPython/nbformat/v3/tests/test_nbpy.py b/IPython/nbformat/v3/tests/test_nbpy.py index 858a6b7..6ba6789 100644 --- a/IPython/nbformat/v3/tests/test_nbpy.py +++ b/IPython/nbformat/v3/tests/test_nbpy.py @@ -36,7 +36,7 @@ class TestPy(formattest.NBFormatTest, TestCase): # newlines in blocks through roundtrip da = da.strip('\n') db = db.strip('\n') - self.assertEquals(da, db) + self.assertEqual(da, db) return True def assertNBEquals(self, nba, nbb): diff --git a/IPython/parallel/tests/clienttest.py b/IPython/parallel/tests/clienttest.py index 1585bec..cf28b11 100644 --- a/IPython/parallel/tests/clienttest.py +++ b/IPython/parallel/tests/clienttest.py @@ -142,7 +142,7 @@ class ClusterTestCase(BaseZMQTestCase): except error.CompositeError as e: e.raise_exception() except error.RemoteError as e: - self.assertEquals(etype.__name__, e.ename, "Should have raised %r, but raised %r"%(etype.__name__, e.ename)) + self.assertEqual(etype.__name__, e.ename, "Should have raised %r, but raised %r"%(etype.__name__, e.ename)) else: self.fail("should have raised a RemoteError") diff --git a/IPython/parallel/tests/test_asyncresult.py b/IPython/parallel/tests/test_asyncresult.py index e12f72c..e811629 100644 --- a/IPython/parallel/tests/test_asyncresult.py +++ b/IPython/parallel/tests/test_asyncresult.py @@ -39,25 +39,25 @@ class AsyncResultTest(ClusterTestCase): """various one-target views get the right value for single_result""" eid = self.client.ids[-1] ar = self.client[eid].apply_async(lambda : 42) - self.assertEquals(ar.get(), 42) + self.assertEqual(ar.get(), 42) ar = self.client[[eid]].apply_async(lambda : 42) - self.assertEquals(ar.get(), [42]) + self.assertEqual(ar.get(), [42]) ar = self.client[-1:].apply_async(lambda : 42) - self.assertEquals(ar.get(), [42]) + self.assertEqual(ar.get(), [42]) def test_get_after_done(self): ar = self.client[-1].apply_async(lambda : 42) ar.wait() self.assertTrue(ar.ready()) - self.assertEquals(ar.get(), 42) - self.assertEquals(ar.get(), 42) + self.assertEqual(ar.get(), 42) + self.assertEqual(ar.get(), 42) def test_get_before_done(self): ar = self.client[-1].apply_async(wait, 0.1) self.assertRaises(TimeoutError, ar.get, 0) ar.wait(0) self.assertFalse(ar.ready()) - self.assertEquals(ar.get(), 0.1) + self.assertEqual(ar.get(), 0.1) def test_get_after_error(self): ar = self.client[-1].apply_async(lambda : 1/0) @@ -69,11 +69,11 @@ class AsyncResultTest(ClusterTestCase): def test_get_dict(self): n = len(self.client) ar = self.client[:].apply_async(lambda : 5) - self.assertEquals(ar.get(), [5]*n) + self.assertEqual(ar.get(), [5]*n) d = ar.get_dict() - self.assertEquals(sorted(d.keys()), sorted(self.client.ids)) + self.assertEqual(sorted(d.keys()), sorted(self.client.ids)) for eid,r in d.iteritems(): - self.assertEquals(r, 5) + self.assertEqual(r, 5) def test_list_amr(self): ar = self.client.load_balanced_view().map_async(wait, [0.1]*5) @@ -93,7 +93,7 @@ class AsyncResultTest(ClusterTestCase): self.assertRaises(AttributeError, lambda : ar.__length_hint__()) self.assertRaises(AttributeError, lambda : ar.foo) self.assertTrue(isinstance(ar.engine_id, list)) - self.assertEquals(ar.engine_id, ar['engine_id']) + self.assertEqual(ar.engine_id, ar['engine_id']) self.assertFalse(hasattr(ar, '__length_hint__')) self.assertFalse(hasattr(ar, 'foo')) self.assertTrue(hasattr(ar, 'engine_id')) @@ -105,7 +105,7 @@ class AsyncResultTest(ClusterTestCase): ar.get(5) self.assertRaises(KeyError, lambda : ar['foo']) self.assertTrue(isinstance(ar['engine_id'], list)) - self.assertEquals(ar.engine_id, ar['engine_id']) + self.assertEqual(ar.engine_id, ar['engine_id']) def test_single_result(self): ar = self.client[-1].apply_async(wait, 0.5) @@ -114,7 +114,7 @@ class AsyncResultTest(ClusterTestCase): self.assertTrue(ar.get(5) == 0.5) self.assertTrue(isinstance(ar['engine_id'], int)) self.assertTrue(isinstance(ar.engine_id, int)) - self.assertEquals(ar.engine_id, ar['engine_id']) + self.assertEqual(ar.engine_id, ar['engine_id']) def test_abort(self): e = self.client[-1] @@ -127,11 +127,11 @@ class AsyncResultTest(ClusterTestCase): def test_len(self): v = self.client.load_balanced_view() ar = v.map_async(lambda x: x, range(10)) - self.assertEquals(len(ar), 10) + self.assertEqual(len(ar), 10) ar = v.apply_async(lambda x: x, range(10)) - self.assertEquals(len(ar), 1) + self.assertEqual(len(ar), 1) ar = self.client[:].apply_async(lambda x: x, range(10)) - self.assertEquals(len(ar), len(self.client.ids)) + self.assertEqual(len(ar), len(self.client.ids)) def test_wall_time_single(self): v = self.client.load_balanced_view() @@ -199,7 +199,7 @@ class AsyncResultTest(ClusterTestCase): self.assertTrue(hr.elapsed > 0., "got bad elapsed: %s" % hr.elapsed) hr.get(1) self.assertTrue(hr.wall_time < ar.wall_time + 0.2, "got bad wall_time: %s > %s" % (hr.wall_time, ar.wall_time)) - self.assertEquals(hr.serial_time, ar.serial_time) + self.assertEqual(hr.serial_time, ar.serial_time) finally: rc2.close() @@ -212,15 +212,15 @@ class AsyncResultTest(ClusterTestCase): ar.get(5) with capture_output() as io: ar.display_outputs() - self.assertEquals(io.stderr, '') - self.assertEquals('5555\n', io.stdout) + self.assertEqual(io.stderr, '') + self.assertEqual('5555\n', io.stdout) ar = v.execute("a=5") ar.get(5) with capture_output() as io: ar.display_outputs() - self.assertEquals(io.stderr, '') - self.assertEquals(io.stdout, '') + self.assertEqual(io.stderr, '') + self.assertEqual(io.stdout, '') def test_display_empty_streams_type(self): """empty stdout/err are not displayed (groupby type)""" @@ -231,17 +231,17 @@ class AsyncResultTest(ClusterTestCase): ar.get(5) with capture_output() as io: ar.display_outputs() - self.assertEquals(io.stderr, '') - self.assertEquals(io.stdout.count('5555'), len(v), io.stdout) + self.assertEqual(io.stderr, '') + self.assertEqual(io.stdout.count('5555'), len(v), io.stdout) self.assertFalse('\n\n' in io.stdout, io.stdout) - self.assertEquals(io.stdout.count('[stdout:'), len(v), io.stdout) + self.assertEqual(io.stdout.count('[stdout:'), len(v), io.stdout) ar = v.execute("a=5") ar.get(5) with capture_output() as io: ar.display_outputs() - self.assertEquals(io.stderr, '') - self.assertEquals(io.stdout, '') + self.assertEqual(io.stderr, '') + self.assertEqual(io.stdout, '') def test_display_empty_streams_engine(self): """empty stdout/err are not displayed (groupby engine)""" @@ -252,16 +252,16 @@ class AsyncResultTest(ClusterTestCase): ar.get(5) with capture_output() as io: ar.display_outputs('engine') - self.assertEquals(io.stderr, '') - self.assertEquals(io.stdout.count('5555'), len(v), io.stdout) + self.assertEqual(io.stderr, '') + self.assertEqual(io.stdout.count('5555'), len(v), io.stdout) self.assertFalse('\n\n' in io.stdout, io.stdout) - self.assertEquals(io.stdout.count('[stdout:'), len(v), io.stdout) + self.assertEqual(io.stdout.count('[stdout:'), len(v), io.stdout) ar = v.execute("a=5") ar.get(5) with capture_output() as io: ar.display_outputs('engine') - self.assertEquals(io.stderr, '') - self.assertEquals(io.stdout, '') + self.assertEqual(io.stderr, '') + self.assertEqual(io.stdout, '') diff --git a/IPython/parallel/tests/test_client.py b/IPython/parallel/tests/test_client.py index 8733503..f57c23b 100644 --- a/IPython/parallel/tests/test_client.py +++ b/IPython/parallel/tests/test_client.py @@ -40,58 +40,58 @@ class TestClient(ClusterTestCase): def test_ids(self): n = len(self.client.ids) self.add_engines(2) - self.assertEquals(len(self.client.ids), n+2) + self.assertEqual(len(self.client.ids), n+2) def test_view_indexing(self): """test index access for views""" self.minimum_engines(4) targets = self.client._build_targets('all')[-1] v = self.client[:] - self.assertEquals(v.targets, targets) + self.assertEqual(v.targets, targets) t = self.client.ids[2] v = self.client[t] self.assert_(isinstance(v, DirectView)) - self.assertEquals(v.targets, t) + self.assertEqual(v.targets, t) t = self.client.ids[2:4] v = self.client[t] self.assert_(isinstance(v, DirectView)) - self.assertEquals(v.targets, t) + self.assertEqual(v.targets, t) v = self.client[::2] self.assert_(isinstance(v, DirectView)) - self.assertEquals(v.targets, targets[::2]) + self.assertEqual(v.targets, targets[::2]) v = self.client[1::3] self.assert_(isinstance(v, DirectView)) - self.assertEquals(v.targets, targets[1::3]) + self.assertEqual(v.targets, targets[1::3]) v = self.client[:-3] self.assert_(isinstance(v, DirectView)) - self.assertEquals(v.targets, targets[:-3]) + self.assertEqual(v.targets, targets[:-3]) v = self.client[-1] self.assert_(isinstance(v, DirectView)) - self.assertEquals(v.targets, targets[-1]) + self.assertEqual(v.targets, targets[-1]) self.assertRaises(TypeError, lambda : self.client[None]) def test_lbview_targets(self): """test load_balanced_view targets""" v = self.client.load_balanced_view() - self.assertEquals(v.targets, None) + self.assertEqual(v.targets, None) v = self.client.load_balanced_view(-1) - self.assertEquals(v.targets, [self.client.ids[-1]]) + self.assertEqual(v.targets, [self.client.ids[-1]]) v = self.client.load_balanced_view('all') - self.assertEquals(v.targets, None) + self.assertEqual(v.targets, None) def test_dview_targets(self): """test direct_view targets""" v = self.client.direct_view() - self.assertEquals(v.targets, 'all') + self.assertEqual(v.targets, 'all') v = self.client.direct_view('all') - self.assertEquals(v.targets, 'all') + self.assertEqual(v.targets, 'all') v = self.client.direct_view(-1) - self.assertEquals(v.targets, self.client.ids[-1]) + self.assertEqual(v.targets, self.client.ids[-1]) def test_lazy_all_targets(self): """test lazy evaluation of rc.direct_view('all')""" v = self.client.direct_view() - self.assertEquals(v.targets, 'all') + self.assertEqual(v.targets, 'all') def double(x): return x*2 @@ -104,11 +104,11 @@ class TestClient(ClusterTestCase): # simple apply r = v.apply_sync(lambda : 1) - self.assertEquals(r, [1] * n1) + self.assertEqual(r, [1] * n1) # map goes through remotefunction r = v.map_sync(double, seq) - self.assertEquals(r, ref) + self.assertEqual(r, ref) # add a couple more engines, and try again self.add_engines(2) @@ -117,18 +117,18 @@ class TestClient(ClusterTestCase): # apply r = v.apply_sync(lambda : 1) - self.assertEquals(r, [1] * n2) + self.assertEqual(r, [1] * n2) # map r = v.map_sync(double, seq) - self.assertEquals(r, ref) + self.assertEqual(r, ref) def test_targets(self): """test various valid targets arguments""" build = self.client._build_targets ids = self.client.ids idents,targets = build(None) - self.assertEquals(ids, targets) + self.assertEqual(ids, targets) def test_clear(self): """test clear behavior""" @@ -154,7 +154,7 @@ class TestClient(ClusterTestCase): time.sleep(.25) ahr = self.client.get_result(ar.msg_ids) self.assertTrue(isinstance(ahr, AsyncHubResult)) - self.assertEquals(ahr.get(), ar.get()) + self.assertEqual(ahr.get(), ar.get()) ar2 = self.client.get_result(ar.msg_ids) self.assertFalse(isinstance(ar2, AsyncHubResult)) c.close() @@ -173,7 +173,7 @@ class TestClient(ClusterTestCase): time.sleep(.25) ahr = self.client.get_result(ar.msg_ids) self.assertTrue(isinstance(ahr, AsyncHubResult)) - self.assertEquals(ahr.get().pyout, ar.get().pyout) + self.assertEqual(ahr.get().pyout, ar.get().pyout) ar2 = self.client.get_result(ar.msg_ids) self.assertFalse(isinstance(ar2, AsyncHubResult)) c.close() @@ -181,7 +181,7 @@ class TestClient(ClusterTestCase): def test_ids_list(self): """test client.ids""" ids = self.client.ids - self.assertEquals(ids, self.client._ids) + self.assertEqual(ids, self.client._ids) self.assertFalse(ids is self.client._ids) ids.remove(ids[-1]) self.assertNotEquals(ids, self.client._ids) @@ -191,16 +191,16 @@ class TestClient(ClusterTestCase): id0 = ids[0] qs = self.client.queue_status(targets=id0) self.assertTrue(isinstance(qs, dict)) - self.assertEquals(sorted(qs.keys()), ['completed', 'queue', 'tasks']) + self.assertEqual(sorted(qs.keys()), ['completed', 'queue', 'tasks']) allqs = self.client.queue_status() self.assertTrue(isinstance(allqs, dict)) intkeys = list(allqs.keys()) intkeys.remove('unassigned') - self.assertEquals(sorted(intkeys), sorted(self.client.ids)) + self.assertEqual(sorted(intkeys), sorted(self.client.ids)) unassigned = allqs.pop('unassigned') for eid,qs in allqs.items(): self.assertTrue(isinstance(qs, dict)) - self.assertEquals(sorted(qs.keys()), ['completed', 'queue', 'tasks']) + self.assertEqual(sorted(qs.keys()), ['completed', 'queue', 'tasks']) def test_shutdown(self): ids = self.client.ids @@ -223,7 +223,7 @@ class TestClient(ClusterTestCase): tic = middle['submitted'] before = self.client.db_query({'submitted' : {'$lt' : tic}}) after = self.client.db_query({'submitted' : {'$gte' : tic}}) - self.assertEquals(len(before)+len(after),len(hist)) + self.assertEqual(len(before)+len(after),len(hist)) for b in before: self.assertTrue(b['submitted'] < tic) for a in after: @@ -236,7 +236,7 @@ class TestClient(ClusterTestCase): """test extracting subset of record keys""" found = self.client.db_query({'msg_id': {'$ne' : ''}},keys=['submitted', 'completed']) for rec in found: - self.assertEquals(set(rec.keys()), set(['msg_id', 'submitted', 'completed'])) + self.assertEqual(set(rec.keys()), set(['msg_id', 'submitted', 'completed'])) def test_db_query_default_keys(self): """default db_query excludes buffers""" @@ -277,10 +277,10 @@ class TestClient(ClusterTestCase): odd = hist[1::2] recs = self.client.db_query({ 'msg_id' : {'$in' : even}}) found = [ r['msg_id'] for r in recs ] - self.assertEquals(set(even), set(found)) + self.assertEqual(set(even), set(found)) recs = self.client.db_query({ 'msg_id' : {'$nin' : even}}) found = [ r['msg_id'] for r in recs ] - self.assertEquals(set(odd), set(found)) + self.assertEqual(set(odd), set(found)) def test_hub_history(self): hist = self.client.hub_history() @@ -298,7 +298,7 @@ class TestClient(ClusterTestCase): ar = self.client[-1].apply_async(lambda : 1) ar.get() time.sleep(0.25) - self.assertEquals(self.client.hub_history()[-1:],ar.msg_ids) + self.assertEqual(self.client.hub_history()[-1:],ar.msg_ids) def _wait_for_idle(self): """wait for an engine to become idle, according to the Hub""" @@ -314,9 +314,9 @@ class TestClient(ClusterTestCase): break # ensure Hub up to date: - self.assertEquals(qs['unassigned'], 0) + self.assertEqual(qs['unassigned'], 0) for eid in rc.ids: - self.assertEquals(qs[eid]['tasks'], 0) + self.assertEqual(qs[eid]['tasks'], 0) def test_resubmit(self): @@ -366,7 +366,7 @@ class TestClient(ClusterTestCase): if key in ('msg_id', 'date'): self.assertNotEquals(h1[key], h2[key]) else: - self.assertEquals(h1[key], h2[key]) + self.assertEqual(h1[key], h2[key]) def test_resubmit_aborted(self): def f(): @@ -414,14 +414,14 @@ class TestClient(ClusterTestCase): ahr.wait(10) self.client.purge_results(hist[-1]) newhist = self.client.hub_history() - self.assertEquals(len(newhist)+1,len(hist)) + self.assertEqual(len(newhist)+1,len(hist)) rc2.spin() rc2.close() def test_purge_all_results(self): self.client.purge_results('all') hist = self.client.hub_history() - self.assertEquals(len(hist), 0) + self.assertEqual(len(hist), 0) def test_spin_thread(self): self.client.spin_thread(0.01) @@ -448,8 +448,8 @@ class TestClient(ClusterTestCase): v0 = self.client.activate(-1, '0') self.assertTrue('px0' in magics['line']) self.assertTrue('px0' in magics['cell']) - self.assertEquals(v0.targets, self.client.ids[-1]) + self.assertEqual(v0.targets, self.client.ids[-1]) v0 = self.client.activate('all', 'all') self.assertTrue('pxall' in magics['line']) self.assertTrue('pxall' in magics['cell']) - self.assertEquals(v0.targets, 'all') + self.assertEqual(v0.targets, 'all') diff --git a/IPython/parallel/tests/test_db.py b/IPython/parallel/tests/test_db.py index e1f2aed..a56dcb2 100644 --- a/IPython/parallel/tests/test_db.py +++ b/IPython/parallel/tests/test_db.py @@ -72,8 +72,8 @@ class TestDictBackend(TestCase): before = self.db.get_history() self.load_records(5) after = self.db.get_history() - self.assertEquals(len(after), len(before)+5) - self.assertEquals(after[:-5],before) + self.assertEqual(len(after), len(before)+5) + self.assertEqual(after[:-5],before) def test_drop_record(self): msg_id = self.load_records()[-1] @@ -95,10 +95,10 @@ class TestDictBackend(TestCase): data = {'stdout': 'hello there', 'completed' : now} self.db.update_record(msg_id, data) rec2 = self.db.get_record(msg_id) - self.assertEquals(rec2['stdout'], 'hello there') - self.assertEquals(rec2['completed'], now) + self.assertEqual(rec2['stdout'], 'hello there') + self.assertEqual(rec2['completed'], now) rec1.update(data) - self.assertEquals(rec1, rec2) + self.assertEqual(rec1, rec2) # def test_update_record_bad(self): # """test updating nonexistant records""" @@ -113,7 +113,7 @@ class TestDictBackend(TestCase): tic = middle['submitted'] before = self.db.find_records({'submitted' : {'$lt' : tic}}) after = self.db.find_records({'submitted' : {'$gte' : tic}}) - self.assertEquals(len(before)+len(after),len(hist)) + self.assertEqual(len(before)+len(after),len(hist)) for b in before: self.assertTrue(b['submitted'] < tic) for a in after: @@ -126,7 +126,7 @@ class TestDictBackend(TestCase): """test extracting subset of record keys""" found = self.db.find_records({'msg_id': {'$ne' : ''}},keys=['submitted', 'completed']) for rec in found: - self.assertEquals(set(rec.keys()), set(['msg_id', 'submitted', 'completed'])) + self.assertEqual(set(rec.keys()), set(['msg_id', 'submitted', 'completed'])) def test_find_records_msg_id(self): """ensure msg_id is always in found records""" @@ -147,10 +147,10 @@ class TestDictBackend(TestCase): odd = hist[1::2] recs = self.db.find_records({ 'msg_id' : {'$in' : even}}) found = [ r['msg_id'] for r in recs ] - self.assertEquals(set(even), set(found)) + self.assertEqual(set(even), set(found)) recs = self.db.find_records({ 'msg_id' : {'$nin' : even}}) found = [ r['msg_id'] for r in recs ] - self.assertEquals(set(odd), set(found)) + self.assertEqual(set(odd), set(found)) def test_get_history(self): msg_ids = self.db.get_history() @@ -161,7 +161,7 @@ class TestDictBackend(TestCase): self.assertTrue(newt >= latest) latest = newt msg_id = self.load_records(1)[-1] - self.assertEquals(self.db.get_history()[-1],msg_id) + self.assertEqual(self.db.get_history()[-1],msg_id) def test_datetime(self): """get/set timestamps with datetime objects""" @@ -177,7 +177,7 @@ class TestDictBackend(TestCase): query = {'msg_id' : {'$in':msg_ids}} self.db.drop_matching_records(query) recs = self.db.find_records(query) - self.assertEquals(len(recs), 0) + self.assertEqual(len(recs), 0) def test_null(self): """test None comparison queries""" @@ -185,7 +185,7 @@ class TestDictBackend(TestCase): query = {'msg_id' : None} recs = self.db.find_records(query) - self.assertEquals(len(recs), 0) + self.assertEqual(len(recs), 0) query = {'msg_id' : {'$ne' : None}} recs = self.db.find_records(query) @@ -201,7 +201,7 @@ class TestDictBackend(TestCase): rec2 = self.db.get_record(msg_id) self.assertTrue('buffers' in rec2) self.assertFalse('garbage' in rec2) - self.assertEquals(rec2['header']['msg_id'], msg_id) + self.assertEqual(rec2['header']['msg_id'], msg_id) def test_pop_safe_find(self): """editing query results shouldn't affect record [find]""" @@ -213,7 +213,7 @@ class TestDictBackend(TestCase): rec2 = self.db.find_records({'msg_id' : msg_id})[0] self.assertTrue('buffers' in rec2) self.assertFalse('garbage' in rec2) - self.assertEquals(rec2['header']['msg_id'], msg_id) + self.assertEqual(rec2['header']['msg_id'], msg_id) def test_pop_safe_find_keys(self): """editing query results shouldn't affect record [find+keys]""" @@ -225,7 +225,7 @@ class TestDictBackend(TestCase): rec2 = self.db.find_records({'msg_id' : msg_id})[0] self.assertTrue('buffers' in rec2) self.assertFalse('garbage' in rec2) - self.assertEquals(rec2['header']['msg_id'], msg_id) + self.assertEqual(rec2['header']['msg_id'], msg_id) class TestSQLiteBackend(TestDictBackend): diff --git a/IPython/parallel/tests/test_dependency.py b/IPython/parallel/tests/test_dependency.py index 1fb1e50..ffe5b8c 100644 --- a/IPython/parallel/tests/test_dependency.py +++ b/IPython/parallel/tests/test_dependency.py @@ -75,7 +75,7 @@ class DependencyTest(ClusterTestCase): def encode(dikt): return urllib.urlencode(dikt) # must pass through canning to properly connect namespaces - self.assertEquals(encode(dict(a=5)), 'a=5') + self.assertEqual(encode(dict(a=5)), 'a=5') def test_success_only(self): dep = pmod.Dependency(mixed, success=True, failure=False) diff --git a/IPython/parallel/tests/test_lbview.py b/IPython/parallel/tests/test_lbview.py index f1774ac..ce985f0 100644 --- a/IPython/parallel/tests/test_lbview.py +++ b/IPython/parallel/tests/test_lbview.py @@ -56,7 +56,7 @@ class TestLoadBalancedView(ClusterTestCase): return x**2 data = range(16) r = self.view.map_sync(f, data) - self.assertEquals(r, map(f, data)) + self.assertEqual(r, map(f, data)) def test_map_unordered(self): def f(x): @@ -75,7 +75,7 @@ class TestLoadBalancedView(ClusterTestCase): astheycame = [ r for r in amr ] # Ensure that at least one result came out of order: self.assertNotEquals(astheycame, reference, "should not have preserved order") - self.assertEquals(sorted(astheycame, reverse=True), reference, "result corrupted") + self.assertEqual(sorted(astheycame, reverse=True), reference, "result corrupted") def test_map_ordered(self): def f(x): @@ -93,8 +93,8 @@ class TestLoadBalancedView(ClusterTestCase): # list(amr) uses __iter__ astheycame = list(amr) # Ensure that results came in order - self.assertEquals(astheycame, reference) - self.assertEquals(amr.result, reference) + self.assertEqual(astheycame, reference) + self.assertEqual(amr.result, reference) def test_map_iterable(self): """test map on iterables (balanced)""" @@ -104,7 +104,7 @@ class TestLoadBalancedView(ClusterTestCase): # so that it will be an iterator, even in Python 3 it = iter(arr) r = view.map_sync(lambda x:x, arr) - self.assertEquals(r, list(arr)) + self.assertEqual(r, list(arr)) def test_abort(self): @@ -163,7 +163,7 @@ class TestLoadBalancedView(ClusterTestCase): ars.append(self.view.apply_async(lambda : 1)) self.view.wait(ars) for ar in ars: - self.assertEquals(ar.engine_id, first_id) + self.assertEqual(ar.engine_id, first_id) def test_after(self): view = self.view diff --git a/IPython/parallel/tests/test_magics.py b/IPython/parallel/tests/test_magics.py index f488db1..dae6c3b 100644 --- a/IPython/parallel/tests/test_magics.py +++ b/IPython/parallel/tests/test_magics.py @@ -48,9 +48,9 @@ class TestParallelMagics(ClusterTestCase, ParametricTestCase): v.block=True ip.magic('px a=5') - self.assertEquals(v['a'], [5]) + self.assertEqual(v['a'], [5]) ip.magic('px a=10') - self.assertEquals(v['a'], [10]) + self.assertEqual(v['a'], [10]) # just 'print a' works ~99% of the time, but this ensures that # the stdout message has arrived when the result is finished: with capture_output() as io: @@ -72,7 +72,7 @@ class TestParallelMagics(ClusterTestCase, ParametricTestCase): self.assertFalse('\n\n' in stderr, stderr) lines = stderr.splitlines() - self.assertEquals(len(lines), len(expected), stderr) + self.assertEqual(len(lines), len(expected), stderr) for line,expect in zip(lines, expected): if isinstance(expect, str): expect = [expect] @@ -128,7 +128,7 @@ class TestParallelMagics(ClusterTestCase, ParametricTestCase): r'Out\[\d+:\d+\]:.*IPython\.core\.display\.Math', ] * len(v) - self.assertEquals(len(lines), len(expected), io.stdout) + self.assertEqual(len(lines), len(expected), io.stdout) for line,expect in zip(lines, expected): if isinstance(expect, str): expect = [expect] @@ -170,7 +170,7 @@ class TestParallelMagics(ClusterTestCase, ParametricTestCase): r'Out\[\d+:\d+\]:.*IPython\.core\.display\.Math' ] * len(v)) - self.assertEquals(len(lines), len(expected), io.stdout) + self.assertEqual(len(lines), len(expected), io.stdout) for line,expect in zip(lines, expected): if isinstance(expect, str): expect = [expect] @@ -209,7 +209,7 @@ class TestParallelMagics(ClusterTestCase, ParametricTestCase): (r'Out\[\d+:\d+\]', r'IPython\.core\.display\.Math') ] * len(v)) - self.assertEquals(len(lines), len(expected), io.stdout) + self.assertEqual(len(lines), len(expected), io.stdout) for line,expect in zip(lines, expected): if isinstance(expect, str): expect = [expect] @@ -226,9 +226,9 @@ class TestParallelMagics(ClusterTestCase, ParametricTestCase): v.block=False ip.magic('px a=5') - self.assertEquals(v['a'], [5]) + self.assertEqual(v['a'], [5]) ip.magic('px a=10') - self.assertEquals(v['a'], [10]) + self.assertEqual(v['a'], [10]) ip.magic('pxconfig --verbose') with capture_output() as io: ar = ip.magic('px print (a)') @@ -263,8 +263,8 @@ class TestParallelMagics(ClusterTestCase, ParametricTestCase): self.assertTrue('\nOut[' in output, output) self.assertTrue(': 24690' in output, output) ar = v.get_result(-1) - self.assertEquals(v['a'], 5) - self.assertEquals(v['b'], 24690) + self.assertEqual(v['a'], 5) + self.assertEqual(v['b'], 24690) self.assertRaisesRemote(ZeroDivisionError, ar.get) def test_autopx_nonblocking(self): @@ -291,9 +291,9 @@ class TestParallelMagics(ClusterTestCase, ParametricTestCase): self.assertRaisesRemote(ZeroDivisionError, ar.get) # prevent TaskAborted on pulls, due to ZeroDivisionError time.sleep(0.5) - self.assertEquals(v['a'], 5) + self.assertEqual(v['a'], 5) # b*=2 will not fire, due to abort - self.assertEquals(v['b'], 10) + self.assertEqual(v['b'], 10) def test_result(self): ip = get_ipython() @@ -335,26 +335,26 @@ class TestParallelMagics(ClusterTestCase, ParametricTestCase): ip = get_ipython() rc = self.client v = rc.activate(-1, '_tst') - self.assertEquals(v.targets, rc.ids[-1]) + self.assertEqual(v.targets, rc.ids[-1]) ip.magic("%pxconfig_tst -t :") - self.assertEquals(v.targets, rc.ids) + self.assertEqual(v.targets, rc.ids) ip.magic("%pxconfig_tst -t ::2") - self.assertEquals(v.targets, rc.ids[::2]) + self.assertEqual(v.targets, rc.ids[::2]) ip.magic("%pxconfig_tst -t 1::2") - self.assertEquals(v.targets, rc.ids[1::2]) + self.assertEqual(v.targets, rc.ids[1::2]) ip.magic("%pxconfig_tst -t 1") - self.assertEquals(v.targets, 1) + self.assertEqual(v.targets, 1) ip.magic("%pxconfig_tst --block") - self.assertEquals(v.block, True) + self.assertEqual(v.block, True) ip.magic("%pxconfig_tst --noblock") - self.assertEquals(v.block, False) + self.assertEqual(v.block, False) def test_cellpx_targets(self): """%%px --targets doesn't change defaults""" ip = get_ipython() rc = self.client view = rc.activate(rc.ids) - self.assertEquals(view.targets, rc.ids) + self.assertEqual(view.targets, rc.ids) ip.magic('pxconfig --verbose') for cell in ("pass", "1/0"): with capture_output() as io: @@ -363,7 +363,7 @@ class TestParallelMagics(ClusterTestCase, ParametricTestCase): except pmod.RemoteError: pass self.assertTrue('engine(s): all' in io.stdout) - self.assertEquals(view.targets, rc.ids) + self.assertEqual(view.targets, rc.ids) def test_cellpx_block(self): @@ -372,7 +372,7 @@ class TestParallelMagics(ClusterTestCase, ParametricTestCase): rc = self.client view = rc.activate(rc.ids) view.block = False - self.assertEquals(view.targets, rc.ids) + self.assertEqual(view.targets, rc.ids) ip.magic('pxconfig --verbose') for cell in ("pass", "1/0"): with capture_output() as io: diff --git a/IPython/parallel/tests/test_newserialized.py b/IPython/parallel/tests/test_newserialized.py index 4a2f883..c7a6180 100644 --- a/IPython/parallel/tests/test_newserialized.py +++ b/IPython/parallel/tests/test_newserialized.py @@ -60,7 +60,7 @@ class CanningTestCase(TestCase): s = ns.serialize(us) uus = ns.unserialize(s) self.assertTrue(isinstance(s, ns.SerializeIt)) - self.assertEquals(uus, us) + self.assertEqual(uus, us) def test_pickle_serialized(self): obj = {'a':1.45345, 'b':'asdfsdf', 'c':10000L} @@ -69,16 +69,16 @@ class CanningTestCase(TestCase): firstData = originalSer.getData() firstTD = originalSer.getTypeDescriptor() firstMD = originalSer.getMetadata() - self.assertEquals(firstTD, 'pickle') - self.assertEquals(firstMD, {}) + self.assertEqual(firstTD, 'pickle') + self.assertEqual(firstMD, {}) unSerialized = ns.UnSerializeIt(originalSer) secondObj = unSerialized.getObject() for k, v in secondObj.iteritems(): - self.assertEquals(obj[k], v) + self.assertEqual(obj[k], v) secondSer = ns.SerializeIt(ns.UnSerialized(secondObj)) - self.assertEquals(firstData, secondSer.getData()) - self.assertEquals(firstTD, secondSer.getTypeDescriptor() ) - self.assertEquals(firstMD, secondSer.getMetadata()) + self.assertEqual(firstData, secondSer.getData()) + self.assertEqual(firstTD, secondSer.getTypeDescriptor() ) + self.assertEqual(firstMD, secondSer.getMetadata()) @skip_without('numpy') def test_ndarray_serialized(self): @@ -87,18 +87,18 @@ class CanningTestCase(TestCase): unSer1 = ns.UnSerialized(a) ser1 = ns.SerializeIt(unSer1) td = ser1.getTypeDescriptor() - self.assertEquals(td, 'ndarray') + self.assertEqual(td, 'ndarray') md = ser1.getMetadata() - self.assertEquals(md['shape'], a.shape) - self.assertEquals(md['dtype'], a.dtype) + self.assertEqual(md['shape'], a.shape) + self.assertEqual(md['dtype'], a.dtype) buff = ser1.getData() - self.assertEquals(buff, buffer(a)) + self.assertEqual(buff, buffer(a)) s = ns.Serialized(buff, td, md) final = ns.unserialize(s) - self.assertEquals(buffer(a), buffer(final)) + self.assertEqual(buffer(a), buffer(final)) self.assertTrue((a==final).all()) - self.assertEquals(a.dtype, final.dtype) - self.assertEquals(a.shape, final.shape) + self.assertEqual(a.dtype, final.dtype) + self.assertEqual(a.shape, final.shape) # test non-copying: a[2] = 1e9 self.assertTrue((a==final).all()) diff --git a/IPython/parallel/tests/test_view.py b/IPython/parallel/tests/test_view.py index fe90d83..e13399c 100644 --- a/IPython/parallel/tests/test_view.py +++ b/IPython/parallel/tests/test_view.py @@ -75,20 +75,20 @@ class TestView(ClusterTestCase, ParametricTestCase): nengines = len(self.client) push({'data':data}) d = pull('data') - self.assertEquals(d, data) + self.assertEqual(d, data) self.client[:].push({'data':data}) d = self.client[:].pull('data', block=True) - self.assertEquals(d, nengines*[data]) + self.assertEqual(d, nengines*[data]) ar = push({'data':data}, block=False) self.assertTrue(isinstance(ar, AsyncResult)) r = ar.get() ar = self.client[:].pull('data', block=False) self.assertTrue(isinstance(ar, AsyncResult)) r = ar.get() - self.assertEquals(r, nengines*[data]) + self.assertEqual(r, nengines*[data]) self.client[:].push(dict(a=10,b=20)) r = self.client[:].pull(('a','b'), block=True) - self.assertEquals(r, nengines*[[10,20]]) + self.assertEqual(r, nengines*[[10,20]]) def test_push_pull_function(self): "test pushing and pulling functions" @@ -106,7 +106,7 @@ class TestView(ClusterTestCase, ParametricTestCase): self.assertEqual(r(1.0), testf(1.0)) execute('r = testf(10)') r = pull('r') - self.assertEquals(r, testf(10)) + self.assertEqual(r, testf(10)) ar = self.client[:].push({'testf':testf}, block=False) ar.get() ar = self.client[:].pull('testf', block=False) @@ -115,7 +115,7 @@ class TestView(ClusterTestCase, ParametricTestCase): self.assertEqual(r(1.0), testf(1.0)) execute("def g(x): return x*x") r = pull(('testf','g')) - self.assertEquals((r[0](10),r[1](10)), (testf(10), 100)) + self.assertEqual((r[0](10),r[1](10)), (testf(10), 100)) def test_push_function_globals(self): """test that pushed functions have access to globals""" @@ -129,7 +129,7 @@ class TestView(ClusterTestCase, ParametricTestCase): self.assertRaisesRemote(NameError, v.execute, 'b=f()') v.execute('a=5') v.execute('b=f()') - self.assertEquals(v['b'], 5) + self.assertEqual(v['b'], 5) def test_push_function_defaults(self): """test that pushed functions preserve default args""" @@ -139,7 +139,7 @@ class TestView(ClusterTestCase, ParametricTestCase): v.block=True v['f'] = echo v.execute('b=f()') - self.assertEquals(v['b'], 10) + self.assertEqual(v['b'], 10) def test_get_result(self): """test getting results from the Hub.""" @@ -153,7 +153,7 @@ class TestView(ClusterTestCase, ParametricTestCase): time.sleep(.25) ahr = v2.get_result(ar.msg_ids) self.assertTrue(isinstance(ahr, AsyncHubResult)) - self.assertEquals(ahr.get(), ar.get()) + self.assertEqual(ahr.get(), ar.get()) ar2 = v2.get_result(ar.msg_ids) self.assertFalse(isinstance(ar2, AsyncHubResult)) c.spin() @@ -168,7 +168,7 @@ class TestView(ClusterTestCase, ParametricTestCase): """) v = self.client[-1] v.run(tmpfile, block=True) - self.assertEquals(v.apply_sync(lambda f: f(), pmod.Reference('g')), 5) + self.assertEqual(v.apply_sync(lambda f: f(), pmod.Reference('g')), 5) def test_apply_tracked(self): """test tracking for apply""" @@ -184,7 +184,7 @@ class TestView(ClusterTestCase, ParametricTestCase): self.assertTrue(ar.sent) ar = echo(track=True) self.assertTrue(isinstance(ar._tracker, zmq.MessageTracker)) - self.assertEquals(ar.sent, ar._tracker.done) + self.assertEqual(ar.sent, ar._tracker.done) ar._tracker.wait() self.assertTrue(ar.sent) @@ -199,7 +199,7 @@ class TestView(ClusterTestCase, ParametricTestCase): ar = v.push(ns, block=False, track=True) self.assertTrue(isinstance(ar._tracker, zmq.MessageTracker)) ar._tracker.wait() - self.assertEquals(ar.sent, ar._tracker.done) + self.assertEqual(ar.sent, ar._tracker.done) self.assertTrue(ar.sent) ar.get() @@ -212,7 +212,7 @@ class TestView(ClusterTestCase, ParametricTestCase): ar = self.client[t].scatter('x', x, block=False, track=True) self.assertTrue(isinstance(ar._tracker, zmq.MessageTracker)) - self.assertEquals(ar.sent, ar._tracker.done) + self.assertEqual(ar.sent, ar._tracker.done) ar._tracker.wait() self.assertTrue(ar.sent) ar.get() @@ -222,7 +222,7 @@ class TestView(ClusterTestCase, ParametricTestCase): v['a'] = 123 ra = pmod.Reference('a') b = v.apply_sync(lambda x: x, ra) - self.assertEquals(b, 123) + self.assertEqual(b, 123) def test_scatter_gather(self): @@ -230,7 +230,7 @@ class TestView(ClusterTestCase, ParametricTestCase): seq1 = range(16) view.scatter('a', seq1) seq2 = view.gather('a', block=True) - self.assertEquals(seq2, seq1) + self.assertEqual(seq2, seq1) self.assertRaisesRemote(NameError, view.gather, 'asdf', block=True) @skip_without('numpy') @@ -249,7 +249,7 @@ class TestView(ClusterTestCase, ParametricTestCase): x = range(64) view.scatter('x', x) gathered = view.gather('x', block=True) - self.assertEquals(gathered, x) + self.assertEqual(gathered, x) @dec.known_failure_py3 @@ -301,10 +301,10 @@ class TestView(ClusterTestCase, ParametricTestCase): R2 = view['RR'] r_dtype, r_shape = view.apply_sync(interactive(lambda : (RR.dtype, RR.shape))) - self.assertEquals(r_dtype, R.dtype) - self.assertEquals(r_shape, R.shape) - self.assertEquals(R2.dtype, R.dtype) - self.assertEquals(R2.shape, R.shape) + self.assertEqual(r_dtype, R.dtype) + self.assertEqual(r_shape, R.shape) + self.assertEqual(R2.dtype, R.dtype) + self.assertEqual(R2.shape, R.shape) assert_array_equal(R2, R) def test_map(self): @@ -313,7 +313,7 @@ class TestView(ClusterTestCase, ParametricTestCase): return x**2 data = range(16) r = view.map_sync(f, data) - self.assertEquals(r, map(f, data)) + self.assertEqual(r, map(f, data)) def test_map_iterable(self): """test map on iterables (direct)""" @@ -323,14 +323,14 @@ class TestView(ClusterTestCase, ParametricTestCase): # ensure it will be an iterator, even in Python 3 it = iter(arr) r = view.map_sync(lambda x:x, arr) - self.assertEquals(r, list(arr)) + self.assertEqual(r, list(arr)) def test_scatterGatherNonblocking(self): data = range(16) view = self.client[:] view.scatter('a', data, block=False) ar = view.gather('a', block=False) - self.assertEquals(ar.get(), data) + self.assertEqual(ar.get(), data) @skip_without('numpy') def test_scatter_gather_numpy_nonblocking(self): @@ -352,9 +352,9 @@ class TestView(ClusterTestCase, ParametricTestCase): self.assertTrue(isinstance(ar, AsyncResult)) ar = execute('d=[0,1,2]', block=False) self.client.wait(ar, 1) - self.assertEquals(len(ar.get()), len(self.client)) + self.assertEqual(len(ar.get()), len(self.client)) for c in view['c']: - self.assertEquals(c, 30) + self.assertEqual(c, 30) def test_abort(self): view = self.client[-1] @@ -396,7 +396,7 @@ class TestView(ClusterTestCase, ParametricTestCase): re = globals()['re'] return re.findall(pat, s) - self.assertEquals(view.apply_sync(findall, '\w+', 'hello world'), 'hello world'.split()) + self.assertEqual(view.apply_sync(findall, '\w+', 'hello world'), 'hello world'.split()) def test_unicode_execute(self): """test executing unicode strings""" @@ -407,13 +407,13 @@ class TestView(ClusterTestCase, ParametricTestCase): else: code=u"a=u'é'" v.execute(code) - self.assertEquals(v['a'], u'é') + self.assertEqual(v['a'], u'é') def test_unicode_apply_result(self): """test unicode apply results""" v = self.client[-1] r = v.apply_sync(lambda : u'é') - self.assertEquals(r, u'é') + self.assertEqual(r, u'é') def test_unicode_apply_arg(self): """test passing unicode arguments to apply""" @@ -444,7 +444,7 @@ class TestView(ClusterTestCase, ParametricTestCase): mlist = nlist[::-1] expected = [ m*n for m,n in zip(mlist, nlist) ] result = v.map_sync(rf, mlist, nlist) - self.assertEquals(result, expected) + self.assertEqual(result, expected) def test_apply_reference(self): """view.apply(, *args) should work""" @@ -454,14 +454,14 @@ class TestView(ClusterTestCase, ParametricTestCase): rf = pmod.Reference('f') result = v.apply_sync(rf, 5) expected = [ 5*id for id in self.client.ids ] - self.assertEquals(result, expected) + self.assertEqual(result, expected) def test_eval_reference(self): v = self.client[self.client.ids[0]] v['g'] = range(5) rg = pmod.Reference('g[0]') echo = lambda x:x - self.assertEquals(v.apply_sync(echo, rg), 0) + self.assertEqual(v.apply_sync(echo, rg), 0) def test_reference_nameerror(self): v = self.client[self.client.ids[0]] @@ -474,22 +474,22 @@ class TestView(ClusterTestCase, ParametricTestCase): r = range(5) check = [ -1*i for i in r ] result = e0.map_sync(lambda x: -1*x, r) - self.assertEquals(result, check) + self.assertEqual(result, check) def test_len(self): """len(view) makes sense""" e0 = self.client[self.client.ids[0]] - yield self.assertEquals(len(e0), 1) + yield self.assertEqual(len(e0), 1) v = self.client[:] - yield self.assertEquals(len(v), len(self.client.ids)) + yield self.assertEqual(len(v), len(self.client.ids)) v = self.client.direct_view('all') - yield self.assertEquals(len(v), len(self.client.ids)) + yield self.assertEqual(len(v), len(self.client.ids)) v = self.client[:2] - yield self.assertEquals(len(v), 2) + yield self.assertEqual(len(v), 2) v = self.client[:1] - yield self.assertEquals(len(v), 1) + yield self.assertEqual(len(v), 1) v = self.client.load_balanced_view() - yield self.assertEquals(len(v), len(self.client.ids)) + yield self.assertEqual(len(v), len(self.client.ids)) # parametric tests seem to require manual closing? self.client.close() @@ -501,15 +501,15 @@ class TestView(ClusterTestCase, ParametricTestCase): e0.block = True ar = e0.execute("5", silent=False) er = ar.get() - self.assertEquals(str(er), "" % er.execution_count) - self.assertEquals(er.pyout['data']['text/plain'], '5') + self.assertEqual(str(er), "" % er.execution_count) + self.assertEqual(er.pyout['data']['text/plain'], '5') def test_execute_reply_stdout(self): e0 = self.client[self.client.ids[0]] e0.block = True ar = e0.execute("print (5)", silent=False) er = ar.get() - self.assertEquals(er.stdout.strip(), '5') + self.assertEqual(er.stdout.strip(), '5') def test_execute_pyout(self): """execute triggers pyout with silent=False""" @@ -518,14 +518,14 @@ class TestView(ClusterTestCase, ParametricTestCase): expected = [{'text/plain' : '5'}] * len(view) mimes = [ out['data'] for out in ar.pyout ] - self.assertEquals(mimes, expected) + self.assertEqual(mimes, expected) def test_execute_silent(self): """execute does not trigger pyout with silent=True""" view = self.client[:] ar = view.execute("5", block=True) expected = [None] * len(view) - self.assertEquals(ar.pyout, expected) + self.assertEqual(ar.pyout, expected) def test_execute_magic(self): """execute accepts IPython commands""" @@ -536,7 +536,7 @@ class TestView(ClusterTestCase, ParametricTestCase): ar.get(5) for stdout in ar.stdout: lines = stdout.splitlines() - self.assertEquals(lines[0].split(), ['Variable', 'Type', 'Data/Info']) + self.assertEqual(lines[0].split(), ['Variable', 'Type', 'Data/Info']) found = False for line in lines[2:]: split = line.split() @@ -554,7 +554,7 @@ class TestView(ClusterTestCase, ParametricTestCase): expected = [ {u'text/plain' : unicode(j)} for j in range(5) ] for outputs in ar.outputs: mimes = [ out['data'] for out in outputs ] - self.assertEquals(mimes, expected) + self.assertEqual(mimes, expected) def test_apply_displaypub(self): """apply tracks display_pub output""" @@ -570,7 +570,7 @@ class TestView(ClusterTestCase, ParametricTestCase): expected = [ {u'text/plain' : unicode(j)} for j in range(5) ] for outputs in ar.outputs: mimes = [ out['data'] for out in outputs ] - self.assertEquals(mimes, expected) + self.assertEqual(mimes, expected) def test_execute_raises(self): """exceptions in execute requests raise appropriately""" @@ -588,7 +588,7 @@ class TestView(ClusterTestCase, ParametricTestCase): # include imports, in case user config ar = view.execute("plot(rand(100))", silent=False) reply = ar.get(5) - self.assertEquals(len(reply.outputs), 1) + self.assertEqual(len(reply.outputs), 1) output = reply.outputs[0] self.assertTrue("data" in output) data = output['data'] diff --git a/IPython/utils/tests/test_process.py b/IPython/utils/tests/test_process.py index f946fcf..3827a45 100644 --- a/IPython/utils/tests/test_process.py +++ b/IPython/utils/tests/test_process.py @@ -103,29 +103,29 @@ class SubProcessTestCase(TestCase, tt.TempFileMixin): def test_system(self): status = system('python "%s"' % self.fname) - self.assertEquals(status, 0) + self.assertEqual(status, 0) def test_system_quotes(self): status = system('python -c "import sys"') - self.assertEquals(status, 0) + self.assertEqual(status, 0) def test_getoutput(self): out = getoutput('python "%s"' % self.fname) - self.assertEquals(out, 'on stdout') + self.assertEqual(out, 'on stdout') def test_getoutput_quoted(self): out = getoutput('python -c "print (1)"') - self.assertEquals(out.strip(), '1') + self.assertEqual(out.strip(), '1') #Invalid quoting on windows @dec.skip_win32 def test_getoutput_quoted2(self): out = getoutput("python -c 'print (1)'") - self.assertEquals(out.strip(), '1') + self.assertEqual(out.strip(), '1') out = getoutput("python -c 'print (\"1\")'") - self.assertEquals(out.strip(), '1') + self.assertEqual(out.strip(), '1') def test_getoutput(self): out, err = getoutputerror('python "%s"' % self.fname) - self.assertEquals(out, 'on stdout') - self.assertEquals(err, 'on stderr') + self.assertEqual(out, 'on stdout') + self.assertEqual(err, 'on stderr') diff --git a/IPython/utils/tests/test_traitlets.py b/IPython/utils/tests/test_traitlets.py index 2c2985c..a056efe 100644 --- a/IPython/utils/tests/test_traitlets.py +++ b/IPython/utils/tests/test_traitlets.py @@ -60,7 +60,7 @@ class TestTraitType(TestCase): class A(HasTraits): a = TraitType a = A() - self.assertEquals(a.a, Undefined) + self.assertEqual(a.a, Undefined) def test_set(self): class A(HasTraitsStub): @@ -68,10 +68,10 @@ class TestTraitType(TestCase): a = A() a.a = 10 - self.assertEquals(a.a, 10) - self.assertEquals(a._notify_name, 'a') - self.assertEquals(a._notify_old, Undefined) - self.assertEquals(a._notify_new, 10) + self.assertEqual(a.a, 10) + self.assertEqual(a._notify_name, 'a') + self.assertEqual(a._notify_old, Undefined) + self.assertEqual(a._notify_new, 10) def test_validate(self): class MyTT(TraitType): @@ -82,7 +82,7 @@ class TestTraitType(TestCase): a = A() a.tt = 10 - self.assertEquals(a.tt, -1) + self.assertEqual(a.tt, -1) def test_default_validate(self): class MyIntTT(TraitType): @@ -93,7 +93,7 @@ class TestTraitType(TestCase): class A(HasTraits): tt = MyIntTT(10) a = A() - self.assertEquals(a.tt, 10) + self.assertEqual(a.tt, 10) # Defaults are validated when the HasTraits is instantiated class B(HasTraits): @@ -109,7 +109,7 @@ class TestTraitType(TestCase): a = A() a.tt = 10 - self.assertEquals(a.tt, 10) + self.assertEqual(a.tt, 10) def test_value_for(self): class MyTT(TraitType): @@ -120,13 +120,13 @@ class TestTraitType(TestCase): a = A() a.tt = 10 - self.assertEquals(a.tt, 20) + self.assertEqual(a.tt, 20) def test_info(self): class A(HasTraits): tt = TraitType a = A() - self.assertEquals(A.tt.info(), 'any value') + self.assertEqual(A.tt.info(), 'any value') def test_error(self): class A(HasTraits): @@ -146,59 +146,59 @@ class TestTraitType(TestCase): return 21 a = A() - self.assertEquals(a._trait_values, {}) - self.assertEquals(a._trait_dyn_inits.keys(), ['x']) - self.assertEquals(a.x, 11) - self.assertEquals(a._trait_values, {'x': 11}) + self.assertEqual(a._trait_values, {}) + self.assertEqual(a._trait_dyn_inits.keys(), ['x']) + self.assertEqual(a.x, 11) + self.assertEqual(a._trait_values, {'x': 11}) b = B() - self.assertEquals(b._trait_values, {'x': 20}) - self.assertEquals(a._trait_dyn_inits.keys(), ['x']) - self.assertEquals(b.x, 20) + self.assertEqual(b._trait_values, {'x': 20}) + self.assertEqual(a._trait_dyn_inits.keys(), ['x']) + self.assertEqual(b.x, 20) c = C() - self.assertEquals(c._trait_values, {}) - self.assertEquals(a._trait_dyn_inits.keys(), ['x']) - self.assertEquals(c.x, 21) - self.assertEquals(c._trait_values, {'x': 21}) + self.assertEqual(c._trait_values, {}) + self.assertEqual(a._trait_dyn_inits.keys(), ['x']) + self.assertEqual(c.x, 21) + self.assertEqual(c._trait_values, {'x': 21}) # Ensure that the base class remains unmolested when the _default # initializer gets overridden in a subclass. a = A() c = C() - self.assertEquals(a._trait_values, {}) - self.assertEquals(a._trait_dyn_inits.keys(), ['x']) - self.assertEquals(a.x, 11) - self.assertEquals(a._trait_values, {'x': 11}) + self.assertEqual(a._trait_values, {}) + self.assertEqual(a._trait_dyn_inits.keys(), ['x']) + self.assertEqual(a.x, 11) + self.assertEqual(a._trait_values, {'x': 11}) class TestHasTraitsMeta(TestCase): def test_metaclass(self): - self.assertEquals(type(HasTraits), MetaHasTraits) + self.assertEqual(type(HasTraits), MetaHasTraits) class A(HasTraits): a = Int a = A() - self.assertEquals(type(a.__class__), MetaHasTraits) - self.assertEquals(a.a,0) + self.assertEqual(type(a.__class__), MetaHasTraits) + self.assertEqual(a.a,0) a.a = 10 - self.assertEquals(a.a,10) + self.assertEqual(a.a,10) class B(HasTraits): b = Int() b = B() - self.assertEquals(b.b,0) + self.assertEqual(b.b,0) b.b = 10 - self.assertEquals(b.b,10) + self.assertEqual(b.b,10) class C(HasTraits): c = Int(30) c = C() - self.assertEquals(c.c,30) + self.assertEqual(c.c,30) c.c = 10 - self.assertEquals(c.c,10) + self.assertEqual(c.c,10) def test_this_class(self): class A(HasTraits): @@ -207,10 +207,10 @@ class TestHasTraitsMeta(TestCase): class B(A): tt = This() ttt = This() - self.assertEquals(A.t.this_class, A) - self.assertEquals(B.t.this_class, A) - self.assertEquals(B.tt.this_class, B) - self.assertEquals(B.ttt.this_class, B) + self.assertEqual(A.t.this_class, A) + self.assertEqual(B.t.this_class, A) + self.assertEqual(B.tt.this_class, B) + self.assertEqual(B.ttt.this_class, B) class TestHasTraitsNotify(TestCase): @@ -233,9 +233,9 @@ class TestHasTraitsNotify(TestCase): a = A() a.on_trait_change(self.notify1) a.a = 0 - self.assertEquals(len(self._notify1),0) + self.assertEqual(len(self._notify1),0) a.b = 0.0 - self.assertEquals(len(self._notify1),0) + self.assertEqual(len(self._notify1),0) a.a = 10 self.assert_(('a',0,10) in self._notify1) a.b = 10.0 @@ -246,7 +246,7 @@ class TestHasTraitsNotify(TestCase): a.on_trait_change(self.notify1,remove=True) a.a = 20 a.b = 20.0 - self.assertEquals(len(self._notify1),0) + self.assertEqual(len(self._notify1),0) def test_notify_one(self): @@ -257,7 +257,7 @@ class TestHasTraitsNotify(TestCase): a = A() a.on_trait_change(self.notify1, 'a') a.a = 0 - self.assertEquals(len(self._notify1),0) + self.assertEqual(len(self._notify1),0) a.a = 10 self.assert_(('a',0,10) in self._notify1) self.assertRaises(TraitError,setattr,a,'a','bad string') @@ -271,12 +271,12 @@ class TestHasTraitsNotify(TestCase): b = Float b = B() - self.assertEquals(b.a,0) - self.assertEquals(b.b,0.0) + self.assertEqual(b.a,0) + self.assertEqual(b.b,0.0) b.a = 100 b.b = 100.0 - self.assertEquals(b.a,100) - self.assertEquals(b.b,100.0) + self.assertEqual(b.a,100) + self.assertEqual(b.b,100.0) def test_notify_subclass(self): @@ -291,8 +291,8 @@ class TestHasTraitsNotify(TestCase): b.on_trait_change(self.notify2, 'b') b.a = 0 b.b = 0.0 - self.assertEquals(len(self._notify1),0) - self.assertEquals(len(self._notify2),0) + self.assertEqual(len(self._notify1),0) + self.assertEqual(len(self._notify2),0) b.a = 10 b.b = 10.0 self.assert_(('a',0,10) in self._notify1) @@ -309,7 +309,7 @@ class TestHasTraitsNotify(TestCase): a = A() a.a = 0 # This is broken!!! - self.assertEquals(len(a._notify1),0) + self.assertEqual(len(a._notify1),0) a.a = 10 self.assert_(('a',0,10) in a._notify1) @@ -342,25 +342,25 @@ class TestHasTraitsNotify(TestCase): a = A() a.on_trait_change(callback0, 'a') a.a = 10 - self.assertEquals(self.cb,()) + self.assertEqual(self.cb,()) a.on_trait_change(callback0, 'a', remove=True) a.on_trait_change(callback1, 'a') a.a = 100 - self.assertEquals(self.cb,('a',)) + self.assertEqual(self.cb,('a',)) a.on_trait_change(callback1, 'a', remove=True) a.on_trait_change(callback2, 'a') a.a = 1000 - self.assertEquals(self.cb,('a',1000)) + self.assertEqual(self.cb,('a',1000)) a.on_trait_change(callback2, 'a', remove=True) a.on_trait_change(callback3, 'a') a.a = 10000 - self.assertEquals(self.cb,('a',1000,10000)) + self.assertEqual(self.cb,('a',1000,10000)) a.on_trait_change(callback3, 'a', remove=True) - self.assertEquals(len(a._trait_notifiers['a']),0) + self.assertEqual(len(a._trait_notifiers['a']),0) class TestHasTraits(TestCase): @@ -370,22 +370,22 @@ class TestHasTraits(TestCase): i = Int f = Float a = A() - self.assertEquals(sorted(a.trait_names()),['f','i']) - self.assertEquals(sorted(A.class_trait_names()),['f','i']) + self.assertEqual(sorted(a.trait_names()),['f','i']) + self.assertEqual(sorted(A.class_trait_names()),['f','i']) def test_trait_metadata(self): class A(HasTraits): i = Int(config_key='MY_VALUE') a = A() - self.assertEquals(a.trait_metadata('i','config_key'), 'MY_VALUE') + self.assertEqual(a.trait_metadata('i','config_key'), 'MY_VALUE') def test_traits(self): class A(HasTraits): i = Int f = Float a = A() - self.assertEquals(a.traits(), dict(i=A.i, f=A.f)) - self.assertEquals(A.class_traits(), dict(i=A.i, f=A.f)) + self.assertEqual(a.traits(), dict(i=A.i, f=A.f)) + self.assertEqual(A.class_traits(), dict(i=A.i, f=A.f)) def test_traits_metadata(self): class A(HasTraits): @@ -393,22 +393,22 @@ class TestHasTraits(TestCase): f = Float(config_key='VALUE3', other_thing='VALUE2') j = Int(0) a = A() - self.assertEquals(a.traits(), dict(i=A.i, f=A.f, j=A.j)) + self.assertEqual(a.traits(), dict(i=A.i, f=A.f, j=A.j)) traits = a.traits(config_key='VALUE1', other_thing='VALUE2') - self.assertEquals(traits, dict(i=A.i)) + self.assertEqual(traits, dict(i=A.i)) # This passes, but it shouldn't because I am replicating a bug in # traits. traits = a.traits(config_key=lambda v: True) - self.assertEquals(traits, dict(i=A.i, f=A.f, j=A.j)) + self.assertEqual(traits, dict(i=A.i, f=A.f, j=A.j)) def test_init(self): class A(HasTraits): i = Int() x = Float() a = A(i=1, x=10.0) - self.assertEquals(a.i, 1) - self.assertEquals(a.x, 10.0) + self.assertEqual(a.i, 1) + self.assertEqual(a.x, 10.0) #----------------------------------------------------------------------------- # Tests for specific trait types @@ -424,10 +424,10 @@ class TestType(TestCase): klass = Type a = A() - self.assertEquals(a.klass, None) + self.assertEqual(a.klass, None) a.klass = B - self.assertEquals(a.klass, B) + self.assertEqual(a.klass, B) self.assertRaises(TraitError, setattr, a, 'klass', 10) def test_value(self): @@ -438,7 +438,7 @@ class TestType(TestCase): klass = Type(B) a = A() - self.assertEquals(a.klass, B) + self.assertEqual(a.klass, B) self.assertRaises(TraitError, setattr, a, 'klass', C) self.assertRaises(TraitError, setattr, a, 'klass', object) a.klass = B @@ -451,10 +451,10 @@ class TestType(TestCase): klass = Type(B, allow_none=False) a = A() - self.assertEquals(a.klass, B) + self.assertEqual(a.klass, B) self.assertRaises(TraitError, setattr, a, 'klass', None) a.klass = C - self.assertEquals(a.klass, C) + self.assertEqual(a.klass, C) def test_validate_klass(self): @@ -489,7 +489,7 @@ class TestType(TestCase): from IPython.utils.ipstruct import Struct a = A() a.klass = Struct - self.assertEquals(a.klass, Struct) + self.assertEqual(a.klass, Struct) self.assertRaises(TraitError, setattr, a, 'klass', 10) @@ -533,13 +533,13 @@ class TestInstance(TestCase): class A(HasTraits): inst = Instance(Foo, (10,)) a = A() - self.assertEquals(a.inst.c, 10) + self.assertEqual(a.inst.c, 10) class B(HasTraits): inst = Instance(Bah, args=(10,), kw=dict(d=20)) b = B() - self.assertEquals(b.inst.c, 10) - self.assertEquals(b.inst.d, 20) + self.assertEqual(b.inst.c, 10) + self.assertEqual(b.inst.d, 20) class C(HasTraits): inst = Instance(Foo) @@ -571,10 +571,10 @@ class TestThis(TestCase): this = This f = Foo() - self.assertEquals(f.this, None) + self.assertEqual(f.this, None) g = Foo() f.this = g - self.assertEquals(f.this, g) + self.assertEqual(f.this, g) self.assertRaises(TraitError, setattr, f, 'this', 10) def test_this_inst(self): @@ -594,8 +594,8 @@ class TestThis(TestCase): b = Bar() f.t = b b.t = f - self.assertEquals(f.t, b) - self.assertEquals(b.t, f) + self.assertEqual(f.t, b) + self.assertEqual(b.t, f) def test_subclass_override(self): class Foo(HasTraits): @@ -605,7 +605,7 @@ class TestThis(TestCase): f = Foo() b = Bar() f.t = b - self.assertEquals(f.t, b) + self.assertEqual(f.t, b) self.assertRaises(TraitError, setattr, b, 't', f) class TraitTestBase(TestCase): @@ -621,7 +621,7 @@ class TraitTestBase(TestCase): if hasattr(self, '_good_values'): for value in self._good_values: self.assign(value) - self.assertEquals(self.obj.value, self.coerce(value)) + self.assertEqual(self.obj.value, self.coerce(value)) def test_bad_values(self): if hasattr(self, '_bad_values'): @@ -633,7 +633,7 @@ class TraitTestBase(TestCase): def test_default_value(self): if hasattr(self, '_default_value'): - self.assertEquals(self._default_value, self.obj.value) + self.assertEqual(self._default_value, self.obj.value) def tearDown(self): # restore default value after tests, if set @@ -692,7 +692,7 @@ class TestLong(TraitTestBase): def test_cast_small(self): """Long casts ints to long""" self.obj.value = 10 - self.assertEquals(type(self.obj.value), long) + self.assertEqual(type(self.obj.value), long) class IntegerTrait(HasTraits): @@ -712,7 +712,7 @@ class TestInteger(TestLong): raise SkipTest("not relevant on py3") self.obj.value = 100L - self.assertEquals(type(self.obj.value), int) + self.assertEqual(type(self.obj.value), int) class FloatTrait(HasTraits): diff --git a/IPython/zmq/tests/test_session.py b/IPython/zmq/tests/test_session.py index 33c6bf5..5a440e6 100644 --- a/IPython/zmq/tests/test_session.py +++ b/IPython/zmq/tests/test_session.py @@ -49,28 +49,28 @@ class TestSession(SessionTestCase): msg = self.session.msg('execute') thekeys = set('header parent_header content msg_type msg_id'.split()) s = set(msg.keys()) - self.assertEquals(s, thekeys) + self.assertEqual(s, thekeys) self.assertTrue(isinstance(msg['content'],dict)) self.assertTrue(isinstance(msg['header'],dict)) self.assertTrue(isinstance(msg['parent_header'],dict)) self.assertTrue(isinstance(msg['msg_id'],str)) self.assertTrue(isinstance(msg['msg_type'],str)) - self.assertEquals(msg['header']['msg_type'], 'execute') - self.assertEquals(msg['msg_type'], 'execute') + self.assertEqual(msg['header']['msg_type'], 'execute') + self.assertEqual(msg['msg_type'], 'execute') def test_serialize(self): msg = self.session.msg('execute', content=dict(a=10, b=1.1)) msg_list = self.session.serialize(msg, ident=b'foo') ident, msg_list = self.session.feed_identities(msg_list) new_msg = self.session.unserialize(msg_list) - self.assertEquals(ident[0], b'foo') - self.assertEquals(new_msg['msg_id'],msg['msg_id']) - self.assertEquals(new_msg['msg_type'],msg['msg_type']) - self.assertEquals(new_msg['header'],msg['header']) - self.assertEquals(new_msg['content'],msg['content']) - self.assertEquals(new_msg['parent_header'],msg['parent_header']) + self.assertEqual(ident[0], b'foo') + self.assertEqual(new_msg['msg_id'],msg['msg_id']) + self.assertEqual(new_msg['msg_type'],msg['msg_type']) + self.assertEqual(new_msg['header'],msg['header']) + self.assertEqual(new_msg['content'],msg['content']) + self.assertEqual(new_msg['parent_header'],msg['parent_header']) # ensure floats don't come out as Decimal: - self.assertEquals(type(new_msg['content']['b']),type(new_msg['content']['b'])) + self.assertEqual(type(new_msg['content']['b']),type(new_msg['content']['b'])) def test_send(self): socket = MockSocket(zmq.Context.instance(),zmq.PAIR) @@ -79,13 +79,13 @@ class TestSession(SessionTestCase): self.session.send(socket, msg, ident=b'foo', buffers=[b'bar']) ident, msg_list = self.session.feed_identities(socket.data) new_msg = self.session.unserialize(msg_list) - self.assertEquals(ident[0], b'foo') - self.assertEquals(new_msg['msg_id'],msg['msg_id']) - self.assertEquals(new_msg['msg_type'],msg['msg_type']) - self.assertEquals(new_msg['header'],msg['header']) - self.assertEquals(new_msg['content'],msg['content']) - self.assertEquals(new_msg['parent_header'],msg['parent_header']) - self.assertEquals(new_msg['buffers'],[b'bar']) + self.assertEqual(ident[0], b'foo') + self.assertEqual(new_msg['msg_id'],msg['msg_id']) + self.assertEqual(new_msg['msg_type'],msg['msg_type']) + self.assertEqual(new_msg['header'],msg['header']) + self.assertEqual(new_msg['content'],msg['content']) + self.assertEqual(new_msg['parent_header'],msg['parent_header']) + self.assertEqual(new_msg['buffers'],[b'bar']) socket.data = [] @@ -97,25 +97,25 @@ class TestSession(SessionTestCase): header=header, ident=b'foo', buffers=[b'bar']) ident, msg_list = self.session.feed_identities(socket.data) new_msg = self.session.unserialize(msg_list) - self.assertEquals(ident[0], b'foo') - self.assertEquals(new_msg['msg_id'],msg['msg_id']) - self.assertEquals(new_msg['msg_type'],msg['msg_type']) - self.assertEquals(new_msg['header'],msg['header']) - self.assertEquals(new_msg['content'],msg['content']) - self.assertEquals(new_msg['parent_header'],msg['parent_header']) - self.assertEquals(new_msg['buffers'],[b'bar']) + self.assertEqual(ident[0], b'foo') + self.assertEqual(new_msg['msg_id'],msg['msg_id']) + self.assertEqual(new_msg['msg_type'],msg['msg_type']) + self.assertEqual(new_msg['header'],msg['header']) + self.assertEqual(new_msg['content'],msg['content']) + self.assertEqual(new_msg['parent_header'],msg['parent_header']) + self.assertEqual(new_msg['buffers'],[b'bar']) socket.data = [] self.session.send(socket, msg, ident=b'foo', buffers=[b'bar']) ident, new_msg = self.session.recv(socket) - self.assertEquals(ident[0], b'foo') - self.assertEquals(new_msg['msg_id'],msg['msg_id']) - self.assertEquals(new_msg['msg_type'],msg['msg_type']) - self.assertEquals(new_msg['header'],msg['header']) - self.assertEquals(new_msg['content'],msg['content']) - self.assertEquals(new_msg['parent_header'],msg['parent_header']) - self.assertEquals(new_msg['buffers'],[b'bar']) + self.assertEqual(ident[0], b'foo') + self.assertEqual(new_msg['msg_id'],msg['msg_id']) + self.assertEqual(new_msg['msg_type'],msg['msg_type']) + self.assertEqual(new_msg['header'],msg['header']) + self.assertEqual(new_msg['content'],msg['content']) + self.assertEqual(new_msg['parent_header'],msg['parent_header']) + self.assertEqual(new_msg['buffers'],[b'bar']) socket.close() @@ -124,17 +124,17 @@ class TestSession(SessionTestCase): s = self.session self.assertTrue(s.pack is ss.default_packer) self.assertTrue(s.unpack is ss.default_unpacker) - self.assertEquals(s.username, os.environ.get('USER', u'username')) + self.assertEqual(s.username, os.environ.get('USER', u'username')) s = ss.Session() - self.assertEquals(s.username, os.environ.get('USER', u'username')) + self.assertEqual(s.username, os.environ.get('USER', u'username')) self.assertRaises(TypeError, ss.Session, pack='hi') self.assertRaises(TypeError, ss.Session, unpack='hi') u = str(uuid.uuid4()) s = ss.Session(username=u'carrot', session=u) - self.assertEquals(s.session, u) - self.assertEquals(s.username, u'carrot') + self.assertEqual(s.session, u) + self.assertEqual(s.username, u'carrot') def test_tracking(self): """test tracking messages""" @@ -162,12 +162,12 @@ class TestSession(SessionTestCase): # d = {'0': uuid.uuid4(), 1:uuid.uuid4(), 'asdf':uuid.uuid4()} # d2 = {0:d['0'],1:d[1],'asdf':d['asdf']} # rd = ss.rekey(d) - # self.assertEquals(d2,rd) + # self.assertEqual(d2,rd) # # d = {'1.5':uuid.uuid4(),'1':uuid.uuid4()} # d2 = {1.5:d['1.5'],1:d['1']} # rd = ss.rekey(d) - # self.assertEquals(d2,rd) + # self.assertEqual(d2,rd) # # d = {'1.0':uuid.uuid4(),'1':uuid.uuid4()} # self.assertRaises(KeyError, ss.rekey, d) @@ -193,20 +193,20 @@ class TestSession(SessionTestCase): # get bs before us bs = session.bsession us = session.session - self.assertEquals(us.encode('ascii'), bs) + self.assertEqual(us.encode('ascii'), bs) session = ss.Session() # get us before bs us = session.session bs = session.bsession - self.assertEquals(us.encode('ascii'), bs) + self.assertEqual(us.encode('ascii'), bs) # change propagates: session.session = 'something else' bs = session.bsession us = session.session - self.assertEquals(us.encode('ascii'), bs) + self.assertEqual(us.encode('ascii'), bs) session = ss.Session(session='stuff') # get us before bs - self.assertEquals(session.bsession, session.session.encode('ascii')) - self.assertEquals(b'stuff', session.bsession) + self.assertEqual(session.bsession, session.session.encode('ascii')) + self.assertEqual(b'stuff', session.bsession)