tests: Use TestCase.assertEqual()

assertEquals() is deperecated in unittest
pull/920/head
Alex Willmer 3 years ago
parent c4f1cc150d
commit caa20be43e

@ -28,136 +28,136 @@ class FixedPolicyTest(testlib.TestCase):
# Uniprocessor .
policy = self.klass(cpu_count=1)
policy.assign_controller()
self.assertEquals(0x1, policy.mask)
self.assertEqual(0x1, policy.mask)
def test_assign_controller_2core(self):
# Small SMP gets 1.. % cpu_count
policy = self.klass(cpu_count=2)
policy.assign_controller()
self.assertEquals(0x2, policy.mask)
self.assertEqual(0x2, policy.mask)
policy.assign_controller()
self.assertEquals(0x2, policy.mask)
self.assertEqual(0x2, policy.mask)
policy.assign_controller()
def test_assign_controller_3core(self):
# Small SMP gets 1.. % cpu_count
policy = self.klass(cpu_count=3)
policy.assign_controller()
self.assertEquals(0x2, policy.mask)
self.assertEqual(0x2, policy.mask)
policy.assign_controller()
self.assertEquals(0x4, policy.mask)
self.assertEqual(0x4, policy.mask)
policy.assign_controller()
self.assertEquals(0x2, policy.mask)
self.assertEqual(0x2, policy.mask)
policy.assign_controller()
self.assertEquals(0x4, policy.mask)
self.assertEqual(0x4, policy.mask)
policy.assign_controller()
def test_assign_controller_4core(self):
# Big SMP gets a dedicated core.
policy = self.klass(cpu_count=4)
policy.assign_controller()
self.assertEquals(0x2, policy.mask)
self.assertEqual(0x2, policy.mask)
policy.assign_controller()
self.assertEquals(0x2, policy.mask)
self.assertEqual(0x2, policy.mask)
def test_assign_muxprocess_1core(self):
# Uniprocessor .
policy = self.klass(cpu_count=1)
policy.assign_muxprocess(0)
self.assertEquals(0x1, policy.mask)
self.assertEqual(0x1, policy.mask)
def test_assign_muxprocess_2core(self):
# Small SMP gets dedicated core.
policy = self.klass(cpu_count=2)
policy.assign_muxprocess(0)
self.assertEquals(0x1, policy.mask)
self.assertEqual(0x1, policy.mask)
policy.assign_muxprocess(0)
self.assertEquals(0x1, policy.mask)
self.assertEqual(0x1, policy.mask)
policy.assign_muxprocess(0)
def test_assign_muxprocess_3core(self):
# Small SMP gets a dedicated core.
policy = self.klass(cpu_count=3)
policy.assign_muxprocess(0)
self.assertEquals(0x1, policy.mask)
self.assertEqual(0x1, policy.mask)
policy.assign_muxprocess(0)
self.assertEquals(0x1, policy.mask)
self.assertEqual(0x1, policy.mask)
def test_assign_muxprocess_4core(self):
# Big SMP gets a dedicated core.
policy = self.klass(cpu_count=4)
policy.assign_muxprocess(0)
self.assertEquals(0x1, policy.mask)
self.assertEqual(0x1, policy.mask)
policy.assign_muxprocess(0)
self.assertEquals(0x1, policy.mask)
self.assertEqual(0x1, policy.mask)
def test_assign_worker_1core(self):
# Balance n % 1
policy = self.klass(cpu_count=1)
policy.assign_worker()
self.assertEquals(0x1, policy.mask)
self.assertEqual(0x1, policy.mask)
policy.assign_worker()
self.assertEquals(0x1, policy.mask)
self.assertEqual(0x1, policy.mask)
def test_assign_worker_2core(self):
# Balance n % 1
policy = self.klass(cpu_count=2)
policy.assign_worker()
self.assertEquals(0x2, policy.mask)
self.assertEqual(0x2, policy.mask)
policy.assign_worker()
self.assertEquals(0x2, policy.mask)
self.assertEqual(0x2, policy.mask)
def test_assign_worker_3core(self):
# Balance n % 1
policy = self.klass(cpu_count=3)
policy.assign_worker()
self.assertEquals(0x2, policy.mask)
self.assertEqual(0x2, policy.mask)
policy.assign_worker()
self.assertEquals(0x4, policy.mask)
self.assertEqual(0x4, policy.mask)
policy.assign_worker()
self.assertEquals(0x2, policy.mask)
self.assertEqual(0x2, policy.mask)
def test_assign_worker_4core(self):
# Balance n % 1
policy = self.klass(cpu_count=4)
policy.assign_worker()
self.assertEquals(4, policy.mask)
self.assertEqual(4, policy.mask)
policy.assign_worker()
self.assertEquals(8, policy.mask)
self.assertEqual(8, policy.mask)
policy.assign_worker()
self.assertEquals(4, policy.mask)
self.assertEqual(4, policy.mask)
def test_assign_subprocess_1core(self):
# allow all except reserved.
policy = self.klass(cpu_count=1)
policy.assign_subprocess()
self.assertEquals(0x1, policy.mask)
self.assertEqual(0x1, policy.mask)
policy.assign_subprocess()
self.assertEquals(0x1, policy.mask)
self.assertEqual(0x1, policy.mask)
def test_assign_subprocess_2core(self):
# allow all except reserved.
policy = self.klass(cpu_count=2)
policy.assign_subprocess()
self.assertEquals(0x2, policy.mask)
self.assertEqual(0x2, policy.mask)
policy.assign_subprocess()
self.assertEquals(0x2, policy.mask)
self.assertEqual(0x2, policy.mask)
def test_assign_subprocess_3core(self):
# allow all except reserved.
policy = self.klass(cpu_count=3)
policy.assign_subprocess()
self.assertEquals(0x2 + 0x4, policy.mask)
self.assertEqual(0x2 + 0x4, policy.mask)
policy.assign_subprocess()
self.assertEquals(0x2 + 0x4, policy.mask)
self.assertEqual(0x2 + 0x4, policy.mask)
def test_assign_subprocess_4core(self):
# allow all except reserved.
policy = self.klass(cpu_count=4)
policy.assign_subprocess()
self.assertEquals(0x4 + 0x8, policy.mask)
self.assertEqual(0x4 + 0x8, policy.mask)
policy.assign_subprocess()
self.assertEquals(0x4 + 0x8, policy.mask)
self.assertEqual(0x4 + 0x8, policy.mask)
@unittest.skipIf(
@ -185,13 +185,13 @@ class LinuxPolicyTest(testlib.TestCase):
def test_set_cpu_mask(self):
self.policy._set_cpu_mask(0x1)
self.assertEquals(0x1, self._get_cpus())
self.assertEqual(0x1, self._get_cpus())
self.policy._set_cpu_mask(0x2)
self.assertEquals(0x2, self._get_cpus())
self.assertEqual(0x2, self._get_cpus())
self.policy._set_cpu_mask(0x3)
self.assertEquals(0x3, self._get_cpus())
self.assertEqual(0x3, self._get_cpus())
def test_clear_on_popen(self):
tf = tempfile.NamedTemporaryFile()

@ -91,20 +91,20 @@ class OptionalIntTest(testlib.TestCase):
func = staticmethod(ansible_mitogen.connection.optional_int)
def test_already_int(self):
self.assertEquals(0, self.func(0))
self.assertEquals(1, self.func(1))
self.assertEquals(-1, self.func(-1))
self.assertEqual(0, self.func(0))
self.assertEqual(1, self.func(1))
self.assertEqual(-1, self.func(-1))
def test_is_string(self):
self.assertEquals(0, self.func("0"))
self.assertEquals(1, self.func("1"))
self.assertEquals(-1, self.func("-1"))
self.assertEqual(0, self.func("0"))
self.assertEqual(1, self.func("1"))
self.assertEqual(-1, self.func("-1"))
def test_is_none(self):
self.assertEquals(None, self.func(None))
self.assertEqual(None, self.func(None))
def test_is_junk(self):
self.assertEquals(None, self.func({1:2}))
self.assertEqual(None, self.func({1:2}))
class FetchFileTest(ConnectionMixin, testlib.TestCase):
@ -119,7 +119,7 @@ class FetchFileTest(ConnectionMixin, testlib.TestCase):
# transfer_file() uses os.rename rather than direct data
# overwrite, so we must reopen.
with open(ofp.name, 'rb') as fp:
self.assertEquals(ifp.read(), fp.read())
self.assertEqual(ifp.read(), fp.read())
class PutDataTest(ConnectionMixin, testlib.TestCase):
@ -129,7 +129,7 @@ class PutDataTest(ConnectionMixin, testlib.TestCase):
self.conn.put_data(path, contents)
self.wait_for_completion()
self.assertEquals(contents, open(path, 'rb').read())
self.assertEqual(contents, open(path, 'rb').read())
os.unlink(path)
def test_mode(self):
@ -139,7 +139,7 @@ class PutDataTest(ConnectionMixin, testlib.TestCase):
self.conn.put_data(path, contents, mode=int('0123', 8))
self.wait_for_completion()
st = os.stat(path)
self.assertEquals(int('0123', 8), st.st_mode & int('0777', 8))
self.assertEqual(int('0123', 8), st.st_mode & int('0777', 8))
os.unlink(path)
@ -163,7 +163,7 @@ class PutFileTest(ConnectionMixin, testlib.TestCase):
path = tempfile.mktemp(prefix='mitotest')
self.conn.put_file(in_path=__file__, out_path=path)
self.wait_for_completion()
self.assertEquals(open(path, 'rb').read(),
self.assertEqual(open(path, 'rb').read(),
open(__file__, 'rb').read())
os.unlink(path)
@ -172,7 +172,7 @@ class PutFileTest(ConnectionMixin, testlib.TestCase):
path = tempfile.mktemp(prefix='mitotest')
self.conn.put_file(in_path=self.big_path, out_path=path)
self.wait_for_completion()
self.assertEquals(open(path, 'rb').read(),
self.assertEqual(open(path, 'rb').read(),
open(self.big_path, 'rb').read())
#self._compare_times_modes(path, __file__)
os.unlink(path)

@ -61,10 +61,10 @@ class ApplyModeSpecTest(unittest.TestCase):
def test_simple(self):
spec = 'u+rwx,go=x'
self.assertEquals(int('0711', 8), self.func(spec, 0))
self.assertEqual(int('0711', 8), self.func(spec, 0))
spec = 'g-rw'
self.assertEquals(int('0717', 8), self.func(spec, int('0777', 8)))
self.assertEqual(int('0717', 8), self.func(spec, int('0777', 8)))
class IsGoodTempDirTest(unittest.TestCase):
@ -84,7 +84,7 @@ class IsGoodTempDirTest(unittest.TestCase):
fp.write('derp')
self.assertTrue(os.path.isfile(bleh))
self.assertFalse(self.func(bleh))
self.assertEquals(open(bleh).read(), 'derp')
self.assertEqual(open(bleh).read(), 'derp')
@unittest.skipIf(
os.geteuid() == 0, 'writes by root ignore directory permissions')

@ -18,7 +18,7 @@ class ShutdownTest(testlib.TestCase):
broker.poller.close = mock.Mock()
broker.shutdown()
broker.join()
self.assertEquals(1, len(broker.poller.close.mock_calls))
self.assertEqual(1, len(broker.poller.close.mock_calls))
actual_close()
@ -30,7 +30,7 @@ class DeferTest(testlib.TestCase):
broker = self.klass()
try:
broker.defer(lambda: latch.put(123))
self.assertEquals(123, latch.get())
self.assertEqual(123, latch.get())
finally:
broker.shutdown()
broker.join()
@ -43,7 +43,7 @@ class DeferTest(testlib.TestCase):
e = self.assertRaises(mitogen.core.Error,
lambda: broker.defer(lambda: latch.put(123)))
self.assertEquals(e.args[0], mitogen.core.Waker.broker_shutdown_msg)
self.assertEqual(e.args[0], mitogen.core.Waker.broker_shutdown_msg)
class DeferSyncTest(testlib.TestCase):
@ -53,7 +53,7 @@ class DeferSyncTest(testlib.TestCase):
broker = self.klass()
try:
th = broker.defer_sync(lambda: threading.currentThread())
self.assertEquals(th, broker._thread)
self.assertEqual(th, broker._thread)
finally:
broker.shutdown()
broker.join()

@ -15,8 +15,8 @@ class ConstructorTest(testlib.RouterMixin, testlib.TestCase):
stream = self.router.stream_by_id(context.context_id)
argv = eval(context.call(os.getenv, 'ORIGINAL_ARGV'))
self.assertEquals(argv[0], buildah_path)
self.assertEquals(argv[1], 'run')
self.assertEquals(argv[2], '--')
self.assertEquals(argv[3], 'container_name')
self.assertEquals(argv[4], stream.conn.options.python_path)
self.assertEqual(argv[0], buildah_path)
self.assertEqual(argv[1], 'run')
self.assertEqual(argv[2], '--')
self.assertEqual(argv[3], 'container_name')
self.assertEqual(argv[4], stream.conn.options.python_path)

@ -12,25 +12,25 @@ class ConstructorTest(testlib.TestCase):
def test_string_noargs(self):
e = self.klass('%s%s')
self.assertEquals(e.args[0], '%s%s')
self.assertEqual(e.args[0], '%s%s')
self.assertTrue(isinstance(e.args[0], mitogen.core.UnicodeType))
def test_string_args(self):
e = self.klass('%s%s', 1, 1)
self.assertEquals(e.args[0], '11')
self.assertEqual(e.args[0], '11')
self.assertTrue(isinstance(e.args[0], mitogen.core.UnicodeType))
def test_from_exc(self):
ve = plain_old_module.MyError('eek')
e = self.klass(ve)
self.assertEquals(e.args[0], 'plain_old_module.MyError: eek')
self.assertEqual(e.args[0], 'plain_old_module.MyError: eek')
self.assertTrue(isinstance(e.args[0], mitogen.core.UnicodeType))
def test_form_base_exc(self):
ve = SystemExit('eek')
e = self.klass(ve)
cls = ve.__class__
self.assertEquals(e.args[0],
self.assertEqual(e.args[0],
# varies across 2/3.
'%s.%s: eek' % (cls.__module__, cls.__name__))
self.assertTrue(isinstance(e.args[0], mitogen.core.UnicodeType))
@ -48,14 +48,14 @@ class ConstructorTest(testlib.TestCase):
def test_bytestring_conversion(self):
e = self.klass(mitogen.core.b('bytes'))
self.assertEquals(u'bytes', e.args[0])
self.assertEqual(u'bytes', e.args[0])
self.assertTrue(isinstance(e.args[0], mitogen.core.UnicodeType))
def test_reduce(self):
e = self.klass('eek')
func, (arg,) = e.__reduce__()
self.assertTrue(func is mitogen.core._unpickle_call_error)
self.assertEquals(arg, e.args[0])
self.assertEqual(arg, e.args[0])
class UnpickleCallErrorTest(testlib.TestCase):
@ -71,10 +71,10 @@ class UnpickleCallErrorTest(testlib.TestCase):
def test_reify(self):
e = self.func(u'some error')
self.assertEquals(mitogen.core.CallError, e.__class__)
self.assertEquals(1, len(e.args))
self.assertEquals(mitogen.core.UnicodeType, type(e.args[0]))
self.assertEquals(u'some error', e.args[0])
self.assertEqual(mitogen.core.CallError, e.__class__)
self.assertEqual(1, len(e.args))
self.assertEqual(mitogen.core.UnicodeType, type(e.args[0]))
self.assertEqual(u'some error', e.args[0])
class PickleTest(testlib.TestCase):
@ -83,18 +83,18 @@ class PickleTest(testlib.TestCase):
def test_string_noargs(self):
e = self.klass('%s%s')
e2 = pickle.loads(pickle.dumps(e))
self.assertEquals(e2.args[0], '%s%s')
self.assertEqual(e2.args[0], '%s%s')
def test_string_args(self):
e = self.klass('%s%s', 1, 1)
e2 = pickle.loads(pickle.dumps(e))
self.assertEquals(e2.args[0], '11')
self.assertEqual(e2.args[0], '11')
def test_from_exc(self):
ve = plain_old_module.MyError('eek')
e = self.klass(ve)
e2 = pickle.loads(pickle.dumps(e))
self.assertEquals(e2.args[0], 'plain_old_module.MyError: eek')
self.assertEqual(e2.args[0], 'plain_old_module.MyError: eek')
def test_from_exc_tb(self):
try:

@ -77,7 +77,7 @@ class CallFunctionTest(testlib.RouterMixin, testlib.TestCase):
def test_bad_return_value(self):
exc = self.assertRaises(mitogen.core.StreamError,
lambda: self.local.call(func_with_bad_return_value))
self.assertEquals(
self.assertEqual(
exc.args[0],
"cannot unpickle '%s'/'CrazyType'" % (__name__,),
)
@ -89,7 +89,7 @@ class CallFunctionTest(testlib.RouterMixin, testlib.TestCase):
self.broker.defer(stream.on_disconnect, self.broker)
exc = self.assertRaises(mitogen.core.ChannelError,
lambda: recv.get())
self.assertEquals(exc.args[0], self.router.respondent_disconnect_msg)
self.assertEqual(exc.args[0], self.router.respondent_disconnect_msg)
def test_aborted_on_local_broker_shutdown(self):
stream = self.router._stream_by_id[self.local.context_id]
@ -99,7 +99,7 @@ class CallFunctionTest(testlib.RouterMixin, testlib.TestCase):
self.broker_shutdown = True
exc = self.assertRaises(mitogen.core.ChannelError,
lambda: recv.get())
self.assertEquals(exc.args[0], self.router.respondent_disconnect_msg)
self.assertEqual(exc.args[0], self.router.respondent_disconnect_msg)
def test_accepts_returns_context(self):
context = self.local.call(func_returns_arg, self.local)
@ -112,10 +112,10 @@ class CallFunctionTest(testlib.RouterMixin, testlib.TestCase):
recv = mitogen.core.Receiver(self.router)
sender = recv.to_sender()
sender2 = self.local.call(func_accepts_returns_sender, sender)
self.assertEquals(sender.context.context_id,
self.assertEqual(sender.context.context_id,
sender2.context.context_id)
self.assertEquals(sender.dst_handle, sender2.dst_handle)
self.assertEquals(123, recv.get().unpickle())
self.assertEqual(sender.dst_handle, sender2.dst_handle)
self.assertEqual(123, recv.get().unpickle())
self.assertRaises(mitogen.core.ChannelError,
lambda: recv.get().unpickle())
@ -130,19 +130,19 @@ class CallChainTest(testlib.RouterMixin, testlib.TestCase):
def test_subsequent_calls_produce_same_error(self):
chain = self.klass(self.local, pipelined=True)
self.assertEquals('xx', chain.call(func_returns_arg, 'xx'))
self.assertEqual('xx', chain.call(func_returns_arg, 'xx'))
chain.call_no_reply(function_that_fails, 'x1')
e1 = self.assertRaises(mitogen.core.CallError,
lambda: chain.call(function_that_fails, 'x2'))
e2 = self.assertRaises(mitogen.core.CallError,
lambda: chain.call(func_returns_arg, 'x3'))
self.assertEquals(str(e1), str(e2))
self.assertEqual(str(e1), str(e2))
def test_unrelated_overlapping_failed_chains(self):
c1 = self.klass(self.local, pipelined=True)
c2 = self.klass(self.local, pipelined=True)
c1.call_no_reply(function_that_fails, 'c1')
self.assertEquals('yes', c2.call(func_returns_arg, 'yes'))
self.assertEqual('yes', c2.call(func_returns_arg, 'yes'))
self.assertRaises(mitogen.core.CallError,
lambda: c1.call(func_returns_arg, 'yes'))
@ -152,7 +152,7 @@ class CallChainTest(testlib.RouterMixin, testlib.TestCase):
e1 = self.assertRaises(mitogen.core.CallError,
lambda: c1.call(function_that_fails, 'x2'))
c1.reset()
self.assertEquals('x3', c1.call(func_returns_arg, 'x3'))
self.assertEqual('x3', c1.call(func_returns_arg, 'x3'))
class UnsupportedCallablesTest(testlib.RouterMixin, testlib.TestCase):
@ -168,17 +168,17 @@ class UnsupportedCallablesTest(testlib.RouterMixin, testlib.TestCase):
closure = lambda: a
e = self.assertRaises(TypeError,
lambda: self.local.call(closure))
self.assertEquals(e.args[0], self.klass.closures_msg)
self.assertEqual(e.args[0], self.klass.closures_msg)
def test_lambda_unsupported(self):
lam = lambda: None
e = self.assertRaises(TypeError,
lambda: self.local.call(lam))
self.assertEquals(e.args[0], self.klass.lambda_msg)
self.assertEqual(e.args[0], self.klass.lambda_msg)
def test_instance_method_unsupported(self):
class X:
def x(): pass
e = self.assertRaises(TypeError,
lambda: self.local.call(X().x))
self.assertEquals(e.args[0], self.klass.method_msg)
self.assertEqual(e.args[0], self.klass.method_msg)

@ -41,7 +41,7 @@ class ConnectionTest(testlib.RouterMixin, testlib.TestCase):
exc, = result
self.assertTrue(isinstance(exc, mitogen.parent.CancelledError))
self.assertEquals(mitogen.parent.BROKER_SHUTDOWN_MSG, exc.args[0])
self.assertEqual(mitogen.parent.BROKER_SHUTDOWN_MSG, exc.args[0])
@mitogen.core.takes_econtext

@ -20,13 +20,13 @@ class PickleTest(testlib.RouterMixin, testlib.TestCase):
r = mitogen.core.Receiver(self.router)
r.to_sender().send(c)
c2 = r.get().unpickle()
self.assertEquals(None, c2.router)
self.assertEquals(c.context_id, c2.context_id)
self.assertEquals(c.name, c2.name)
self.assertEqual(None, c2.router)
self.assertEqual(c.context_id, c2.context_id)
self.assertEqual(c.name, c2.name)
def test_vanilla_roundtrip(self):
c = self.router.local()
c2 = pickle.loads(pickle.dumps(c))
self.assertEquals(None, c2.router)
self.assertEquals(c.context_id, c2.context_id)
self.assertEquals(c.name, c2.name)
self.assertEqual(None, c2.router)
self.assertEqual(c.context_id, c2.context_id)
self.assertEqual(c.name, c2.name)

@ -97,8 +97,8 @@ class StdinSockMixin(object):
lambda proc: proc.stdin.send(b('TEST')))
st = os.fstat(proc.stdin.fileno())
self.assertTrue(stat.S_ISSOCK(st.st_mode))
self.assertEquals(st.st_dev, info['st_dev'])
self.assertEquals(st.st_mode, _osx_mode(info['st_mode']))
self.assertEqual(st.st_dev, info['st_dev'])
self.assertEqual(st.st_mode, _osx_mode(info['st_mode']))
flags = fcntl.fcntl(proc.stdin.fileno(), fcntl.F_GETFL)
self.assertTrue(flags & os.O_RDWR)
self.assertTrue(info['buf'], 'TEST')
@ -111,8 +111,8 @@ class StdoutSockMixin(object):
lambda proc: wait_read(proc.stdout, 4))
st = os.fstat(proc.stdout.fileno())
self.assertTrue(stat.S_ISSOCK(st.st_mode))
self.assertEquals(st.st_dev, info['st_dev'])
self.assertEquals(st.st_mode, _osx_mode(info['st_mode']))
self.assertEqual(st.st_dev, info['st_dev'])
self.assertEqual(st.st_mode, _osx_mode(info['st_mode']))
flags = fcntl.fcntl(proc.stdout.fileno(), fcntl.F_GETFL)
self.assertTrue(flags & os.O_RDWR)
self.assertTrue(buf, 'TEST')
@ -125,9 +125,9 @@ class CreateChildTest(StdinSockMixin, StdoutSockMixin, testlib.TestCase):
def test_stderr(self):
proc, info, _ = run_fd_check(self.func, 2, 'write')
st = os.fstat(sys.stderr.fileno())
self.assertEquals(st.st_dev, info['st_dev'])
self.assertEquals(st.st_mode, info['st_mode'])
self.assertEquals(st.st_ino, info['st_ino'])
self.assertEqual(st.st_dev, info['st_dev'])
self.assertEqual(st.st_mode, info['st_mode'])
self.assertEqual(st.st_ino, info['st_ino'])
class CreateChildMergedTest(StdinSockMixin, StdoutSockMixin,
@ -139,7 +139,7 @@ class CreateChildMergedTest(StdinSockMixin, StdoutSockMixin,
def test_stderr(self):
proc, info, buf = run_fd_check(self.func, 2, 'write',
lambda proc: wait_read(proc.stdout, 4))
self.assertEquals(None, proc.stderr)
self.assertEqual(None, proc.stderr)
st = os.fstat(proc.stdout.fileno())
self.assertTrue(stat.S_ISSOCK(st.st_mode))
flags = fcntl.fcntl(proc.stdout.fileno(), fcntl.F_GETFL)
@ -159,8 +159,8 @@ class CreateChildStderrPipeTest(StdinSockMixin, StdoutSockMixin,
lambda proc: wait_read(proc.stderr, 4))
st = os.fstat(proc.stderr.fileno())
self.assertTrue(stat.S_ISFIFO(st.st_mode))
self.assertEquals(st.st_dev, info['st_dev'])
self.assertEquals(st.st_mode, info['st_mode'])
self.assertEqual(st.st_dev, info['st_dev'])
self.assertEqual(st.st_mode, info['st_mode'])
flags = fcntl.fcntl(proc.stderr.fileno(), fcntl.F_GETFL)
self.assertFalse(flags & os.O_WRONLY)
self.assertFalse(flags & os.O_RDWR)
@ -188,11 +188,11 @@ class TtyCreateChildTest(testlib.TestCase):
])
mitogen.core.set_block(proc.stdin.fileno())
# read(3) below due to https://bugs.python.org/issue37696
self.assertEquals(mitogen.core.b('hi\n'), proc.stdin.read(3))
self.assertEqual(mitogen.core.b('hi\n'), proc.stdin.read(3))
waited_pid, status = os.waitpid(proc.pid, 0)
self.assertEquals(proc.pid, waited_pid)
self.assertEquals(0, status)
self.assertEquals(mitogen.core.b(''), tf.read())
self.assertEqual(proc.pid, waited_pid)
self.assertEqual(0, status)
self.assertEqual(mitogen.core.b(''), tf.read())
proc.stdout.close()
finally:
tf.close()
@ -268,11 +268,11 @@ class TtyCreateChildTest(testlib.TestCase):
proc = self.func([
'bash', '-c', 'exec 2>%s; echo hi > /dev/tty' % (tf.name,)
])
self.assertEquals(mitogen.core.b('hi\n'), wait_read(proc.stdout, 3))
self.assertEqual(mitogen.core.b('hi\n'), wait_read(proc.stdout, 3))
waited_pid, status = os.waitpid(proc.pid, 0)
self.assertEquals(proc.pid, waited_pid)
self.assertEquals(0, status)
self.assertEquals(mitogen.core.b(''), tf.read())
self.assertEqual(proc.pid, waited_pid)
self.assertEqual(0, status)
self.assertEqual(mitogen.core.b(''), tf.read())
proc.stdout.close()
finally:
tf.close()
@ -316,8 +316,8 @@ if 0:
lambda proc: proc.transmit_side.write('TEST'))
st = os.fstat(proc.transmit_side.fd)
self.assertTrue(stat.S_ISFIFO(st.st_mode))
self.assertEquals(st.st_dev, info['st_dev'])
self.assertEquals(st.st_mode, info['st_mode'])
self.assertEqual(st.st_dev, info['st_dev'])
self.assertEqual(st.st_mode, info['st_mode'])
flags = fcntl.fcntl(proc.transmit_side.fd, fcntl.F_GETFL)
self.assertTrue(flags & os.O_WRONLY)
self.assertTrue(buf, 'TEST')
@ -329,8 +329,8 @@ if 0:
lambda proc: wait_read(proc.receive_side, 4))
st = os.fstat(proc.receive_side.fd)
self.assertTrue(stat.S_ISFIFO(st.st_mode))
self.assertEquals(st.st_dev, info['st_dev'])
self.assertEquals(st.st_mode, info['st_mode'])
self.assertEqual(st.st_dev, info['st_dev'])
self.assertEqual(st.st_mode, info['st_mode'])
flags = fcntl.fcntl(proc.receive_side.fd, fcntl.F_GETFL)
self.assertFalse(flags & os.O_WRONLY)
self.assertFalse(flags & os.O_RDWR)

@ -17,13 +17,13 @@ class ConstructorTest(testlib.RouterMixin, testlib.TestCase):
username='someuser',
)
argv = eval(context.call(os.getenv, 'ORIGINAL_ARGV'))
self.assertEquals(argv[:4], [
self.assertEqual(argv[:4], [
self.doas_path,
'-u',
'someuser',
'--',
])
self.assertEquals('1', context.call(os.getenv, 'THIS_IS_STUB_DOAS'))
self.assertEqual('1', context.call(os.getenv, 'THIS_IS_STUB_DOAS'))
# TODO: https://github.com/dw/mitogen/issues/694 they are flaky on python 2.6 MODE=mitogen DISTROS=centos7
@ -57,4 +57,4 @@ class ConstructorTest(testlib.RouterMixin, testlib.TestCase):
# password='has_sudo_password',
# )
# context = self.router.doas(via=ssh, password='has_sudo_password')
# self.assertEquals(0, context.call(os.getuid))
# self.assertEqual(0, context.call(os.getuid))

@ -15,8 +15,8 @@ class ConstructorTest(testlib.RouterMixin, testlib.TestCase):
stream = self.router.stream_by_id(context.context_id)
argv = eval(context.call(os.getenv, 'ORIGINAL_ARGV'))
self.assertEquals(argv[0], docker_path)
self.assertEquals(argv[1], 'exec')
self.assertEquals(argv[2], '--interactive')
self.assertEquals(argv[3], 'container_name')
self.assertEquals(argv[4], stream.conn.options.python_path)
self.assertEqual(argv[0], docker_path)
self.assertEqual(argv[1], 'exec')
self.assertEqual(argv[2], '--interactive')
self.assertEqual(argv[3], 'container_name')
self.assertEqual(argv[4], stream.conn.options.python_path)

@ -7,20 +7,20 @@ class ConstructorTest(testlib.TestCase):
def test_literal_no_format(self):
e = self.klass('error')
self.assertEquals(e.args[0], 'error')
self.assertEqual(e.args[0], 'error')
self.assertTrue(isinstance(e.args[0], mitogen.core.UnicodeType))
def test_literal_format_chars_present(self):
e = self.klass('error%s')
self.assertEquals(e.args[0], 'error%s')
self.assertEqual(e.args[0], 'error%s')
self.assertTrue(isinstance(e.args[0], mitogen.core.UnicodeType))
def test_format(self):
e = self.klass('error%s', 123)
self.assertEquals(e.args[0], 'error123')
self.assertEqual(e.args[0], 'error123')
self.assertTrue(isinstance(e.args[0], mitogen.core.UnicodeType))
def test_bytes_to_unicode(self):
e = self.klass(mitogen.core.b('error'))
self.assertEquals(e.args[0], 'error')
self.assertEqual(e.args[0], 'error')
self.assertTrue(isinstance(e.args[0], mitogen.core.UnicodeType))

@ -50,8 +50,8 @@ class FetchTest(testlib.RouterMixin, testlib.TestCase):
def _validate_response(self, resp):
self.assertTrue(isinstance(resp, dict))
self.assertEquals('root', resp['owner'])
self.assertEquals(self.ROOT_GROUP, resp['group'])
self.assertEqual('root', resp['owner'])
self.assertEqual(self.ROOT_GROUP, resp['group'])
self.assertTrue(isinstance(resp['mode'], int))
self.assertTrue(isinstance(resp['mtime'], float))
self.assertTrue(isinstance(resp['atime'], float))

@ -37,8 +37,8 @@ class CommandLineTest(testlib.RouterMixin, testlib.TestCase):
stderr=subprocess.PIPE,
)
stdout, stderr = proc.communicate()
self.assertEquals(0, proc.returncode)
self.assertEquals(stdout,
self.assertEqual(0, proc.returncode)
self.assertEqual(stdout,
mitogen.parent.BootstrapProtocol.EC0_MARKER+b('\n'))
self.assertIn(b("Error -5 while decompressing data"), stderr)
finally:

@ -115,7 +115,7 @@ class ForkTest(testlib.RouterMixin, testlib.TestCase):
sender = mitogen.core.Sender(econtext.parent, recv.handle)
sender.send(123)
context = self.router.fork(on_start=on_start)
self.assertEquals(123, recv.get().unpickle())
self.assertEqual(123, recv.get().unpickle())
ForkTest = skipIfUnsupported(ForkTest)
@ -134,7 +134,7 @@ class DoubleChildTest(testlib.RouterMixin, testlib.TestCase):
# successfully. In future, we need lots more tests.
c1 = self.router.fork()
c2 = self.router.fork(via=c1)
self.assertEquals(123, c2.call(ping))
self.assertEqual(123, c2.call(ping))
def test_importer(self):
c1 = self.router.fork(name='c1')

@ -14,7 +14,7 @@ class SlaveTest(testlib.RouterMixin, testlib.TestCase):
def test_slave_allocates_id(self):
context = self.router.local()
# Master's allocator named the context 1.
self.assertEquals(1, context.context_id)
self.assertEqual(1, context.context_id)
# First call from slave allocates a block (2..1001)
id_ = context.call(allocate_an_id)
@ -26,4 +26,4 @@ class SlaveTest(testlib.RouterMixin, testlib.TestCase):
# Subsequent master allocation does not collide
c2 = self.router.local()
self.assertEquals(1002, c2.context_id)
self.assertEqual(1002, c2.context_id)

@ -68,7 +68,7 @@ class LoadModuleTest(ImporterMixin, testlib.TestCase):
def test_module_file_set(self):
self.set_get_module_response(self.response)
mod = self.importer.load_module(self.modname)
self.assertEquals(mod.__file__, 'master:' + self.path)
self.assertEqual(mod.__file__, 'master:' + self.path)
def test_module_loader_set(self):
self.set_get_module_response(self.response)
@ -91,7 +91,7 @@ class LoadSubmoduleTest(ImporterMixin, testlib.TestCase):
def test_module_package_unset(self):
self.set_get_module_response(self.response)
mod = self.importer.load_module(self.modname)
self.assertEquals(mod.__package__, 'mypkg')
self.assertEqual(mod.__package__, 'mypkg')
class LoadModulePackageTest(ImporterMixin, testlib.TestCase):
@ -104,19 +104,19 @@ class LoadModulePackageTest(ImporterMixin, testlib.TestCase):
def test_module_file_set(self):
self.set_get_module_response(self.response)
mod = self.importer.load_module(self.modname)
self.assertEquals(mod.__file__, 'master:' + self.path)
self.assertEqual(mod.__file__, 'master:' + self.path)
def test_get_filename(self):
self.set_get_module_response(self.response)
mod = self.importer.load_module(self.modname)
filename = mod.__loader__.get_filename(self.modname)
self.assertEquals('master:fake_pkg/__init__.py', filename)
self.assertEqual('master:fake_pkg/__init__.py', filename)
def test_get_source(self):
self.set_get_module_response(self.response)
mod = self.importer.load_module(self.modname)
source = mod.__loader__.get_source(self.modname)
self.assertEquals(source,
self.assertEqual(source,
mitogen.core.to_text(zlib.decompress(self.data)))
def test_module_loader_set(self):
@ -127,18 +127,18 @@ class LoadModulePackageTest(ImporterMixin, testlib.TestCase):
def test_module_path_present(self):
self.set_get_module_response(self.response)
mod = self.importer.load_module(self.modname)
self.assertEquals(mod.__path__, [])
self.assertEqual(mod.__path__, [])
def test_module_package_set(self):
self.set_get_module_response(self.response)
mod = self.importer.load_module(self.modname)
self.assertEquals(mod.__package__, self.modname)
self.assertEqual(mod.__package__, self.modname)
def test_module_data(self):
self.set_get_module_response(self.response)
mod = self.importer.load_module(self.modname)
self.assertIsInstance(mod.func, types.FunctionType)
self.assertEquals(mod.func.__module__, self.modname)
self.assertEqual(mod.func.__module__, self.modname)
class EmailParseAddrSysTest(testlib.RouterMixin, testlib.TestCase):
@ -218,5 +218,5 @@ class SelfReplacingModuleTest(testlib.RouterMixin, testlib.TestCase):
# issue #590
def test_importer_handles_self_replacement(self):
c = self.router.local()
self.assertEquals(0,
self.assertEqual(0,
c.call(simple_pkg.imports_replaces_self.subtract_one, 1))

@ -30,10 +30,10 @@ class RestartTest(object):
'yay',
]
rc, disconnected = self.func(py24_mock_fix(m), 'input')
self.assertEquals(rc, 'yay')
self.assertEqual(rc, 'yay')
self.assertFalse(disconnected)
self.assertEquals(4, m.call_count)
self.assertEquals(m.mock_calls, [
self.assertEqual(4, m.call_count)
self.assertEqual(m.mock_calls, [
mock.call('input'),
mock.call('input'),
mock.call('input'),
@ -58,10 +58,10 @@ class DisconnectTest(object):
m = mock.Mock()
m.side_effect = self.exception_class(self.errno)
rc, disconnected = self.func(m, 'input')
self.assertEquals(rc, None)
self.assertEqual(rc, None)
self.assertTrue(disconnected)
self.assertEquals(1, m.call_count)
self.assertEquals(m.mock_calls, [
self.assertEqual(1, m.call_count)
self.assertEqual(m.mock_calls, [
mock.call('input'),
])
@ -106,9 +106,9 @@ class ExceptionTest(object):
m.side_effect = self.exception_class(self.errno)
e = self.assertRaises(self.exception_class,
lambda: self.func(m, 'input'))
self.assertEquals(e, m.side_effect)
self.assertEquals(1, m.call_count)
self.assertEquals(m.mock_calls, [
self.assertEqual(e, m.side_effect)
self.assertEqual(1, m.call_count)
self.assertEqual(m.mock_calls, [
mock.call('input'),
])

@ -21,38 +21,38 @@ class IterSplitTest(unittest.TestCase):
lst = []
trailer, cont = self.func(buf='', delim='\n', func=lst.append)
self.assertTrue(cont)
self.assertEquals('', trailer)
self.assertEquals([], lst)
self.assertEqual('', trailer)
self.assertEqual([], lst)
def test_empty_line(self):
lst = []
trailer, cont = self.func(buf='\n', delim='\n', func=lst.append)
self.assertTrue(cont)
self.assertEquals('', trailer)
self.assertEquals([''], lst)
self.assertEqual('', trailer)
self.assertEqual([''], lst)
def test_one_line(self):
buf = 'xxxx\n'
lst = []
trailer, cont = self.func(buf=buf, delim='\n', func=lst.append)
self.assertTrue(cont)
self.assertEquals('', trailer)
self.assertEquals(lst, ['xxxx'])
self.assertEqual('', trailer)
self.assertEqual(lst, ['xxxx'])
def test_one_incomplete(self):
buf = 'xxxx\nyy'
lst = []
trailer, cont = self.func(buf=buf, delim='\n', func=lst.append)
self.assertTrue(cont)
self.assertEquals('yy', trailer)
self.assertEquals(lst, ['xxxx'])
self.assertEqual('yy', trailer)
self.assertEqual(lst, ['xxxx'])
def test_returns_false_immediately(self):
buf = 'xxxx\nyy'
func = lambda buf: False
trailer, cont = self.func(buf=buf, delim='\n', func=func)
self.assertFalse(cont)
self.assertEquals('yy', trailer)
self.assertEqual('yy', trailer)
def test_returns_false_second_call(self):
buf = 'xxxx\nyy\nzz'
@ -60,4 +60,4 @@ class IterSplitTest(unittest.TestCase):
func = lambda buf: next(it)
trailer, cont = self.func(buf=buf, delim='\n', func=func)
self.assertFalse(cont)
self.assertEquals('zz', trailer)
self.assertEqual('zz', trailer)

@ -18,10 +18,10 @@ class ConstructorTest(testlib.RouterMixin, testlib.TestCase):
stream = self.router.stream_by_id(context.context_id)
argv = eval(context.call(os.getenv, 'ORIGINAL_ARGV'))
self.assertEquals(argv[:4], [
self.assertEqual(argv[:4], [
self.jexec_path,
'somejail',
stream.conn.options.python_path,
'-c',
])
self.assertEquals('1', context.call(os.getenv, 'THIS_IS_STUB_JEXEC'))
self.assertEqual('1', context.call(os.getenv, 'THIS_IS_STUB_JEXEC'))

@ -17,7 +17,7 @@ class ConstructorTest(testlib.RouterMixin, testlib.TestCase):
)
argv = eval(context.call(os.getenv, 'ORIGINAL_ARGV'))
self.assertEquals(argv[0], self.kubectl_path)
self.assertEquals(argv[1], 'exec')
self.assertEquals(argv[2], '-it')
self.assertEquals(argv[3], 'pod_name')
self.assertEqual(argv[0], self.kubectl_path)
self.assertEqual(argv[1], 'exec')
self.assertEqual(argv[2], '-it')
self.assertEqual(argv[3], 'pod_name')

@ -45,19 +45,19 @@ class GetTest(testlib.TestCase):
obj = object()
latch = self.klass()
latch.put(obj)
self.assertEquals(obj, latch.get())
self.assertEqual(obj, latch.get())
def test_nonempty_noblock(self):
obj = object()
latch = self.klass()
latch.put(obj)
self.assertEquals(obj, latch.get(block=False))
self.assertEqual(obj, latch.get(block=False))
def test_nonempty_zero_timeout(self):
obj = object()
latch = self.klass()
latch.put(obj)
self.assertEquals(obj, latch.get(timeout=0))
self.assertEqual(obj, latch.get(timeout=0))
class ThreadedGetTest(testlib.TestCase):
@ -91,8 +91,8 @@ class ThreadedGetTest(testlib.TestCase):
self.start_one(lambda: latch.get(timeout=3.0))
latch.put('test')
self.join()
self.assertEquals(self.results, ['test'])
self.assertEquals(self.excs, [])
self.assertEqual(self.results, ['test'])
self.assertEqual(self.excs, [])
def test_five_threads(self):
latch = self.klass()
@ -101,8 +101,8 @@ class ThreadedGetTest(testlib.TestCase):
for x in range(5):
latch.put(x)
self.join()
self.assertEquals(sorted(self.results), list(range(5)))
self.assertEquals(self.excs, [])
self.assertEqual(sorted(self.results), list(range(5)))
self.assertEqual(self.excs, [])
@ -112,7 +112,7 @@ class PutTest(testlib.TestCase):
def test_put(self):
latch = self.klass()
latch.put(None)
self.assertEquals(None, latch.get())
self.assertEqual(None, latch.get())
class CloseTest(testlib.TestCase):
@ -197,7 +197,7 @@ class ThreadedCloseTest(testlib.TestCase):
self.start_one(lambda: latch.get(timeout=3.0))
latch.close()
self.join()
self.assertEquals(self.results, [None])
self.assertEqual(self.results, [None])
for exc in self.excs:
self.assertTrue(isinstance(exc, mitogen.core.LatchError))
@ -207,6 +207,6 @@ class ThreadedCloseTest(testlib.TestCase):
self.start_one(lambda: latch.get(timeout=3.0))
latch.close()
self.join()
self.assertEquals(self.results, [None]*5)
self.assertEqual(self.results, [None]*5)
for exc in self.excs:
self.assertTrue(isinstance(exc, mitogen.core.LatchError))

@ -21,18 +21,18 @@ class ConstructionTest(testlib.RouterMixin, testlib.TestCase):
def test_stream_name(self):
context = self.router.local()
pid = context.call(os.getpid)
self.assertEquals('local.%d' % (pid,), context.name)
self.assertEqual('local.%d' % (pid,), context.name)
def test_python_path_inherited(self):
context = self.router.local()
self.assertEquals(sys.executable, context.call(get_sys_executable))
self.assertEqual(sys.executable, context.call(get_sys_executable))
def test_python_path_string(self):
context = self.router.local(
python_path=self.stub_python_path,
)
env = context.call(get_os_environ)
self.assertEquals('1', env['THIS_IS_STUB_PYTHON'])
self.assertEqual('1', env['THIS_IS_STUB_PYTHON'])
def test_python_path_list(self):
context = self.router.local(
@ -42,7 +42,7 @@ class ConstructionTest(testlib.RouterMixin, testlib.TestCase):
sys.executable
]
)
self.assertEquals(sys.executable, context.call(get_sys_executable))
self.assertEqual(sys.executable, context.call(get_sys_executable))
env = context.call(get_os_environ)
self.assertEquals('magic_first_arg', env['STUB_PYTHON_FIRST_ARG'])
self.assertEquals('1', env['THIS_IS_STUB_PYTHON'])
self.assertEqual('magic_first_arg', env['STUB_PYTHON_FIRST_ARG'])
self.assertEqual('1', env['THIS_IS_STUB_PYTHON'])

@ -38,8 +38,8 @@ class BufferingTest(testlib.TestCase):
context, handler = self.build()
rec = self.record()
handler.emit(rec)
self.assertEquals(0, context.send.call_count)
self.assertEquals(1, len(handler._buffer))
self.assertEqual(0, context.send.call_count)
self.assertEqual(1, len(handler._buffer))
def test_uncork(self):
context, handler = self.build()
@ -47,14 +47,14 @@ class BufferingTest(testlib.TestCase):
handler.emit(rec)
handler.uncork()
self.assertEquals(1, context.send.call_count)
self.assertEquals(None, handler._buffer)
self.assertEqual(1, context.send.call_count)
self.assertEqual(None, handler._buffer)
_, args, _ = context.send.mock_calls[0]
msg, = args
self.assertEquals(mitogen.core.FORWARD_LOG, msg.handle)
self.assertEquals(b('name\x0099\x00msg'), msg.data)
self.assertEqual(mitogen.core.FORWARD_LOG, msg.handle)
self.assertEqual(b('name\x0099\x00msg'), msg.data)
class StartupTest(testlib.RouterMixin, testlib.TestCase):

@ -25,7 +25,7 @@ class ConstructorTest(testlib.RouterMixin, testlib.TestCase):
)
argv = eval(context.call(os.getenv, 'ORIGINAL_ARGV'))
self.assertEquals(argv[0], self.lxc_attach_path)
self.assertEqual(argv[0], self.lxc_attach_path)
self.assertTrue('--clear-env' in argv)
self.assertTrue(has_subseq(argv, ['--name', 'container_name']))

@ -16,10 +16,10 @@ class ConstructorTest(testlib.RouterMixin, testlib.TestCase):
)
argv = eval(context.call(os.getenv, 'ORIGINAL_ARGV'))
self.assertEquals(argv[0], lxc_path)
self.assertEquals(argv[1], 'exec')
self.assertEquals(argv[2], '--mode=noninteractive')
self.assertEquals(argv[3], 'container_name')
self.assertEqual(argv[0], lxc_path)
self.assertEqual(argv[1], 'exec')
self.assertEqual(argv[2], '--mode=noninteractive')
self.assertEqual(argv[3], 'container_name')
def test_eof(self):
e = self.assertRaises(mitogen.parent.EofError,

@ -23,4 +23,4 @@ class ScanCodeImportsTest(testlib.TestCase):
def test_simple(self):
source_path = inspect.getsourcefile(ScanCodeImportsTest)
co = compile(open(source_path).read(), source_path, 'exec')
self.assertEquals(list(self.func(co)), self.SIMPLE_EXPECT)
self.assertEqual(list(self.func(co)), self.SIMPLE_EXPECT)

@ -16,45 +16,45 @@ class ConstructorTest(testlib.TestCase):
klass = mitogen.core.Message
def test_dst_id_default(self):
self.assertEquals(self.klass().dst_id, None)
self.assertEqual(self.klass().dst_id, None)
def test_dst_id_explicit(self):
self.assertEquals(self.klass(dst_id=1111).dst_id, 1111)
self.assertEqual(self.klass(dst_id=1111).dst_id, 1111)
@mock.patch('mitogen.context_id', 1234)
def test_src_id_default(self):
self.assertEquals(self.klass().src_id, 1234)
self.assertEqual(self.klass().src_id, 1234)
def test_src_id_explicit(self):
self.assertEquals(self.klass(src_id=4321).src_id, 4321)
self.assertEqual(self.klass(src_id=4321).src_id, 4321)
@mock.patch('mitogen.context_id', 5555)
def test_auth_id_default(self):
self.assertEquals(self.klass().auth_id, 5555)
self.assertEqual(self.klass().auth_id, 5555)
def test_auth_id_explicit(self):
self.assertEquals(self.klass(auth_id=2222).auth_id, 2222)
self.assertEqual(self.klass(auth_id=2222).auth_id, 2222)
def test_handle_default(self):
self.assertEquals(self.klass().handle, None)
self.assertEqual(self.klass().handle, None)
def test_handle_explicit(self):
self.assertEquals(self.klass(handle=1234).handle, 1234)
self.assertEqual(self.klass(handle=1234).handle, 1234)
def test_reply_to_default(self):
self.assertEquals(self.klass().reply_to, None)
self.assertEqual(self.klass().reply_to, None)
def test_reply_to_explicit(self):
self.assertEquals(self.klass(reply_to=8888).reply_to, 8888)
self.assertEqual(self.klass(reply_to=8888).reply_to, 8888)
def test_data_default(self):
m = self.klass()
self.assertEquals(m.data, b(''))
self.assertEqual(m.data, b(''))
self.assertTrue(isinstance(m.data, mitogen.core.BytesType))
def test_data_explicit(self):
m = self.klass(data=b('asdf'))
self.assertEquals(m.data, b('asdf'))
self.assertEqual(m.data, b('asdf'))
self.assertTrue(isinstance(m.data, mitogen.core.BytesType))
def test_data_hates_unicode(self):
@ -66,62 +66,62 @@ class PackTest(testlib.TestCase):
klass = mitogen.core.Message
def test_header_format_sanity(self):
self.assertEquals(self.klass.HEADER_LEN,
self.assertEqual(self.klass.HEADER_LEN,
struct.calcsize(self.klass.HEADER_FMT))
def test_header_length_correct(self):
s = self.klass(dst_id=123, handle=123).pack()
self.assertEquals(len(s), self.klass.HEADER_LEN)
self.assertEqual(len(s), self.klass.HEADER_LEN)
def test_magic(self):
s = self.klass(dst_id=123, handle=123).pack()
magic, = struct.unpack('>h', s[:2])
self.assertEquals(self.klass.HEADER_MAGIC, magic)
self.assertEqual(self.klass.HEADER_MAGIC, magic)
def test_dst_id(self):
s = self.klass(dst_id=123, handle=123).pack()
dst_id, = struct.unpack('>L', s[2:6])
self.assertEquals(123, dst_id)
self.assertEqual(123, dst_id)
def test_src_id(self):
s = self.klass(src_id=5432, dst_id=123, handle=123).pack()
src_id, = struct.unpack('>L', s[6:10])
self.assertEquals(5432, src_id)
self.assertEqual(5432, src_id)
def test_auth_id(self):
s = self.klass(auth_id=1919, src_id=5432, dst_id=123, handle=123).pack()
auth_id, = struct.unpack('>L', s[10:14])
self.assertEquals(1919, auth_id)
self.assertEqual(1919, auth_id)
def test_handle(self):
s = self.klass(dst_id=123, handle=9999).pack()
handle, = struct.unpack('>L', s[14:18])
self.assertEquals(9999, handle)
self.assertEqual(9999, handle)
def test_reply_to(self):
s = self.klass(dst_id=1231, handle=7777, reply_to=9132).pack()
reply_to, = struct.unpack('>L', s[18:22])
self.assertEquals(9132, reply_to)
self.assertEqual(9132, reply_to)
def test_data_length_empty(self):
s = self.klass(dst_id=1231, handle=7777).pack()
data_length, = struct.unpack('>L', s[22:26])
self.assertEquals(0, data_length)
self.assertEqual(0, data_length)
def test_data_length_present(self):
s = self.klass(dst_id=1231, handle=7777, data=b('hello')).pack()
data_length, = struct.unpack('>L', s[22:26])
self.assertEquals(5, data_length)
self.assertEqual(5, data_length)
def test_data_empty(self):
s = self.klass(dst_id=1231, handle=7777).pack()
data = s[26:]
self.assertEquals(b(''), data)
self.assertEqual(b(''), data)
def test_data_present(self):
s = self.klass(dst_id=11, handle=77, data=b('hello')).pack()
data = s[26:]
self.assertEquals(b('hello'), data)
self.assertEqual(b('hello'), data)
class IsDeadTest(testlib.TestCase):
@ -141,15 +141,15 @@ class DeadTest(testlib.TestCase):
def test_no_reason(self):
msg = self.klass.dead()
self.assertEquals(msg.reply_to, mitogen.core.IS_DEAD)
self.assertEqual(msg.reply_to, mitogen.core.IS_DEAD)
self.assertTrue(msg.is_dead)
self.assertEquals(msg.data, b(''))
self.assertEqual(msg.data, b(''))
def test_with_reason(self):
msg = self.klass.dead(reason=u'oh no')
self.assertEquals(msg.reply_to, mitogen.core.IS_DEAD)
self.assertEqual(msg.reply_to, mitogen.core.IS_DEAD)
self.assertTrue(msg.is_dead)
self.assertEquals(msg.data, b('oh no'))
self.assertEqual(msg.data, b('oh no'))
class EvilObject(object):
@ -168,7 +168,7 @@ class PickledTest(testlib.TestCase):
def test_bool(self):
for b in True, False:
self.assertEquals(b, self.roundtrip(b))
self.assertEqual(b, self.roundtrip(b))
@unittest.skipIf(condition=sys.version_info < (2, 6),
reason='bytearray missing on <2.6')
@ -180,24 +180,24 @@ class PickledTest(testlib.TestCase):
def test_bytes(self):
by = b('123')
self.assertEquals(by, self.roundtrip(by))
self.assertEqual(by, self.roundtrip(by))
def test_dict(self):
d = {1: 2, u'a': 3, b('b'): 4, 'c': {}}
roundtrip = self.roundtrip(d)
self.assertEquals(d, roundtrip)
self.assertEqual(d, roundtrip)
self.assertTrue(isinstance(roundtrip, dict))
for k in d:
self.assertTrue(isinstance(roundtrip[k], type(d[k])))
def test_int(self):
self.assertEquals(123, self.klass.pickled(123).unpickle())
self.assertEqual(123, self.klass.pickled(123).unpickle())
def test_list(self):
l = [1, u'b', b('c')]
roundtrip = self.roundtrip(l)
self.assertTrue(isinstance(roundtrip, list))
self.assertEquals(l, roundtrip)
self.assertEqual(l, roundtrip)
for k in range(len(l)):
self.assertTrue(isinstance(roundtrip[k], type(l[k])))
@ -206,13 +206,13 @@ class PickledTest(testlib.TestCase):
def test_long(self):
l = long(0xffffffffffff)
roundtrip = self.roundtrip(l)
self.assertEquals(l, roundtrip)
self.assertEqual(l, roundtrip)
self.assertTrue(isinstance(roundtrip, long))
def test_tuple(self):
l = (1, u'b', b('c'))
roundtrip = self.roundtrip(l)
self.assertEquals(l, roundtrip)
self.assertEqual(l, roundtrip)
self.assertTrue(isinstance(roundtrip, tuple))
for k in range(len(l)):
self.assertTrue(isinstance(roundtrip[k], type(l[k])))
@ -220,7 +220,7 @@ class PickledTest(testlib.TestCase):
def test_unicode(self):
u = u'abcd'
roundtrip = self.roundtrip(u)
self.assertEquals(u, roundtrip)
self.assertEqual(u, roundtrip)
self.assertTrue(isinstance(roundtrip, mitogen.core.UnicodeType))
#### custom types. see also: types_test.py, call_error_test.py
@ -233,31 +233,31 @@ class PickledTest(testlib.TestCase):
v = mitogen.core.Blob(b('dave'))
roundtrip = self.roundtrip(v)
self.assertTrue(isinstance(roundtrip, mitogen.core.Blob))
self.assertEquals(b('dave'), roundtrip)
self.assertEqual(b('dave'), roundtrip)
def test_blob_empty(self):
v = mitogen.core.Blob(b(''))
roundtrip = self.roundtrip(v)
self.assertTrue(isinstance(roundtrip, mitogen.core.Blob))
self.assertEquals(b(''), v)
self.assertEqual(b(''), v)
def test_secret_nonempty(self):
s = mitogen.core.Secret(u'dave')
roundtrip = self.roundtrip(s)
self.assertTrue(isinstance(roundtrip, mitogen.core.Secret))
self.assertEquals(u'dave', roundtrip)
self.assertEqual(u'dave', roundtrip)
def test_secret_empty(self):
s = mitogen.core.Secret(u'')
roundtrip = self.roundtrip(s)
self.assertTrue(isinstance(roundtrip, mitogen.core.Secret))
self.assertEquals(u'', roundtrip)
self.assertEqual(u'', roundtrip)
def test_call_error(self):
ce = mitogen.core.CallError('nope')
ce2 = self.assertRaises(mitogen.core.CallError,
lambda: self.roundtrip(ce))
self.assertEquals(ce.args[0], ce2.args[0])
self.assertEqual(ce.args[0], ce2.args[0])
def test_context(self):
router = mitogen.master.Router()
@ -265,7 +265,7 @@ class PickledTest(testlib.TestCase):
c = router.context_by_id(1234)
roundtrip = self.roundtrip(c)
self.assertTrue(isinstance(roundtrip, mitogen.core.Context))
self.assertEquals(c.context_id, 1234)
self.assertEqual(c.context_id, 1234)
finally:
router.broker.shutdown()
router.broker.join()
@ -277,8 +277,8 @@ class PickledTest(testlib.TestCase):
sender = recv.to_sender()
roundtrip = self.roundtrip(sender, router=router)
self.assertTrue(isinstance(roundtrip, mitogen.core.Sender))
self.assertEquals(roundtrip.context.context_id, mitogen.context_id)
self.assertEquals(roundtrip.dst_handle, sender.dst_handle)
self.assertEqual(roundtrip.context.context_id, mitogen.context_id)
self.assertEqual(roundtrip.dst_handle, sender.dst_handle)
finally:
router.broker.shutdown()
router.broker.join()
@ -299,15 +299,15 @@ class ReplyTest(testlib.TestCase):
msg = self.klass(src_id=1234, reply_to=9191)
router = mock.Mock()
msg.reply(123, router=router)
self.assertEquals(1, router.route.call_count)
self.assertEqual(1, router.route.call_count)
def test_reply_pickles_object(self):
msg = self.klass(src_id=1234, reply_to=9191)
router = mock.Mock()
msg.reply(123, router=router)
_, (reply,), _ = router.route.mock_calls[0]
self.assertEquals(reply.dst_id, 1234)
self.assertEquals(reply.unpickle(), 123)
self.assertEqual(reply.dst_id, 1234)
self.assertEqual(reply.unpickle(), 123)
def test_reply_uses_preformatted_message(self):
msg = self.klass(src_id=1234, reply_to=9191)
@ -316,22 +316,22 @@ class ReplyTest(testlib.TestCase):
msg.reply(my_reply, router=router)
_, (reply,), _ = router.route.mock_calls[0]
self.assertTrue(my_reply is reply)
self.assertEquals(reply.dst_id, 1234)
self.assertEquals(reply.unpickle(), 4444)
self.assertEqual(reply.dst_id, 1234)
self.assertEqual(reply.unpickle(), 4444)
def test_reply_sets_dst_id(self):
msg = self.klass(src_id=1234, reply_to=9191)
router = mock.Mock()
msg.reply(123, router=router)
_, (reply,), _ = router.route.mock_calls[0]
self.assertEquals(reply.dst_id, 1234)
self.assertEqual(reply.dst_id, 1234)
def test_reply_sets_handle(self):
msg = self.klass(src_id=1234, reply_to=9191)
router = mock.Mock()
msg.reply(123, router=router)
_, (reply,), _ = router.route.mock_calls[0]
self.assertEquals(reply.handle, 9191)
self.assertEqual(reply.handle, 9191)
class UnpickleTest(testlib.TestCase):
@ -343,13 +343,13 @@ class UnpickleTest(testlib.TestCase):
m = self.klass.pickled(ce)
ce2 = self.assertRaises(mitogen.core.CallError,
lambda: m.unpickle())
self.assertEquals(ce.args[0], ce2.args[0])
self.assertEqual(ce.args[0], ce2.args[0])
def test_no_throw(self):
ce = mitogen.core.CallError('nope')
m = self.klass.pickled(ce)
ce2 = m.unpickle(throw=False)
self.assertEquals(ce.args[0], ce2.args[0])
self.assertEqual(ce.args[0], ce2.args[0])
def test_throw_dead(self):
m = self.klass.pickled('derp', reply_to=mitogen.core.IS_DEAD)
@ -358,7 +358,7 @@ class UnpickleTest(testlib.TestCase):
def test_no_throw_dead(self):
m = self.klass.pickled('derp', reply_to=mitogen.core.IS_DEAD)
self.assertEquals('derp', m.unpickle(throw_dead=False))
self.assertEqual('derp', m.unpickle(throw_dead=False))
class UnpickleCompatTest(testlib.TestCase):

@ -69,7 +69,7 @@ class MitogenCoreTest(testlib.TestCase):
compile(minified, name, 'exec')
def _test_line_counts_match(self, original, minified):
self.assertEquals(original.count('\n'),
self.assertEqual(original.count('\n'),
minified.count('\n'))
def _test_non_blank_lines_match(self, name, original, minified):

@ -24,6 +24,6 @@ class ReceiveOneTest(testlib.TestCase):
protocol.on_receive(broker, junk)
capture.stop()
self.assertEquals(1, stream.on_disconnect.call_count)
self.assertEqual(1, stream.on_disconnect.call_count)
expect = self.klass.corrupt_msg % (stream.name, junk)
self.assertTrue(expect in capture.raw())

@ -21,7 +21,7 @@ class ReprTest(testlib.TestCase):
klass = mitogen.master.ModuleFinder
def test_simple(self):
self.assertEquals('ModuleFinder()', repr(self.klass()))
self.assertEqual('ModuleFinder()', repr(self.klass()))
class IsStdlibNameTest(testlib.TestCase):
@ -58,10 +58,10 @@ class GetMainModuleDefectivePython3x(testlib.TestCase):
return self.klass().find(fullname)
def test_builtin(self):
self.assertEquals(None, self.call('sys'))
self.assertEqual(None, self.call('sys'))
def test_not_main(self):
self.assertEquals(None, self.call('mitogen'))
self.assertEqual(None, self.call('mitogen'))
def test_main(self):
import __main__
@ -69,10 +69,10 @@ class GetMainModuleDefectivePython3x(testlib.TestCase):
path, source, is_pkg = self.call('__main__')
self.assertTrue(path is not None)
self.assertTrue(os.path.exists(path))
self.assertEquals(path, __main__.__file__)
self.assertEqual(path, __main__.__file__)
fp = open(path, 'rb')
try:
self.assertEquals(source, fp.read())
self.assertEqual(source, fp.read())
finally:
fp.close()
self.assertFalse(is_pkg)
@ -86,24 +86,24 @@ class PkgutilMethodTest(testlib.TestCase):
def test_empty_source_pkg(self):
path, src, is_pkg = self.call('module_finder_testmod')
self.assertEquals(path,
self.assertEqual(path,
os.path.join(MODS_DIR, 'module_finder_testmod/__init__.py'))
self.assertEquals(mitogen.core.b(''), src)
self.assertEqual(mitogen.core.b(''), src)
self.assertTrue(is_pkg)
def test_empty_source_module(self):
path, src, is_pkg = self.call('module_finder_testmod.empty_mod')
self.assertEquals(path,
self.assertEqual(path,
os.path.join(MODS_DIR, 'module_finder_testmod/empty_mod.py'))
self.assertEquals(mitogen.core.b(''), src)
self.assertEqual(mitogen.core.b(''), src)
self.assertFalse(is_pkg)
def test_regular_mod(self):
from module_finder_testmod import regular_mod
path, src, is_pkg = self.call('module_finder_testmod.regular_mod')
self.assertEquals(path,
self.assertEqual(path,
os.path.join(MODS_DIR, 'module_finder_testmod/regular_mod.py'))
self.assertEquals(mitogen.core.to_text(src),
self.assertEqual(mitogen.core.to_text(src),
inspect.getsource(regular_mod))
self.assertFalse(is_pkg)
@ -117,14 +117,14 @@ class SysModulesMethodTest(testlib.TestCase):
def test_main(self):
import __main__
path, src, is_pkg = self.call('__main__')
self.assertEquals(path, __main__.__file__)
self.assertEqual(path, __main__.__file__)
# linecache adds a line ending to the final line if one is missing.
actual_src = open(path, 'rb').read()
if actual_src[-1:] != b('\n'):
actual_src += b('\n')
self.assertEquals(src, actual_src)
self.assertEqual(src, actual_src)
self.assertFalse(is_pkg)
def test_dylib_fails(self):
@ -165,16 +165,16 @@ class GetModuleViaParentEnumerationTest(testlib.TestCase):
import pkg_like_plumbum.colors
path, src, is_pkg = self.call('pkg_like_plumbum.colors')
modpath = os.path.join(MODS_DIR, 'pkg_like_plumbum/colors.py')
self.assertEquals(path, modpath)
self.assertEqual(path, modpath)
self.assertEquals(src, open(modpath, 'rb').read())
self.assertEqual(src, open(modpath, 'rb').read())
self.assertFalse(is_pkg)
def test_ansible_module_utils_distro_succeeds(self):
# #590: a package that turns itself into a module.
import pkg_like_ansible.module_utils.distro as d
self.assertEquals(d.I_AM, "the module that replaced the package")
self.assertEquals(
self.assertEqual(d.I_AM, "the module that replaced the package")
self.assertEqual(
sys.modules['pkg_like_ansible.module_utils.distro'].__name__,
'pkg_like_ansible.module_utils.distro._distro'
)
@ -183,9 +183,9 @@ class GetModuleViaParentEnumerationTest(testlib.TestCase):
path, src, is_pkg = self.call('pkg_like_ansible.module_utils.distro')
modpath = os.path.join(MODS_DIR,
'pkg_like_ansible/module_utils/distro/__init__.py')
self.assertEquals(path, modpath)
self.assertEquals(src, open(modpath, 'rb').read())
self.assertEquals(is_pkg, True)
self.assertEqual(path, modpath)
self.assertEqual(src, open(modpath, 'rb').read())
self.assertEqual(is_pkg, True)
# ensure we can resolve a child of the subpackage.
path, src, is_pkg = self.call(
@ -193,16 +193,16 @@ class GetModuleViaParentEnumerationTest(testlib.TestCase):
)
modpath = os.path.join(MODS_DIR,
'pkg_like_ansible/module_utils/distro/_distro.py')
self.assertEquals(path, modpath)
self.assertEquals(src, open(modpath, 'rb').read())
self.assertEquals(is_pkg, False)
self.assertEqual(path, modpath)
self.assertEqual(src, open(modpath, 'rb').read())
self.assertEqual(is_pkg, False)
def test_ansible_module_utils_system_distro_succeeds(self):
# #590: a package that turns itself into a module.
# #590: a package that turns itself into a module.
import pkg_like_ansible.module_utils.sys_distro as d
self.assertEquals(d.I_AM, "the system module that replaced the subpackage")
self.assertEquals(
self.assertEqual(d.I_AM, "the system module that replaced the subpackage")
self.assertEqual(
sys.modules['pkg_like_ansible.module_utils.sys_distro'].__name__,
'system_distro'
)
@ -211,9 +211,9 @@ class GetModuleViaParentEnumerationTest(testlib.TestCase):
path, src, is_pkg = self.call('pkg_like_ansible.module_utils.sys_distro')
modpath = os.path.join(MODS_DIR,
'pkg_like_ansible/module_utils/sys_distro/__init__.py')
self.assertEquals(path, modpath)
self.assertEquals(src, open(modpath, 'rb').read())
self.assertEquals(is_pkg, True)
self.assertEqual(path, modpath)
self.assertEqual(src, open(modpath, 'rb').read())
self.assertEqual(is_pkg, True)
# ensure we can resolve a child of the subpackage.
path, src, is_pkg = self.call(
@ -221,9 +221,9 @@ class GetModuleViaParentEnumerationTest(testlib.TestCase):
)
modpath = os.path.join(MODS_DIR,
'pkg_like_ansible/module_utils/sys_distro/_distro.py')
self.assertEquals(path, modpath)
self.assertEquals(src, open(modpath, 'rb').read())
self.assertEquals(is_pkg, False)
self.assertEqual(path, modpath)
self.assertEqual(src, open(modpath, 'rb').read())
self.assertEqual(is_pkg, False)
class ResolveRelPathTest(testlib.TestCase):
@ -233,21 +233,21 @@ class ResolveRelPathTest(testlib.TestCase):
return self.klass().resolve_relpath(fullname, level)
def test_empty(self):
self.assertEquals('', self.call('', 0))
self.assertEquals('', self.call('', 1))
self.assertEquals('', self.call('', 2))
self.assertEqual('', self.call('', 0))
self.assertEqual('', self.call('', 1))
self.assertEqual('', self.call('', 2))
def test_absolute(self):
self.assertEquals('', self.call('email.utils', 0))
self.assertEqual('', self.call('email.utils', 0))
def test_rel1(self):
self.assertEquals('email.', self.call('email.utils', 1))
self.assertEqual('email.', self.call('email.utils', 1))
def test_rel2(self):
self.assertEquals('', self.call('email.utils', 2))
self.assertEqual('', self.call('email.utils', 2))
def test_rel_overflow(self):
self.assertEquals('', self.call('email.utils', 3))
self.assertEqual('', self.call('email.utils', 3))
class FakeSshTest(testlib.TestCase):
@ -259,7 +259,7 @@ class FakeSshTest(testlib.TestCase):
def test_simple(self):
import mitogen.fakessh
related = self.call('mitogen.fakessh')
self.assertEquals(related, [
self.assertEqual(related, [
'mitogen',
'mitogen.core',
'mitogen.master',
@ -291,7 +291,7 @@ class FindRelatedTest(testlib.TestCase):
def test_simple(self):
import mitogen.fakessh
related = self.call('mitogen.fakessh')
self.assertEquals(set(related), self.SIMPLE_EXPECT)
self.assertEqual(set(related), self.SIMPLE_EXPECT)
if sys.version_info > (2, 6):
@ -332,7 +332,7 @@ if sys.version_info > (2, 6):
def test_django_db(self):
import django.db
related = self.call('django.db')
self.assertEquals(related, [
self.assertEqual(related, [
'django',
'django.core',
'django.core.signals',
@ -344,7 +344,7 @@ if sys.version_info > (2, 6):
import django.db.models
related = self.call('django.db.models')
self.maxDiff=None
self.assertEquals(related, [
self.assertEqual(related, [
u'django',
u'django.core.exceptions',
u'django.db',
@ -374,7 +374,7 @@ if sys.version_info > (2, 6):
def test_django_db(self):
import django.db
related = self.call('django.db')
self.assertEquals(related, [
self.assertEqual(related, [
u'django',
u'django.conf',
u'django.conf.global_settings',
@ -401,7 +401,7 @@ if sys.version_info > (2, 6):
def test_django_db_models(self):
import django.db.models
related = self.call('django.db.models')
self.assertEquals(related, [
self.assertEqual(related, [
u'django',
u'django.conf',
u'django.conf.global_settings',

@ -13,7 +13,7 @@ class CorkTest(testlib.RouterMixin, testlib.TestCase):
def test_cork_broker(self):
latch = mitogen.core.Latch()
self.broker.defer(self.ping, latch)
self.assertEquals('pong', latch.get())
self.assertEqual('pong', latch.get())
corker = self.klass(brokers=(self.broker,))
corker.cork()
@ -23,14 +23,14 @@ class CorkTest(testlib.RouterMixin, testlib.TestCase):
self.assertRaises(mitogen.core.TimeoutError,
lambda: latch.get(timeout=0.5))
corker.uncork()
self.assertEquals('pong', latch.get())
self.assertEqual('pong', latch.get())
def test_cork_pool(self):
pool = mitogen.service.Pool(self.router, services=(), size=4)
try:
latch = mitogen.core.Latch()
pool.defer(self.ping, latch)
self.assertEquals('pong', latch.get())
self.assertEqual('pong', latch.get())
corker = self.klass(pools=(pool,))
corker.cork()
@ -40,6 +40,6 @@ class CorkTest(testlib.RouterMixin, testlib.TestCase):
self.assertRaises(mitogen.core.TimeoutError,
lambda: latch.get(timeout=0.5))
corker.uncork()
self.assertEquals('pong', latch.get())
self.assertEqual('pong', latch.get())
finally:
pool.stop(join=True)

@ -69,20 +69,20 @@ class GetDefaultRemoteNameTest(testlib.TestCase):
mock_gethostname.return_value = 'box'
mock_getuser.return_value = 'ECORP\\Administrator'
mock_getpid.return_value = 123
self.assertEquals("ECORP_Administrator@box:123", self.func())
self.assertEqual("ECORP_Administrator@box:123", self.func())
class ReturncodeToStrTest(testlib.TestCase):
func = staticmethod(mitogen.parent.returncode_to_str)
def test_return_zero(self):
self.assertEquals(self.func(0), 'exited with return code 0')
self.assertEqual(self.func(0), 'exited with return code 0')
def test_return_one(self):
self.assertEquals(self.func(1), 'exited with return code 1')
self.assertEqual(self.func(1), 'exited with return code 1')
def test_sigkill(self):
self.assertEquals(self.func(-signal.SIGKILL),
self.assertEqual(self.func(-signal.SIGKILL),
'exited due to signal %s (SIGKILL)' % (int(signal.SIGKILL),)
)
@ -107,7 +107,7 @@ class ReapChildTest(testlib.RouterMixin, testlib.TestCase):
e = self.assertRaises(OSError,
lambda: os.kill(conn.proc.pid, 0)
)
self.assertEquals(e.args[0], errno.ESRCH)
self.assertEqual(e.args[0], errno.ESRCH)
class StreamErrorTest(testlib.RouterMixin, testlib.TestCase):
@ -186,7 +186,7 @@ class OpenPtyTest(testlib.TestCase):
e = self.assertRaises(mitogen.core.StreamError,
lambda: self.func())
msg = mitogen.parent.OPENPTY_MSG % (openpty.side_effect,)
self.assertEquals(e.args[0], msg)
self.assertEqual(e.args[0], msg)
@unittest.skipIf(condition=(os.uname()[0] != 'Linux'),
reason='Fallback only supported on Linux')
@ -196,12 +196,12 @@ class OpenPtyTest(testlib.TestCase):
master_fp, slave_fp = self.func()
try:
st = os.fstat(master_fp.fileno())
self.assertEquals(5, os.major(st.st_rdev))
self.assertEqual(5, os.major(st.st_rdev))
flags = fcntl.fcntl(master_fp.fileno(), fcntl.F_GETFL)
self.assertTrue(flags & os.O_RDWR)
st = os.fstat(slave_fp.fileno())
self.assertEquals(136, os.major(st.st_rdev))
self.assertEqual(136, os.major(st.st_rdev))
flags = fcntl.fcntl(slave_fp.fileno(), fcntl.F_GETFL)
self.assertTrue(flags & os.O_RDWR)
finally:
@ -218,7 +218,7 @@ class DisconnectTest(testlib.RouterMixin, testlib.TestCase):
c1.shutdown(wait=True)
e = self.assertRaises(mitogen.core.ChannelError,
lambda: recv.get())
self.assertEquals(e.args[0], self.router.respondent_disconnect_msg)
self.assertEqual(e.args[0], self.router.respondent_disconnect_msg)
def test_indirect_child_disconnected(self):
# Achievement unlocked: process notices an indirectly connected child
@ -229,7 +229,7 @@ class DisconnectTest(testlib.RouterMixin, testlib.TestCase):
c2.shutdown(wait=True)
e = self.assertRaises(mitogen.core.ChannelError,
lambda: recv.get())
self.assertEquals(e.args[0], self.router.respondent_disconnect_msg)
self.assertEqual(e.args[0], self.router.respondent_disconnect_msg)
def test_indirect_child_intermediary_disconnected(self):
# Battlefield promotion: process notices indirect child disconnected
@ -240,7 +240,7 @@ class DisconnectTest(testlib.RouterMixin, testlib.TestCase):
c1.shutdown(wait=True)
e = self.assertRaises(mitogen.core.ChannelError,
lambda: recv.get())
self.assertEquals(e.args[0], self.router.respondent_disconnect_msg)
self.assertEqual(e.args[0], self.router.respondent_disconnect_msg)
def test_near_sibling_disconnected(self):
# Hard mode: child notices sibling connected to same parent has

@ -24,7 +24,7 @@ class ConstructorTest(testlib.RouterMixin, testlib.TestCase):
'container_name',
stream.conn.options.python_path
]
self.assertEquals(argv[:len(expected_call)], expected_call)
self.assertEqual(argv[:len(expected_call)], expected_call)
context = self.router.podman(
container='container_name',
@ -43,4 +43,4 @@ class ConstructorTest(testlib.RouterMixin, testlib.TestCase):
'container_name',
stream.conn.options.python_path
]
self.assertEquals(argv[:len(expected_call)], expected_call)
self.assertEqual(argv[:len(expected_call)], expected_call)

@ -86,69 +86,69 @@ class PollerMixin(object):
class ReceiveStateMixin(PollerMixin, SockMixin):
def test_start_receive_adds_reader(self):
self.p.start_receive(self.l1)
self.assertEquals([(self.l1, self.l1)], self.p.readers)
self.assertEquals([], self.p.writers)
self.assertEqual([(self.l1, self.l1)], self.p.readers)
self.assertEqual([], self.p.writers)
def test_start_receive_adds_reader_data(self):
data = object()
self.p.start_receive(self.l1, data=data)
self.assertEquals([(self.l1, data)], self.p.readers)
self.assertEquals([], self.p.writers)
self.assertEqual([(self.l1, data)], self.p.readers)
self.assertEqual([], self.p.writers)
def test_stop_receive(self):
self.p.start_receive(self.l1)
self.p.stop_receive(self.l1)
self.assertEquals([], self.p.readers)
self.assertEquals([], self.p.writers)
self.assertEqual([], self.p.readers)
self.assertEqual([], self.p.writers)
def test_stop_receive_dup(self):
self.p.start_receive(self.l1)
self.p.stop_receive(self.l1)
self.assertEquals([], self.p.readers)
self.assertEquals([], self.p.writers)
self.assertEqual([], self.p.readers)
self.assertEqual([], self.p.writers)
self.p.stop_receive(self.l1)
self.assertEquals([], self.p.readers)
self.assertEquals([], self.p.writers)
self.assertEqual([], self.p.readers)
self.assertEqual([], self.p.writers)
def test_stop_receive_noexist(self):
p = self.klass()
p.stop_receive(123) # should not fail
self.assertEquals([], p.readers)
self.assertEquals([], self.p.writers)
self.assertEqual([], p.readers)
self.assertEqual([], self.p.writers)
class TransmitStateMixin(PollerMixin, SockMixin):
def test_start_transmit_adds_writer(self):
self.p.start_transmit(self.r1)
self.assertEquals([], self.p.readers)
self.assertEquals([(self.r1, self.r1)], self.p.writers)
self.assertEqual([], self.p.readers)
self.assertEqual([(self.r1, self.r1)], self.p.writers)
def test_start_transmit_adds_writer_data(self):
data = object()
self.p.start_transmit(self.r1, data=data)
self.assertEquals([], self.p.readers)
self.assertEquals([(self.r1, data)], self.p.writers)
self.assertEqual([], self.p.readers)
self.assertEqual([(self.r1, data)], self.p.writers)
def test_stop_transmit(self):
self.p.start_transmit(self.r1)
self.p.stop_transmit(self.r1)
self.assertEquals([], self.p.readers)
self.assertEquals([], self.p.writers)
self.assertEqual([], self.p.readers)
self.assertEqual([], self.p.writers)
def test_stop_transmit_dup(self):
self.p.start_transmit(self.r1)
self.p.stop_transmit(self.r1)
self.assertEquals([], self.p.readers)
self.assertEquals([], self.p.writers)
self.assertEqual([], self.p.readers)
self.assertEqual([], self.p.writers)
self.p.stop_transmit(self.r1)
self.assertEquals([], self.p.readers)
self.assertEquals([], self.p.writers)
self.assertEqual([], self.p.readers)
self.assertEqual([], self.p.writers)
def test_stop_transmit_noexist(self):
p = self.klass()
p.stop_receive(123) # should not fail
self.assertEquals([], p.readers)
self.assertEquals([], self.p.writers)
self.assertEqual([], p.readers)
self.assertEqual([], self.p.writers)
class CloseMixin(PollerMixin):
@ -163,42 +163,42 @@ class CloseMixin(PollerMixin):
class PollMixin(PollerMixin):
def test_empty_zero_timeout(self):
t0 = mitogen.core.now()
self.assertEquals([], list(self.p.poll(0)))
self.assertEqual([], list(self.p.poll(0)))
self.assertTrue((mitogen.core.now() - t0) < .1) # vaguely reasonable
def test_empty_small_timeout(self):
t0 = mitogen.core.now()
self.assertEquals([], list(self.p.poll(.2)))
self.assertEqual([], list(self.p.poll(.2)))
self.assertTrue((mitogen.core.now() - t0) >= .2)
class ReadableMixin(PollerMixin, SockMixin):
def test_unreadable(self):
self.p.start_receive(self.l1)
self.assertEquals([], list(self.p.poll(0)))
self.assertEqual([], list(self.p.poll(0)))
def test_readable_before_add(self):
self.fill(self.r1)
self.p.start_receive(self.l1)
self.assertEquals([self.l1], list(self.p.poll(0)))
self.assertEqual([self.l1], list(self.p.poll(0)))
def test_readable_after_add(self):
self.p.start_receive(self.l1)
self.fill(self.r1)
self.assertEquals([self.l1], list(self.p.poll(0)))
self.assertEqual([self.l1], list(self.p.poll(0)))
def test_readable_then_unreadable(self):
self.fill(self.r1)
self.p.start_receive(self.l1)
self.assertEquals([self.l1], list(self.p.poll(0)))
self.assertEqual([self.l1], list(self.p.poll(0)))
self.drain(self.l1)
self.assertEquals([], list(self.p.poll(0)))
self.assertEqual([], list(self.p.poll(0)))
def test_readable_data(self):
data = object()
self.fill(self.r1)
self.p.start_receive(self.l1, data=data)
self.assertEquals([data], list(self.p.poll(0)))
self.assertEqual([data], list(self.p.poll(0)))
def test_double_readable_data(self):
data1 = object()
@ -207,35 +207,35 @@ class ReadableMixin(PollerMixin, SockMixin):
self.p.start_receive(self.l1, data=data1)
self.fill(self.r2)
self.p.start_receive(self.l2, data=data2)
self.assertEquals(set([data1, data2]), set(self.p.poll(0)))
self.assertEqual(set([data1, data2]), set(self.p.poll(0)))
class WriteableMixin(PollerMixin, SockMixin):
def test_writeable(self):
self.p.start_transmit(self.r1)
self.assertEquals([self.r1], list(self.p.poll(0)))
self.assertEqual([self.r1], list(self.p.poll(0)))
def test_writeable_data(self):
data = object()
self.p.start_transmit(self.r1, data=data)
self.assertEquals([data], list(self.p.poll(0)))
self.assertEqual([data], list(self.p.poll(0)))
def test_unwriteable_before_add(self):
self.fill(self.r1)
self.p.start_transmit(self.r1)
self.assertEquals([], list(self.p.poll(0)))
self.assertEqual([], list(self.p.poll(0)))
def test_unwriteable_after_add(self):
self.p.start_transmit(self.r1)
self.fill(self.r1)
self.assertEquals([], list(self.p.poll(0)))
self.assertEqual([], list(self.p.poll(0)))
def test_unwriteable_then_writeable(self):
self.fill(self.r1)
self.p.start_transmit(self.r1)
self.assertEquals([], list(self.p.poll(0)))
self.assertEqual([], list(self.p.poll(0)))
self.drain(self.l1)
self.assertEquals([self.r1], list(self.p.poll(0)))
self.assertEqual([self.r1], list(self.p.poll(0)))
def test_double_unwriteable_then_Writeable(self):
self.fill(self.r1)
@ -244,13 +244,13 @@ class WriteableMixin(PollerMixin, SockMixin):
self.fill(self.r2)
self.p.start_transmit(self.r2)
self.assertEquals([], list(self.p.poll(0)))
self.assertEqual([], list(self.p.poll(0)))
self.drain(self.l1)
self.assertEquals([self.r1], list(self.p.poll(0)))
self.assertEqual([self.r1], list(self.p.poll(0)))
self.drain(self.l2)
self.assertEquals(set([self.r1, self.r2]), set(self.p.poll(0)))
self.assertEqual(set([self.r1, self.r2]), set(self.p.poll(0)))
class MutateDuringYieldMixin(PollerMixin, SockMixin):
@ -262,13 +262,13 @@ class MutateDuringYieldMixin(PollerMixin, SockMixin):
self.p.start_receive(self.r1)
p = self.p.poll(0)
self.p.stop_receive(self.r1)
self.assertEquals([], list(p))
self.assertEqual([], list(p))
def test_one_writeable_removed_before_yield(self):
self.p.start_transmit(self.r1)
p = self.p.poll(0)
self.p.stop_transmit(self.r1)
self.assertEquals([], list(p))
self.assertEqual([], list(p))
def test_one_readable_readded_before_yield(self):
# fd removed, closed, another fd opened, gets same fd number, re-added.
@ -278,7 +278,7 @@ class MutateDuringYieldMixin(PollerMixin, SockMixin):
p = self.p.poll(0)
self.p.stop_receive(self.r1)
self.p.start_receive(self.r1)
self.assertEquals([], list(p))
self.assertEqual([], list(p))
def test_one_readable_readded_during_yield(self):
self.fill(self.l1)
@ -299,7 +299,7 @@ class MutateDuringYieldMixin(PollerMixin, SockMixin):
# the start_receive() may be for a totally new underlying file object,
# the live loop iteration must not yield any buffered readiness event.
self.assertEquals([], list(p))
self.assertEqual([], list(p))
class FileClosedMixin(PollerMixin, SockMixin):
@ -308,10 +308,10 @@ class FileClosedMixin(PollerMixin, SockMixin):
def test_writeable_then_closed(self):
self.p.start_transmit(self.r1)
self.assertEquals([self.r1], list(self.p.poll(0)))
self.assertEqual([self.r1], list(self.p.poll(0)))
self.close_socks()
try:
self.assertEquals([], list(self.p.poll(0)))
self.assertEqual([], list(self.p.poll(0)))
except select.error:
# a crash is also reasonable here.
pass
@ -321,7 +321,7 @@ class FileClosedMixin(PollerMixin, SockMixin):
p = self.p.poll(0)
self.close_socks()
try:
self.assertEquals([], list(p))
self.assertEqual([], list(p))
except select.error:
# a crash is also reasonable here.
pass
@ -329,10 +329,10 @@ class FileClosedMixin(PollerMixin, SockMixin):
def test_readable_then_closed(self):
self.fill(self.l1)
self.p.start_receive(self.r1)
self.assertEquals([self.r1], list(self.p.poll(0)))
self.assertEqual([self.r1], list(self.p.poll(0)))
self.close_socks()
try:
self.assertEquals([], list(self.p.poll(0)))
self.assertEqual([], list(self.p.poll(0)))
except select.error:
# a crash is also reasonable here.
pass
@ -343,7 +343,7 @@ class FileClosedMixin(PollerMixin, SockMixin):
p = self.p.poll(0)
self.close_socks()
try:
self.assertEquals([], list(p))
self.assertEqual([], list(p))
except select.error:
# a crash is also reasonable here.
pass
@ -355,10 +355,10 @@ class TtyHangupMixin(PollerMixin):
master_fp, slave_fp = mitogen.parent.openpty()
try:
self.p.start_receive(master_fp.fileno())
self.assertEquals([], list(self.p.poll(0)))
self.assertEqual([], list(self.p.poll(0)))
slave_fp.close()
slave_fp = None
self.assertEquals([master_fp.fileno()], list(self.p.poll(0)))
self.assertEqual([master_fp.fileno()], list(self.p.poll(0)))
finally:
if slave_fp is not None:
slave_fp.close()
@ -375,9 +375,9 @@ class DistinctDataMixin(PollerMixin, SockMixin):
self.p.start_receive(self.r1, data=rdata)
self.p.start_transmit(self.r1, data=wdata)
self.assertEquals([wdata], list(self.p.poll(0)))
self.assertEqual([wdata], list(self.p.poll(0)))
self.fill(self.l1) # r1 is now readable and writeable.
self.assertEquals(set([rdata, wdata]), set(self.p.poll(0)))
self.assertEqual(set([rdata, wdata]), set(self.p.poll(0)))
class AllMixin(ReceiveStateMixin,

@ -13,27 +13,27 @@ class BytesPartitionTest(testlib.TestCase):
self.assertTrue(isinstance(left, mitogen.core.BytesType))
self.assertTrue(isinstance(sep, mitogen.core.BytesType))
self.assertTrue(isinstance(right, mitogen.core.BytesType))
self.assertEquals(left, b('dave'))
self.assertEquals(sep, b(''))
self.assertEquals(right, b(''))
self.assertEqual(left, b('dave'))
self.assertEqual(sep, b(''))
self.assertEqual(right, b(''))
def test_one_sep(self):
left, sep, right = self.func(b('davexdave'), b('x'))
self.assertTrue(isinstance(left, mitogen.core.BytesType))
self.assertTrue(isinstance(sep, mitogen.core.BytesType))
self.assertTrue(isinstance(right, mitogen.core.BytesType))
self.assertEquals(left, b('dave'))
self.assertEquals(sep, b('x'))
self.assertEquals(right, b('dave'))
self.assertEqual(left, b('dave'))
self.assertEqual(sep, b('x'))
self.assertEqual(right, b('dave'))
def test_two_seps(self):
left, sep, right = self.func(b('davexdavexdave'), b('x'))
self.assertTrue(isinstance(left, mitogen.core.BytesType))
self.assertTrue(isinstance(sep, mitogen.core.BytesType))
self.assertTrue(isinstance(right, mitogen.core.BytesType))
self.assertEquals(left, b('dave'))
self.assertEquals(sep, b('x'))
self.assertEquals(right, b('davexdave'))
self.assertEqual(left, b('dave'))
self.assertEqual(sep, b('x'))
self.assertEqual(right, b('davexdave'))
class StrPartitionTest(testlib.TestCase):
@ -44,27 +44,27 @@ class StrPartitionTest(testlib.TestCase):
self.assertTrue(isinstance(left, mitogen.core.UnicodeType))
self.assertTrue(isinstance(sep, mitogen.core.UnicodeType))
self.assertTrue(isinstance(right, mitogen.core.UnicodeType))
self.assertEquals(left, u'dave')
self.assertEquals(sep, u'')
self.assertEquals(right, u'')
self.assertEqual(left, u'dave')
self.assertEqual(sep, u'')
self.assertEqual(right, u'')
def test_one_sep(self):
left, sep, right = self.func(u'davexdave', u'x')
self.assertTrue(isinstance(left, mitogen.core.UnicodeType))
self.assertTrue(isinstance(sep, mitogen.core.UnicodeType))
self.assertTrue(isinstance(right, mitogen.core.UnicodeType))
self.assertEquals(left, u'dave')
self.assertEquals(sep, u'x')
self.assertEquals(right, u'dave')
self.assertEqual(left, u'dave')
self.assertEqual(sep, u'x')
self.assertEqual(right, u'dave')
def test_two_seps(self):
left, sep, right = self.func(u'davexdavexdave', u'x')
self.assertTrue(isinstance(left, mitogen.core.UnicodeType))
self.assertTrue(isinstance(sep, mitogen.core.UnicodeType))
self.assertTrue(isinstance(right, mitogen.core.UnicodeType))
self.assertEquals(left, u'dave')
self.assertEquals(sep, u'x')
self.assertEquals(right, u'davexdave')
self.assertEqual(left, u'dave')
self.assertEqual(sep, u'x')
self.assertEqual(right, u'davexdave')
class StrRpartitionTest(testlib.TestCase):
@ -75,24 +75,24 @@ class StrRpartitionTest(testlib.TestCase):
self.assertTrue(isinstance(left, mitogen.core.UnicodeType))
self.assertTrue(isinstance(sep, mitogen.core.UnicodeType))
self.assertTrue(isinstance(right, mitogen.core.UnicodeType))
self.assertEquals(left, u'')
self.assertEquals(sep, u'')
self.assertEquals(right, u'dave')
self.assertEqual(left, u'')
self.assertEqual(sep, u'')
self.assertEqual(right, u'dave')
def test_one_sep(self):
left, sep, right = self.func(u'davexdave', u'x')
self.assertTrue(isinstance(left, mitogen.core.UnicodeType))
self.assertTrue(isinstance(sep, mitogen.core.UnicodeType))
self.assertTrue(isinstance(right, mitogen.core.UnicodeType))
self.assertEquals(left, u'dave')
self.assertEquals(sep, u'x')
self.assertEquals(right, u'dave')
self.assertEqual(left, u'dave')
self.assertEqual(sep, u'x')
self.assertEqual(right, u'dave')
def test_two_seps(self):
left, sep, right = self.func(u'davexdavexdave', u'x')
self.assertTrue(isinstance(left, mitogen.core.UnicodeType))
self.assertTrue(isinstance(sep, mitogen.core.UnicodeType))
self.assertTrue(isinstance(right, mitogen.core.UnicodeType))
self.assertEquals(left, u'davexdave')
self.assertEquals(sep, u'x')
self.assertEquals(right, u'dave')
self.assertEqual(left, u'davexdave')
self.assertEqual(sep, u'x')
self.assertEqual(right, u'dave')

@ -43,9 +43,9 @@ class PropagateToTest(testlib.RouterMixin, testlib.TestCase):
service.propagate_to(context=c2, path=path)
s = c1.call(wait_for_file, path=path)
self.assertEquals(b('test'), s)
self.assertEqual(b('test'), s)
s = c2.call(wait_for_file, path=path)
self.assertEquals(b('test'), s)
self.assertEqual(b('test'), s)
finally:
tf.close()

@ -14,13 +14,13 @@ class ReaperTest(testlib.TestCase):
proc = mock.Mock()
proc.poll.return_value = None
reaper = mitogen.parent.Reaper(broker, proc, True, True)
self.assertEquals(50, int(1000 * reaper._calc_delay(0)))
self.assertEquals(86, int(1000 * reaper._calc_delay(1)))
self.assertEquals(147, int(1000 * reaper._calc_delay(2)))
self.assertEquals(254, int(1000 * reaper._calc_delay(3)))
self.assertEquals(437, int(1000 * reaper._calc_delay(4)))
self.assertEquals(752, int(1000 * reaper._calc_delay(5)))
self.assertEquals(1294, int(1000 * reaper._calc_delay(6)))
self.assertEqual(50, int(1000 * reaper._calc_delay(0)))
self.assertEqual(86, int(1000 * reaper._calc_delay(1)))
self.assertEqual(147, int(1000 * reaper._calc_delay(2)))
self.assertEqual(254, int(1000 * reaper._calc_delay(3)))
self.assertEqual(437, int(1000 * reaper._calc_delay(4)))
self.assertEqual(752, int(1000 * reaper._calc_delay(5)))
self.assertEqual(1294, int(1000 * reaper._calc_delay(6)))
@mock.patch('os.kill')
def test_reap_calls(self, kill):
@ -31,20 +31,20 @@ class ReaperTest(testlib.TestCase):
reaper = mitogen.parent.Reaper(broker, proc, True, True)
reaper.reap()
self.assertEquals(0, kill.call_count)
self.assertEqual(0, kill.call_count)
reaper.reap()
self.assertEquals(1, kill.call_count)
self.assertEqual(1, kill.call_count)
reaper.reap()
reaper.reap()
reaper.reap()
self.assertEquals(1, kill.call_count)
self.assertEqual(1, kill.call_count)
reaper.reap()
self.assertEquals(2, kill.call_count)
self.assertEqual(2, kill.call_count)
self.assertEquals(kill.mock_calls, [
self.assertEqual(kill.mock_calls, [
mock.call(proc.pid, signal.SIGTERM),
mock.call(proc.pid, signal.SIGKILL),
])

@ -26,7 +26,7 @@ class ConstructorTest(testlib.RouterMixin, testlib.TestCase):
handle=recv.handle,
)
)
self.assertEquals('hi', recv.get().unpickle())
self.assertEqual('hi', recv.get().unpickle())
class IterationTest(testlib.RouterMixin, testlib.TestCase):
@ -34,8 +34,8 @@ class IterationTest(testlib.RouterMixin, testlib.TestCase):
recv = mitogen.core.Receiver(self.router)
fork = self.router.local()
ret = fork.call_async(yield_stuff_then_die, recv.to_sender())
self.assertEquals(list(range(5)), list(m.unpickle() for m in recv))
self.assertEquals(10, ret.get().unpickle())
self.assertEqual(list(range(5)), list(m.unpickle() for m in recv))
self.assertEqual(10, ret.get().unpickle())
def iter_and_put(self, recv, latch):
try:
@ -76,7 +76,7 @@ class CloseTest(testlib.RouterMixin, testlib.TestCase):
raise latch.get()
t.join()
e = self.assertRaises(mitogen.core.ChannelError, throw)
self.assertEquals(e.args[0], mitogen.core.Receiver.closed_msg)
self.assertEqual(e.args[0], mitogen.core.Receiver.closed_msg)
def test_closes_all(self):
latch = mitogen.core.Latch()
@ -92,7 +92,7 @@ class CloseTest(testlib.RouterMixin, testlib.TestCase):
raise latch.get()
for x in range(5):
e = self.assertRaises(mitogen.core.ChannelError, throw)
self.assertEquals(e.args[0], mitogen.core.Receiver.closed_msg)
self.assertEqual(e.args[0], mitogen.core.Receiver.closed_msg)
for t in ts:
t.join()
@ -118,7 +118,7 @@ class OnReceiveTest(testlib.RouterMixin, testlib.TestCase):
raise latch.get()
t.join()
e = self.assertRaises(mitogen.core.ChannelError, throw)
self.assertEquals(e.args[0], sender.explicit_close_msg)
self.assertEqual(e.args[0], sender.explicit_close_msg)
@unittest.skip(reason=(
'Unclear if a asingle dead message received from remote should '
@ -139,7 +139,7 @@ class OnReceiveTest(testlib.RouterMixin, testlib.TestCase):
raise latch.get()
for x in range(5):
e = self.assertRaises(mitogen.core.ChannelError, throw)
self.assertEquals(e.args[0], mitogen.core.Receiver.closed_msg)
self.assertEqual(e.args[0], mitogen.core.Receiver.closed_msg)
for t in ts:
t.join()
@ -152,4 +152,4 @@ class ToSenderTest(testlib.RouterMixin, testlib.TestCase):
def test_returned_context(self):
myself = self.router.myself()
recv = self.klass(self.router)
self.assertEquals(myself, recv.to_sender().context)
self.assertEqual(myself, recv.to_sender().context)

@ -24,7 +24,7 @@ class NeutralizeMainTest(testlib.RouterMixin, testlib.TestCase):
args = [sys.executable, path]
proc = subprocess.Popen(args, stderr=subprocess.PIPE)
_, stderr = proc.communicate()
self.assertEquals(1, proc.returncode)
self.assertEqual(1, proc.returncode)
expect = self.klass.main_guard_msg % (path,)
self.assertTrue(expect in stderr.decode())
@ -43,7 +43,7 @@ class NeutralizeMainTest(testlib.RouterMixin, testlib.TestCase):
def test_mitogen_main(self):
untouched = self.call("derp.py", self.HAS_MITOGEN_MAIN)
self.assertEquals(untouched, self.HAS_MITOGEN_MAIN)
self.assertEqual(untouched, self.HAS_MITOGEN_MAIN)
HAS_EXEC_GUARD = mitogen.core.b(
textwrap.dedent("""
@ -63,7 +63,7 @@ class NeutralizeMainTest(testlib.RouterMixin, testlib.TestCase):
def test_exec_guard(self):
touched = self.call("derp.py", self.HAS_EXEC_GUARD)
bits = touched.decode().split()
self.assertEquals(bits[-3:], ['def', 'main():', 'pass'])
self.assertEqual(bits[-3:], ['def', 'main():', 'pass'])
class GoodModulesTest(testlib.RouterMixin, testlib.TestCase):
@ -72,22 +72,22 @@ class GoodModulesTest(testlib.RouterMixin, testlib.TestCase):
# package machinery damage.
context = self.router.local()
self.assertEquals(256, context.call(plain_old_module.pow, 2, 8))
self.assertEqual(256, context.call(plain_old_module.pow, 2, 8))
os_fork = int(sys.version_info < (2, 6)) # mitogen.os_fork
self.assertEquals(1+os_fork, self.router.responder.get_module_count)
self.assertEquals(1+os_fork, self.router.responder.good_load_module_count)
self.assertEqual(1+os_fork, self.router.responder.get_module_count)
self.assertEqual(1+os_fork, self.router.responder.good_load_module_count)
self.assertLess(300, self.router.responder.good_load_module_size)
def test_simple_pkg(self):
# Ensure success of a simple package containing two submodules, one of
# which imports the other.
context = self.router.local()
self.assertEquals(3,
self.assertEqual(3,
context.call(simple_pkg.a.subtract_one_add_two, 2))
os_fork = int(sys.version_info < (2, 6)) # mitogen.os_fork
self.assertEquals(2+os_fork, self.router.responder.get_module_count)
self.assertEquals(3+os_fork, self.router.responder.good_load_module_count)
self.assertEquals(0, self.router.responder.bad_load_module_count)
self.assertEqual(2+os_fork, self.router.responder.get_module_count)
self.assertEqual(3+os_fork, self.router.responder.good_load_module_count)
self.assertEqual(0, self.router.responder.bad_load_module_count)
self.assertLess(450, self.router.responder.good_load_module_size)
def test_self_contained_program(self):
@ -95,7 +95,7 @@ class GoodModulesTest(testlib.RouterMixin, testlib.TestCase):
# successfully.
args = [sys.executable, testlib.data_path('self_contained_program.py')]
output = testlib.subprocess__check_output(args).decode()
self.assertEquals(output, "['__main__', 50]\n")
self.assertEqual(output, "['__main__', 50]\n")
class BrokenModulesTest(testlib.TestCase):
@ -116,17 +116,17 @@ class BrokenModulesTest(testlib.TestCase):
responder = mitogen.master.ModuleResponder(router)
responder._on_get_module(msg)
self.assertEquals(1, len(router._async_route.mock_calls))
self.assertEqual(1, len(router._async_route.mock_calls))
self.assertEquals(1, responder.get_module_count)
self.assertEquals(0, responder.good_load_module_count)
self.assertEquals(0, responder.good_load_module_size)
self.assertEquals(1, responder.bad_load_module_count)
self.assertEqual(1, responder.get_module_count)
self.assertEqual(0, responder.good_load_module_count)
self.assertEqual(0, responder.good_load_module_size)
self.assertEqual(1, responder.bad_load_module_count)
call = router._async_route.mock_calls[0]
msg, = call[1]
self.assertEquals(mitogen.core.LOAD_MODULE, msg.handle)
self.assertEquals(('non_existent_module', None, None, None, ()),
self.assertEqual(mitogen.core.LOAD_MODULE, msg.handle)
self.assertEqual(('non_existent_module', None, None, None, ()),
msg.unpickle())
@unittest.skipIf(
@ -154,15 +154,15 @@ class BrokenModulesTest(testlib.TestCase):
responder = mitogen.master.ModuleResponder(router)
responder._on_get_module(msg)
self.assertEquals(1, len(router._async_route.mock_calls))
self.assertEqual(1, len(router._async_route.mock_calls))
self.assertEquals(1, responder.get_module_count)
self.assertEquals(1, responder.good_load_module_count)
self.assertEquals(0, responder.bad_load_module_count)
self.assertEqual(1, responder.get_module_count)
self.assertEqual(1, responder.good_load_module_count)
self.assertEqual(0, responder.bad_load_module_count)
call = router._async_route.mock_calls[0]
msg, = call[1]
self.assertEquals(mitogen.core.LOAD_MODULE, msg.handle)
self.assertEqual(mitogen.core.LOAD_MODULE, msg.handle)
tup = msg.unpickle()
self.assertIsInstance(tup, tuple)
@ -188,9 +188,9 @@ class ForwardTest(testlib.RouterMixin, testlib.TestCase):
c2 = self.router.local(via=c1)
os_fork = int(sys.version_info < (2, 6))
self.assertEquals(256, c2.call(plain_old_module.pow, 2, 8))
self.assertEquals(2+os_fork, self.router.responder.get_module_count)
self.assertEquals(2+os_fork, self.router.responder.good_load_module_count)
self.assertEqual(256, c2.call(plain_old_module.pow, 2, 8))
self.assertEqual(2+os_fork, self.router.responder.get_module_count)
self.assertEqual(2+os_fork, self.router.responder.good_load_module_count)
self.assertLess(10000, self.router.responder.good_load_module_size)
self.assertGreater(40000, self.router.responder.good_load_module_size)

@ -97,7 +97,7 @@ class SourceVerifyTest(testlib.RouterMixin, testlib.TestCase):
e = self.assertRaises(mitogen.core.ChannelError,
lambda: recv.get().unpickle()
)
self.assertEquals(e.args[0], self.router.no_route_msg % (
self.assertEqual(e.args[0], self.router.no_route_msg % (
1234,
c1.context_id,
))
@ -136,7 +136,7 @@ class PolicyTest(testlib.RouterMixin, testlib.TestCase):
recv.to_sender().send(123)
self.sync_with_broker()
self.assertFalse(recv.empty())
self.assertEquals(123, recv.get().unpickle())
self.assertEqual(123, recv.get().unpickle())
def test_refuse_all(self):
# Deliver a message locally from child2 with the correct auth_id, but
@ -174,7 +174,7 @@ class PolicyTest(testlib.RouterMixin, testlib.TestCase):
# Verify CallError received by reply_to target.
e = self.assertRaises(mitogen.core.ChannelError,
lambda: reply_target.get().unpickle())
self.assertEquals(e.args[0], self.router.refused_msg)
self.assertEqual(e.args[0], self.router.refused_msg)
class CrashTest(testlib.BrokerMixin, testlib.TestCase):
@ -225,7 +225,7 @@ class AddHandlerTest(testlib.TestCase):
router.add_handler((lambda: None), handle=1234)
e = self.assertRaises(mitogen.core.Error,
lambda: router.add_handler((lambda: None), handle=1234))
self.assertEquals(router.duplicate_handle_msg, e.args[0])
self.assertEqual(router.duplicate_handle_msg, e.args[0])
router.del_handler(1234)
finally:
router.broker.shutdown()
@ -246,9 +246,9 @@ class AddHandlerTest(testlib.TestCase):
class MyselfTest(testlib.RouterMixin, testlib.TestCase):
def test_myself(self):
myself = self.router.myself()
self.assertEquals(myself.context_id, mitogen.context_id)
self.assertEqual(myself.context_id, mitogen.context_id)
# TODO: context should know its own name too.
self.assertEquals(myself.name, 'self')
self.assertEqual(myself.name, 'self')
class MessageSizeTest(testlib.BrokerMixin, testlib.TestCase):
@ -281,7 +281,7 @@ class MessageSizeTest(testlib.BrokerMixin, testlib.TestCase):
child = router.local()
e = self.assertRaises(mitogen.core.ChannelError,
lambda: child.call(zlib.crc32, ' '*8192))
self.assertEquals(e.args[0], expect)
self.assertEqual(e.args[0], expect)
self.assertTrue(expect in logs.stop())
@ -300,20 +300,20 @@ class MessageSizeTest(testlib.BrokerMixin, testlib.TestCase):
lambda: recv.get().unpickle()
)
expect = router.too_large_msg % (4096,)
self.assertEquals(e.args[0], expect)
self.assertEqual(e.args[0], expect)
def test_remote_configured(self):
router = self.klass(broker=self.broker, max_message_size=64*1024)
remote = router.local()
size = remote.call(return_router_max_message_size)
self.assertEquals(size, 64*1024)
self.assertEqual(size, 64*1024)
def test_remote_of_remote_configured(self):
router = self.klass(broker=self.broker, max_message_size=64*1024)
remote = router.local()
remote2 = router.local(via=remote)
size = remote2.call(return_router_max_message_size)
self.assertEquals(size, 64*1024)
self.assertEqual(size, 64*1024)
def test_remote_exceeded(self):
# Ensure new contexts receive a router with the same value.
@ -336,14 +336,14 @@ class NoRouteTest(testlib.RouterMixin, testlib.TestCase):
l1 = self.router.local()
recv = l1.send_async(mitogen.core.Message(handle=999))
msg = recv.get(throw_dead=False)
self.assertEquals(msg.is_dead, True)
self.assertEquals(msg.src_id, l1.context_id)
self.assertEquals(msg.data, self.router.invalid_handle_msg.encode())
self.assertEqual(msg.is_dead, True)
self.assertEqual(msg.src_id, l1.context_id)
self.assertEqual(msg.data, self.router.invalid_handle_msg.encode())
recv = l1.send_async(mitogen.core.Message(handle=999))
e = self.assertRaises(mitogen.core.ChannelError,
lambda: recv.get())
self.assertEquals(e.args[0], self.router.invalid_handle_msg)
self.assertEqual(e.args[0], self.router.invalid_handle_msg)
def test_totally_invalid_context_returns_dead(self):
recv = mitogen.core.Receiver(self.router)
@ -354,9 +354,9 @@ class NoRouteTest(testlib.RouterMixin, testlib.TestCase):
)
self.router.route(msg)
rmsg = recv.get(throw_dead=False)
self.assertEquals(rmsg.is_dead, True)
self.assertEquals(rmsg.src_id, mitogen.context_id)
self.assertEquals(rmsg.data, (self.router.no_route_msg % (
self.assertEqual(rmsg.is_dead, True)
self.assertEqual(rmsg.src_id, mitogen.context_id)
self.assertEqual(rmsg.data, (self.router.no_route_msg % (
1234,
mitogen.context_id,
)).encode())
@ -364,7 +364,7 @@ class NoRouteTest(testlib.RouterMixin, testlib.TestCase):
self.router.route(msg)
e = self.assertRaises(mitogen.core.ChannelError,
lambda: recv.get())
self.assertEquals(e.args[0], (self.router.no_route_msg % (
self.assertEqual(e.args[0], (self.router.no_route_msg % (
1234,
mitogen.context_id,
)))
@ -380,9 +380,9 @@ class NoRouteTest(testlib.RouterMixin, testlib.TestCase):
)
self.router.route(msg)
rmsg = recv.get(throw_dead=False)
self.assertEquals(rmsg.is_dead, True)
self.assertEquals(rmsg.src_id, mitogen.context_id)
self.assertEquals(rmsg.data, (self.router.no_route_msg % (
self.assertEqual(rmsg.is_dead, True)
self.assertEqual(rmsg.src_id, mitogen.context_id)
self.assertEqual(rmsg.data, (self.router.no_route_msg % (
l1.context_id,
mitogen.context_id,
)).encode())
@ -390,7 +390,7 @@ class NoRouteTest(testlib.RouterMixin, testlib.TestCase):
self.router.route(msg)
e = self.assertRaises(mitogen.core.ChannelError,
lambda: recv.get())
self.assertEquals(e.args[0], self.router.no_route_msg % (
self.assertEqual(e.args[0], self.router.no_route_msg % (
l1.context_id,
mitogen.context_id,
))
@ -465,7 +465,7 @@ class EgressIdsTest(testlib.RouterMixin, testlib.TestCase):
# causes messages to be sent.
pass
self.assertEquals(c1s.protocol.egress_ids, set([
self.assertEqual(c1s.protocol.egress_ids, set([
mitogen.context_id,
c2.context_id,
]))
@ -496,11 +496,11 @@ class ShutdownTest(testlib.RouterMixin, testlib.TestCase):
e = self.assertRaises(OSError,
lambda: os.waitpid(pid, 0))
self.assertEquals(e.args[0], errno.ECHILD)
self.assertEqual(e.args[0], errno.ECHILD)
e = self.assertRaises(mitogen.core.ChannelError,
lambda: l1.call(os.getpid))
self.assertEquals(e.args[0], mitogen.core.Router.no_route_msg % (
self.assertEqual(e.args[0], mitogen.core.Router.no_route_msg % (
l1.context_id,
mitogen.context_id,
))
@ -518,11 +518,11 @@ class ShutdownTest(testlib.RouterMixin, testlib.TestCase):
e = self.assertRaises(OSError,
lambda: os.waitpid(pid, 0))
self.assertEquals(e.args[0], errno.ECHILD)
self.assertEqual(e.args[0], errno.ECHILD)
e = self.assertRaises(mitogen.core.ChannelError,
lambda: l1.call(os.getpid))
self.assertEquals(e.args[0], mitogen.core.Router.no_route_msg % (
self.assertEqual(e.args[0], mitogen.core.Router.no_route_msg % (
l1.context_id,
mitogen.context_id,
))
@ -545,11 +545,11 @@ class ShutdownTest(testlib.RouterMixin, testlib.TestCase):
e = self.assertRaises(OSError,
lambda: os.waitpid(pid, 0))
self.assertEquals(e.args[0], errno.ECHILD)
self.assertEqual(e.args[0], errno.ECHILD)
e = self.assertRaises(mitogen.core.ChannelError,
lambda: l1.call(os.getpid))
self.assertEquals(e.args[0], mitogen.core.Router.no_route_msg % (
self.assertEqual(e.args[0], mitogen.core.Router.no_route_msg % (
l1.context_id,
mitogen.context_id,
))
@ -572,12 +572,12 @@ class ShutdownTest(testlib.RouterMixin, testlib.TestCase):
for pid in pids:
e = self.assertRaises(OSError,
lambda: os.waitpid(pid, 0))
self.assertEquals(e.args[0], errno.ECHILD)
self.assertEqual(e.args[0], errno.ECHILD)
for ctx in l1, l2:
e = self.assertRaises(mitogen.core.ChannelError,
lambda: ctx.call(os.getpid))
self.assertEquals(e.args[0], mitogen.core.Router.no_route_msg % (
self.assertEqual(e.args[0], mitogen.core.Router.no_route_msg % (
ctx.context_id,
mitogen.context_id,
))

@ -15,7 +15,7 @@ class BoolTest(testlib.RouterMixin, testlib.TestCase):
latch.put(123)
self.assertTrue(select)
self.assertEquals(123, select.get())
self.assertEqual(123, select.get())
self.assertFalse(select)
def test_receiver(self):
@ -27,7 +27,7 @@ class BoolTest(testlib.RouterMixin, testlib.TestCase):
recv._on_receive(mitogen.core.Message.pickled('123'))
self.assertTrue(select)
self.assertEquals('123', select.get().unpickle())
self.assertEqual('123', select.get().unpickle())
self.assertFalse(select)
@ -38,34 +38,34 @@ class AddTest(testlib.RouterMixin, testlib.TestCase):
latch = mitogen.core.Latch()
select = self.klass()
select.add(latch)
self.assertEquals(1, len(select._receivers))
self.assertEquals(latch, select._receivers[0])
self.assertEquals(select._put, latch.notify)
self.assertEqual(1, len(select._receivers))
self.assertEqual(latch, select._receivers[0])
self.assertEqual(select._put, latch.notify)
def test_receiver(self):
recv = mitogen.core.Receiver(self.router)
select = self.klass()
select.add(recv)
self.assertEquals(1, len(select._receivers))
self.assertEquals(recv, select._receivers[0])
self.assertEquals(select._put, recv.notify)
self.assertEqual(1, len(select._receivers))
self.assertEqual(recv, select._receivers[0])
self.assertEqual(select._put, recv.notify)
def test_channel(self):
context = self.router.local()
chan = mitogen.core.Channel(self.router, context, 1234)
select = self.klass()
select.add(chan)
self.assertEquals(1, len(select._receivers))
self.assertEquals(chan, select._receivers[0])
self.assertEquals(select._put, chan.notify)
self.assertEqual(1, len(select._receivers))
self.assertEqual(chan, select._receivers[0])
self.assertEqual(select._put, chan.notify)
def test_subselect_empty(self):
select = self.klass()
subselect = self.klass()
select.add(subselect)
self.assertEquals(1, len(select._receivers))
self.assertEquals(subselect, select._receivers[0])
self.assertEquals(select._put, subselect.notify)
self.assertEqual(1, len(select._receivers))
self.assertEqual(subselect, select._receivers[0])
self.assertEqual(select._put, subselect.notify)
def test_subselect_nonempty(self):
recv = mitogen.core.Receiver(self.router)
@ -74,15 +74,15 @@ class AddTest(testlib.RouterMixin, testlib.TestCase):
subselect.add(recv)
select.add(subselect)
self.assertEquals(1, len(select._receivers))
self.assertEquals(subselect, select._receivers[0])
self.assertEquals(select._put, subselect.notify)
self.assertEqual(1, len(select._receivers))
self.assertEqual(subselect, select._receivers[0])
self.assertEqual(select._put, subselect.notify)
def test_subselect_loop_direct(self):
select = self.klass()
exc = self.assertRaises(mitogen.select.Error,
lambda: select.add(select))
self.assertEquals(str(exc), self.klass.loop_msg)
self.assertEqual(str(exc), self.klass.loop_msg)
def test_subselect_loop_indirect(self):
s0 = self.klass()
@ -93,7 +93,7 @@ class AddTest(testlib.RouterMixin, testlib.TestCase):
s1.add(s2)
exc = self.assertRaises(mitogen.select.Error,
lambda: s2.add(s0))
self.assertEquals(str(exc), self.klass.loop_msg)
self.assertEqual(str(exc), self.klass.loop_msg)
def test_double_add_receiver(self):
select = self.klass()
@ -101,7 +101,7 @@ class AddTest(testlib.RouterMixin, testlib.TestCase):
select.add(recv)
exc = self.assertRaises(mitogen.select.Error,
lambda: select.add(recv))
self.assertEquals(str(exc), self.klass.owned_msg)
self.assertEqual(str(exc), self.klass.owned_msg)
def test_double_add_subselect(self):
select = self.klass()
@ -109,7 +109,7 @@ class AddTest(testlib.RouterMixin, testlib.TestCase):
select.add(select2)
exc = self.assertRaises(mitogen.select.Error,
lambda: select.add(select2))
self.assertEquals(str(exc), self.klass.owned_msg)
self.assertEqual(str(exc), self.klass.owned_msg)
class RemoveTest(testlib.RouterMixin, testlib.TestCase):
@ -120,7 +120,7 @@ class RemoveTest(testlib.RouterMixin, testlib.TestCase):
recv = mitogen.core.Receiver(self.router)
exc = self.assertRaises(mitogen.select.Error,
lambda: select.remove(recv))
self.assertEquals(str(exc), self.klass.not_present_msg)
self.assertEqual(str(exc), self.klass.not_present_msg)
def test_receiver_absent(self):
select = self.klass()
@ -129,22 +129,22 @@ class RemoveTest(testlib.RouterMixin, testlib.TestCase):
select.add(recv2)
exc = self.assertRaises(mitogen.select.Error,
lambda: select.remove(recv))
self.assertEquals(str(exc), self.klass.not_present_msg)
self.assertEqual(str(exc), self.klass.not_present_msg)
def test_receiver_present(self):
select = self.klass()
recv = mitogen.core.Receiver(self.router)
select.add(recv)
select.remove(recv)
self.assertEquals(0, len(select._receivers))
self.assertEquals(None, recv.notify)
self.assertEqual(0, len(select._receivers))
self.assertEqual(None, recv.notify)
def test_latch_empty(self):
select = self.klass()
latch = mitogen.core.Latch()
exc = self.assertRaises(mitogen.select.Error,
lambda: select.remove(latch))
self.assertEquals(str(exc), self.klass.not_present_msg)
self.assertEqual(str(exc), self.klass.not_present_msg)
def test_latch_absent(self):
select = self.klass()
@ -153,15 +153,15 @@ class RemoveTest(testlib.RouterMixin, testlib.TestCase):
select.add(latch2)
exc = self.assertRaises(mitogen.select.Error,
lambda: select.remove(latch))
self.assertEquals(str(exc), self.klass.not_present_msg)
self.assertEqual(str(exc), self.klass.not_present_msg)
def test_latch_present(self):
select = self.klass()
latch = mitogen.core.Latch()
select.add(latch)
select.remove(latch)
self.assertEquals(0, len(select._receivers))
self.assertEquals(None, latch.notify)
self.assertEqual(0, len(select._receivers))
self.assertEqual(None, latch.notify)
class CloseTest(testlib.RouterMixin, testlib.TestCase):
@ -176,24 +176,24 @@ class CloseTest(testlib.RouterMixin, testlib.TestCase):
latch = mitogen.core.Latch()
select.add(latch)
self.assertEquals(1, len(select._receivers))
self.assertEquals(select._put, latch.notify)
self.assertEqual(1, len(select._receivers))
self.assertEqual(select._put, latch.notify)
select.close()
self.assertEquals(0, len(select._receivers))
self.assertEquals(None, latch.notify)
self.assertEqual(0, len(select._receivers))
self.assertEqual(None, latch.notify)
def test_one_receiver(self):
select = self.klass()
recv = mitogen.core.Receiver(self.router)
select.add(recv)
self.assertEquals(1, len(select._receivers))
self.assertEquals(select._put, recv.notify)
self.assertEqual(1, len(select._receivers))
self.assertEqual(select._put, recv.notify)
select.close()
self.assertEquals(0, len(select._receivers))
self.assertEquals(None, recv.notify)
self.assertEqual(0, len(select._receivers))
self.assertEqual(None, recv.notify)
def test_one_subselect(self):
select = self.klass()
@ -203,16 +203,16 @@ class CloseTest(testlib.RouterMixin, testlib.TestCase):
recv = mitogen.core.Receiver(self.router)
subselect.add(recv)
self.assertEquals(1, len(select._receivers))
self.assertEquals(subselect._put, recv.notify)
self.assertEqual(1, len(select._receivers))
self.assertEqual(subselect._put, recv.notify)
select.close()
self.assertEquals(0, len(select._receivers))
self.assertEquals(subselect._put, recv.notify)
self.assertEqual(0, len(select._receivers))
self.assertEqual(subselect._put, recv.notify)
subselect.close()
self.assertEquals(None, recv.notify)
self.assertEqual(None, recv.notify)
class EmptyTest(testlib.RouterMixin, testlib.TestCase):
@ -262,20 +262,20 @@ class IterTest(testlib.RouterMixin, testlib.TestCase):
def test_empty(self):
select = self.klass()
self.assertEquals([], list(select))
self.assertEqual([], list(select))
def test_nonempty_receiver(self):
recv = mitogen.core.Receiver(self.router)
select = self.klass([recv])
msg = mitogen.core.Message.pickled('123')
recv._on_receive(msg)
self.assertEquals([msg], list(select))
self.assertEqual([msg], list(select))
def test_nonempty_latch(self):
latch = mitogen.core.Latch()
select = self.klass([latch])
latch.put(123)
self.assertEquals([123], list(select))
self.assertEqual([123], list(select))
class OneShotTest(testlib.RouterMixin, testlib.TestCase):
@ -287,9 +287,9 @@ class OneShotTest(testlib.RouterMixin, testlib.TestCase):
msg = mitogen.core.Message.pickled('123')
recv._on_receive(msg)
msg_ = select.get()
self.assertEquals(msg, msg_)
self.assertEquals(0, len(select._receivers))
self.assertEquals(None, recv.notify)
self.assertEqual(msg, msg_)
self.assertEqual(0, len(select._receivers))
self.assertEqual(None, recv.notify)
def test_false_receiver_persists_after_get(self):
recv = mitogen.core.Receiver(self.router)
@ -297,28 +297,28 @@ class OneShotTest(testlib.RouterMixin, testlib.TestCase):
msg = mitogen.core.Message.pickled('123')
recv._on_receive(msg)
self.assertEquals(msg, select.get())
self.assertEquals(1, len(select._receivers))
self.assertEquals(recv, select._receivers[0])
self.assertEquals(select._put, recv.notify)
self.assertEqual(msg, select.get())
self.assertEqual(1, len(select._receivers))
self.assertEqual(recv, select._receivers[0])
self.assertEqual(select._put, recv.notify)
def test_true_latch_removed_after_get(self):
latch = mitogen.core.Latch()
select = self.klass([latch])
latch.put(123)
self.assertEquals(123, select.get())
self.assertEquals(0, len(select._receivers))
self.assertEquals(None, latch.notify)
self.assertEqual(123, select.get())
self.assertEqual(0, len(select._receivers))
self.assertEqual(None, latch.notify)
def test_false_latch_persists_after_get(self):
latch = mitogen.core.Latch()
select = self.klass([latch], oneshot=False)
latch.put(123)
self.assertEquals(123, select.get())
self.assertEquals(1, len(select._receivers))
self.assertEquals(latch, select._receivers[0])
self.assertEquals(select._put, latch.notify)
self.assertEqual(123, select.get())
self.assertEqual(1, len(select._receivers))
self.assertEqual(latch, select._receivers[0])
self.assertEqual(select._put, latch.notify)
class GetReceiverTest(testlib.RouterMixin, testlib.TestCase):
@ -328,13 +328,13 @@ class GetReceiverTest(testlib.RouterMixin, testlib.TestCase):
select = self.klass()
exc = self.assertRaises(mitogen.select.Error,
lambda: select.get())
self.assertEquals(str(exc), self.klass.empty_msg)
self.assertEqual(str(exc), self.klass.empty_msg)
def test_timeout_no_receivers(self):
select = self.klass()
exc = self.assertRaises(mitogen.select.Error,
lambda: select.get(timeout=1.0))
self.assertEquals(str(exc), self.klass.empty_msg)
self.assertEqual(str(exc), self.klass.empty_msg)
def test_zero_timeout(self):
recv = mitogen.core.Receiver(self.router)
@ -353,7 +353,7 @@ class GetReceiverTest(testlib.RouterMixin, testlib.TestCase):
recv._on_receive(mitogen.core.Message.pickled('123'))
select = self.klass([recv])
msg = select.get()
self.assertEquals('123', msg.unpickle())
self.assertEqual('123', msg.unpickle())
def test_nonempty_multiple_items_before_add(self):
recv = mitogen.core.Receiver(self.router)
@ -361,9 +361,9 @@ class GetReceiverTest(testlib.RouterMixin, testlib.TestCase):
recv._on_receive(mitogen.core.Message.pickled('234'))
select = self.klass([recv], oneshot=False)
msg = select.get()
self.assertEquals('123', msg.unpickle())
self.assertEqual('123', msg.unpickle())
msg = select.get()
self.assertEquals('234', msg.unpickle())
self.assertEqual('234', msg.unpickle())
self.assertRaises(mitogen.core.TimeoutError,
lambda: select.get(block=False))
@ -372,21 +372,21 @@ class GetReceiverTest(testlib.RouterMixin, testlib.TestCase):
select = self.klass([recv])
recv._on_receive(mitogen.core.Message.pickled('123'))
msg = select.get()
self.assertEquals('123', msg.unpickle())
self.assertEqual('123', msg.unpickle())
def test_nonempty_receiver_attr_set(self):
recv = mitogen.core.Receiver(self.router)
select = self.klass([recv])
recv._on_receive(mitogen.core.Message.pickled('123'))
msg = select.get()
self.assertEquals(msg.receiver, recv)
self.assertEqual(msg.receiver, recv)
def test_drained_by_other_thread(self):
recv = mitogen.core.Receiver(self.router)
recv._on_receive(mitogen.core.Message.pickled('123'))
select = self.klass([recv])
msg = recv.get()
self.assertEquals('123', msg.unpickle())
self.assertEqual('123', msg.unpickle())
self.assertRaises(mitogen.core.TimeoutError,
lambda: select.get(timeout=0.0))
@ -398,13 +398,13 @@ class GetLatchTest(testlib.RouterMixin, testlib.TestCase):
select = self.klass()
exc = self.assertRaises(mitogen.select.Error,
lambda: select.get())
self.assertEquals(str(exc), self.klass.empty_msg)
self.assertEqual(str(exc), self.klass.empty_msg)
def test_timeout_no_receivers(self):
select = self.klass()
exc = self.assertRaises(mitogen.select.Error,
lambda: select.get(timeout=1.0))
self.assertEquals(str(exc), self.klass.empty_msg)
self.assertEqual(str(exc), self.klass.empty_msg)
def test_zero_timeout(self):
latch = mitogen.core.Latch()
@ -422,15 +422,15 @@ class GetLatchTest(testlib.RouterMixin, testlib.TestCase):
latch = mitogen.core.Latch()
latch.put(123)
select = self.klass([latch])
self.assertEquals(123, select.get())
self.assertEqual(123, select.get())
def test_nonempty_multiple_items_before_add(self):
latch = mitogen.core.Latch()
latch.put(123)
latch.put(234)
select = self.klass([latch], oneshot=False)
self.assertEquals(123, select.get())
self.assertEquals(234, select.get())
self.assertEqual(123, select.get())
self.assertEqual(234, select.get())
self.assertRaises(mitogen.core.TimeoutError,
lambda: select.get(block=False))
@ -438,13 +438,13 @@ class GetLatchTest(testlib.RouterMixin, testlib.TestCase):
latch = mitogen.core.Latch()
select = self.klass([latch])
latch.put(123)
self.assertEquals(123, latch.get())
self.assertEqual(123, latch.get())
def test_drained_by_other_thread(self):
latch = mitogen.core.Latch()
latch.put(123)
select = self.klass([latch])
self.assertEquals(123, latch.get())
self.assertEqual(123, latch.get())
self.assertRaises(mitogen.core.TimeoutError,
lambda: select.get(timeout=0.0))
@ -456,20 +456,20 @@ class GetEventTest(testlib.RouterMixin, testlib.TestCase):
select = self.klass()
exc = self.assertRaises(mitogen.select.Error,
lambda: select.get())
self.assertEquals(str(exc), self.klass.empty_msg)
self.assertEqual(str(exc), self.klass.empty_msg)
def test_latch(self):
latch = mitogen.core.Latch()
latch.put(123)
select = self.klass([latch])
event = select.get_event()
self.assertEquals(latch, event.source)
self.assertEquals(123, event.data)
self.assertEqual(latch, event.source)
self.assertEqual(123, event.data)
def test_receiver(self):
recv = mitogen.core.Receiver(self.router)
recv._on_receive(mitogen.core.Message.pickled('123'))
select = self.klass([recv])
event = select.get_event()
self.assertEquals(recv, event.source)
self.assertEquals('123', event.data.unpickle())
self.assertEqual(recv, event.source)
self.assertEqual('123', event.data.unpickle())

@ -43,7 +43,7 @@ def call_service_in(context, service_name, method_name):
class CallTest(testlib.RouterMixin, testlib.TestCase):
def test_local(self):
pool = mitogen.service.get_or_create_pool(router=self.router)
self.assertEquals(
self.assertEqual(
'privileged!',
mitogen.service.call(MyService, 'privileged_op')
)
@ -63,7 +63,7 @@ class CallTest(testlib.RouterMixin, testlib.TestCase):
def test_local_unicode(self):
pool = mitogen.service.get_or_create_pool(router=self.router)
self.assertEquals(
self.assertEqual(
'privileged!',
mitogen.service.call(MyService.name(), 'privileged_op')
)
@ -71,7 +71,7 @@ class CallTest(testlib.RouterMixin, testlib.TestCase):
def test_remote(self):
c1 = self.router.local()
self.assertEquals(
self.assertEqual(
'privileged!',
mitogen.service.call(MyService, 'privileged_op',
call_context=c1)
@ -82,7 +82,7 @@ class ActivationTest(testlib.RouterMixin, testlib.TestCase):
def test_parent_can_activate(self):
l1 = self.router.local()
counter, id_ = l1.call_service(MyService, 'get_id')
self.assertEquals(1, counter)
self.assertEqual(1, counter)
self.assertTrue(isinstance(id_, int))
def test_sibling_cannot_activate_framework(self):
@ -110,9 +110,9 @@ class ActivationTest(testlib.RouterMixin, testlib.TestCase):
l1 = self.router.local()
counter, id_ = l1.call_service(MyService, 'get_id')
counter2, id_2 = l1.call_service(MyService, 'get_id')
self.assertEquals(1, counter)
self.assertEquals(2, counter2)
self.assertEquals(id_, id_2)
self.assertEqual(1, counter)
self.assertEqual(2, counter2)
self.assertEqual(id_, id_2)
class PermissionTest(testlib.RouterMixin, testlib.TestCase):
@ -120,7 +120,7 @@ class PermissionTest(testlib.RouterMixin, testlib.TestCase):
l1 = self.router.local()
l1.call_service(MyService, 'get_id')
l2 = self.router.local()
self.assertEquals('unprivileged!',
self.assertEqual('unprivileged!',
l2.call(call_service_in, l1, MyService.name(), 'unprivileged_op'))
def test_sibling_privileged_bad(self):
@ -147,8 +147,8 @@ class CloseTest(testlib.RouterMixin, testlib.TestCase):
def test_receiver_closed(self):
pool = self.klass(router=self.router, services=[])
pool.stop()
self.assertEquals(None, pool._receiver.handle)
self.assertEqual(None, pool._receiver.handle)
e = self.assertRaises(mitogen.core.ChannelError,
lambda: self.router.myself().call_service(MyService, 'foobar'))
self.assertEquals(e.args[0], self.router.invalid_handle_msg)
self.assertEqual(e.args[0], self.router.invalid_handle_msg)

@ -30,7 +30,7 @@ import testlib
# via=root,
# )
# self.assertEquals(
# self.assertEqual(
# via_ssh.call(socket.gethostname),
# via_setns.call(socket.gethostname),
# )

@ -15,7 +15,7 @@ class ListenFireTest(testlib.TestCase):
lambda: latch.put('event fired'))
mitogen.core.fire(thing, 'event')
self.assertEquals('event fired', latch.get())
self.assertEqual('event fired', latch.get())
self.assertTrue(latch.empty())
def test_with_args(self):
@ -23,7 +23,7 @@ class ListenFireTest(testlib.TestCase):
latch = mitogen.core.Latch()
mitogen.core.listen(thing, 'event', latch.put)
mitogen.core.fire(thing, 'event', 'event fired')
self.assertEquals('event fired', latch.get())
self.assertEqual('event fired', latch.get())
self.assertTrue(latch.empty())
def test_two_listeners(self):
@ -33,7 +33,7 @@ class ListenFireTest(testlib.TestCase):
mitogen.core.listen(thing, 'event', latch.put)
mitogen.core.listen(thing, 'event', latch2.put)
mitogen.core.fire(thing, 'event', 'event fired')
self.assertEquals('event fired', latch.get())
self.assertEquals('event fired', latch2.get())
self.assertEqual('event fired', latch.get())
self.assertEqual('event fired', latch2.get())
self.assertTrue(latch.empty())
self.assertTrue(latch2.empty())

@ -36,7 +36,7 @@ class ConstructorTest(testlib.RouterMixin, testlib.TestCase):
)
#context.call(mitogen.utils.log_to_file, '/tmp/log')
#context.call(mitogen.utils.disable_site_packages)
self.assertEquals(3, context.call(plain_old_module.add, 1, 2))
self.assertEqual(3, context.call(plain_old_module.add, 1, 2))
class SshTest(testlib.DockerMixin, testlib.TestCase):
@ -73,7 +73,7 @@ class SshTest(testlib.DockerMixin, testlib.TestCase):
self.dockerized_ssh.get_host(),
self.dockerized_ssh.port,
)
self.assertEquals(name, context.name)
self.assertEqual(name, context.name)
def test_via_stream_name(self):
context = self.docker_ssh(
@ -86,7 +86,7 @@ class SshTest(testlib.DockerMixin, testlib.TestCase):
self.dockerized_ssh.host,
self.dockerized_ssh.port,
)
self.assertEquals(name, sudo.name)
self.assertEqual(name, sudo.name)
def test_password_required(self):
e = self.assertRaises(mitogen.ssh.PasswordError,
@ -145,7 +145,7 @@ class SshTest(testlib.DockerMixin, testlib.TestCase):
check_host_keys='enforce',
)
)
self.assertEquals(e.args[0], mitogen.ssh.hostkey_failed_msg)
self.assertEqual(e.args[0], mitogen.ssh.hostkey_failed_msg)
finally:
fp.close()
@ -189,7 +189,7 @@ class BannerTest(testlib.DockerMixin, testlib.TestCase):
self.dockerized_ssh.get_host(),
self.dockerized_ssh.port,
)
self.assertEquals(name, context.name)
self.assertEqual(name, context.name)
class StubPermissionDeniedTest(StubSshMixin, testlib.TestCase):
@ -206,19 +206,19 @@ class StubCheckHostKeysTest(StubSshMixin, testlib.TestCase):
def test_check_host_keys_accept(self):
# required=true, host_key_checking=accept
context = self.stub_ssh(STUBSSH_MODE='ask', check_host_keys='accept')
self.assertEquals('1', context.call(os.getenv, 'STDERR_WAS_TTY'))
self.assertEqual('1', context.call(os.getenv, 'STDERR_WAS_TTY'))
def test_check_host_keys_enforce(self):
# required=false, host_key_checking=enforce
context = self.stub_ssh(check_host_keys='enforce')
self.assertEquals(None, context.call(os.getenv, 'STDERR_WAS_TTY'))
self.assertEqual(None, context.call(os.getenv, 'STDERR_WAS_TTY'))
def test_check_host_keys_ignore(self):
# required=false, host_key_checking=ignore
context = self.stub_ssh(check_host_keys='ignore')
self.assertEquals(None, context.call(os.getenv, 'STDERR_WAS_TTY'))
self.assertEqual(None, context.call(os.getenv, 'STDERR_WAS_TTY'))
def test_password_present(self):
# required=true, password is not None
context = self.stub_ssh(check_host_keys='ignore', password='willick')
self.assertEquals('1', context.call(os.getenv, 'STDERR_WAS_TTY'))
self.assertEqual('1', context.call(os.getenv, 'STDERR_WAS_TTY'))

@ -20,8 +20,8 @@ class ConstructorTest(testlib.RouterMixin, testlib.TestCase):
def test_basic(self):
context, argv = self.run_su()
self.assertEquals(argv[1], 'root')
self.assertEquals(argv[2], '-c')
self.assertEqual(argv[1], 'root')
self.assertEqual(argv[2], '-c')
class SuTest(testlib.DockerMixin, testlib.TestCase):
@ -64,4 +64,4 @@ class SuTest(testlib.DockerMixin, testlib.TestCase):
password='has_sudo_password',
)
context = self.router.su(via=ssh, password='rootpassword')
self.assertEquals(0, context.call(os.getuid))
self.assertEqual(0, context.call(os.getuid))

@ -21,7 +21,7 @@ class ConstructorTest(testlib.RouterMixin, testlib.TestCase):
def test_basic(self):
context, argv = self.run_sudo()
self.assertEquals(argv[:4], [
self.assertEqual(argv[:4], [
self.sudo_path,
'-u', 'root',
'--'
@ -32,7 +32,7 @@ class ConstructorTest(testlib.RouterMixin, testlib.TestCase):
selinux_type='setype',
selinux_role='serole',
)
self.assertEquals(argv[:8], [
self.assertEqual(argv[:8], [
self.sudo_path,
'-u', 'root',
'-r', 'serole',
@ -44,7 +44,7 @@ class ConstructorTest(testlib.RouterMixin, testlib.TestCase):
context, argv = self.run_sudo(
sudo_args=['--type', 'setype', '--role', 'serole', '--user', 'user']
)
self.assertEquals(argv[:8], [
self.assertEqual(argv[:8], [
self.sudo_path,
'-u', 'user',
'-r', 'serole',
@ -57,7 +57,7 @@ class ConstructorTest(testlib.RouterMixin, testlib.TestCase):
os.environ['PREHISTORIC_SUDO'] = '1'
try:
context, argv = self.run_sudo()
self.assertEquals('1', context.call(os.getenv, 'PREHISTORIC_SUDO'))
self.assertEqual('1', context.call(os.getenv, 'PREHISTORIC_SUDO'))
finally:
del os.environ['PREHISTORIC_SUDO']

@ -18,49 +18,49 @@ class TimerListMixin(object):
class GetTimeoutTest(TimerListMixin, testlib.TestCase):
def test_empty(self):
self.assertEquals(None, self.list.get_timeout())
self.assertEqual(None, self.list.get_timeout())
def test_one_event(self):
self.list.schedule(2, lambda: None)
self.list._now = lambda: 1
self.assertEquals(1, self.list.get_timeout())
self.assertEqual(1, self.list.get_timeout())
def test_two_events_same_moment(self):
self.list.schedule(2, lambda: None)
self.list.schedule(2, lambda: None)
self.list._now = lambda: 1
self.assertEquals(1, self.list.get_timeout())
self.assertEqual(1, self.list.get_timeout())
def test_two_events(self):
self.list.schedule(2, lambda: None)
self.list.schedule(3, lambda: None)
self.list._now = lambda: 1
self.assertEquals(1, self.list.get_timeout())
self.assertEqual(1, self.list.get_timeout())
def test_two_events_expired(self):
self.list.schedule(2, lambda: None)
self.list.schedule(3, lambda: None)
self.list._now = lambda: 3
self.assertEquals(0, self.list.get_timeout())
self.assertEqual(0, self.list.get_timeout())
def test_two_events_in_past(self):
self.list.schedule(2, lambda: None)
self.list.schedule(3, lambda: None)
self.list._now = lambda: 30
self.assertEquals(0, self.list.get_timeout())
self.assertEqual(0, self.list.get_timeout())
def test_two_events_in_past(self):
self.list.schedule(2, lambda: None)
self.list.schedule(3, lambda: None)
self.list._now = lambda: 30
self.assertEquals(0, self.list.get_timeout())
self.assertEqual(0, self.list.get_timeout())
def test_one_cancelled(self):
t1 = self.list.schedule(2, lambda: None)
t2 = self.list.schedule(3, lambda: None)
self.list._now = lambda: 0
t1.cancel()
self.assertEquals(3, self.list.get_timeout())
self.assertEqual(3, self.list.get_timeout())
def test_two_cancelled(self):
t1 = self.list.schedule(2, lambda: None)
@ -68,30 +68,30 @@ class GetTimeoutTest(TimerListMixin, testlib.TestCase):
self.list._now = lambda: 0
t1.cancel()
t2.cancel()
self.assertEquals(None, self.list.get_timeout())
self.assertEqual(None, self.list.get_timeout())
class ScheduleTest(TimerListMixin, testlib.TestCase):
def test_in_past(self):
self.list._now = lambda: 30
timer = self.list.schedule(29, lambda: None)
self.assertEquals(29, timer.when)
self.assertEquals(0, self.list.get_timeout())
self.assertEqual(29, timer.when)
self.assertEqual(0, self.list.get_timeout())
def test_in_future(self):
self.list._now = lambda: 30
timer = self.list.schedule(31, lambda: None)
self.assertEquals(31, timer.when)
self.assertEquals(1, self.list.get_timeout())
self.assertEqual(31, timer.when)
self.assertEqual(1, self.list.get_timeout())
def test_same_moment(self):
self.list._now = lambda: 30
timer = self.list.schedule(31, lambda: None)
timer2 = self.list.schedule(31, lambda: None)
self.assertEquals(31, timer.when)
self.assertEquals(31, timer2.when)
self.assertEqual(31, timer.when)
self.assertEqual(31, timer2.when)
self.assertTrue(timer is not timer2)
self.assertEquals(1, self.list.get_timeout())
self.assertEqual(1, self.list.get_timeout())
class ExpireTest(TimerListMixin, testlib.TestCase):
@ -100,7 +100,7 @@ class ExpireTest(TimerListMixin, testlib.TestCase):
self.assertTrue(timer.active)
self.list._now = lambda: 30
self.list.expire()
self.assertEquals(1, len(timer.func.mock_calls))
self.assertEqual(1, len(timer.func.mock_calls))
self.assertFalse(timer.active)
def test_in_future(self):
@ -108,7 +108,7 @@ class ExpireTest(TimerListMixin, testlib.TestCase):
self.assertTrue(timer.active)
self.list._now = lambda: 28
self.list.expire()
self.assertEquals(0, len(timer.func.mock_calls))
self.assertEqual(0, len(timer.func.mock_calls))
self.assertTrue(timer.active)
def test_same_moment(self):
@ -118,8 +118,8 @@ class ExpireTest(TimerListMixin, testlib.TestCase):
self.assertTrue(timer2.active)
self.list._now = lambda: 29
self.list.expire()
self.assertEquals(1, len(timer.func.mock_calls))
self.assertEquals(1, len(timer2.func.mock_calls))
self.assertEqual(1, len(timer.func.mock_calls))
self.assertEqual(1, len(timer2.func.mock_calls))
self.assertFalse(timer.active)
self.assertFalse(timer2.active)
@ -127,11 +127,11 @@ class ExpireTest(TimerListMixin, testlib.TestCase):
self.list._now = lambda: 29
timer = self.list.schedule(29, mock.Mock())
timer.cancel()
self.assertEquals(None, self.list.get_timeout())
self.assertEqual(None, self.list.get_timeout())
self.list._now = lambda: 29
self.list.expire()
self.assertEquals(0, len(timer.func.mock_calls))
self.assertEquals(None, self.list.get_timeout())
self.assertEqual(0, len(timer.func.mock_calls))
self.assertEqual(None, self.list.get_timeout())
class CancelTest(TimerListMixin, testlib.TestCase):
@ -142,7 +142,7 @@ class CancelTest(TimerListMixin, testlib.TestCase):
timer.cancel()
self.assertFalse(timer.active)
self.list.expire()
self.assertEquals(0, len(timer.func.mock_calls))
self.assertEqual(0, len(timer.func.mock_calls))
def test_double_cancel(self):
self.list._now = lambda: 29
@ -152,7 +152,7 @@ class CancelTest(TimerListMixin, testlib.TestCase):
timer.cancel()
self.assertFalse(timer.active)
self.list.expire()
self.assertEquals(0, len(timer.func.mock_calls))
self.assertEqual(0, len(timer.func.mock_calls))
@mitogen.core.takes_econtext

@ -19,5 +19,5 @@ class TwoThreeCompatTest(testlib.RouterMixin, testlib.TestCase):
target = self.router.local(python_path=self.python_path)
spare2, = target.call(simple_pkg.ping.ping, spare)
self.assertEquals(spare.context_id, spare2.context_id)
self.assertEquals(spare.name, spare2.name)
self.assertEqual(spare.context_id, spare2.context_id)
self.assertEqual(spare.name, spare2.name)

@ -29,26 +29,26 @@ class BlobTest(testlib.TestCase):
def test_repr(self):
blob = self.make()
self.assertEquals('[blob: 128 bytes]', repr(blob))
self.assertEqual('[blob: 128 bytes]', repr(blob))
def test_decays_on_constructor(self):
blob = self.make()
self.assertEquals(b('x') * 128, mitogen.core.BytesType(blob))
self.assertEqual(b('x') * 128, mitogen.core.BytesType(blob))
def test_decays_on_write(self):
blob = self.make()
io = BytesIO()
io.write(blob)
self.assertEquals(128, io.tell())
self.assertEquals(b('x') * 128, io.getvalue())
self.assertEqual(128, io.tell())
self.assertEqual(b('x') * 128, io.getvalue())
def test_message_roundtrip(self):
blob = self.make()
msg = mitogen.core.Message.pickled(blob)
blob2 = msg.unpickle()
self.assertEquals(type(blob), type(blob2))
self.assertEquals(repr(blob), repr(blob2))
self.assertEquals(mitogen.core.BytesType(blob),
self.assertEqual(type(blob), type(blob2))
self.assertEqual(repr(blob), repr(blob2))
self.assertEqual(mitogen.core.BytesType(blob),
mitogen.core.BytesType(blob2))
@ -60,26 +60,26 @@ class SecretTest(testlib.TestCase):
def test_repr(self):
secret = self.make()
self.assertEquals('[secret]', repr(secret))
self.assertEqual('[secret]', repr(secret))
def test_decays_on_constructor(self):
secret = self.make()
self.assertEquals('password', mitogen.core.UnicodeType(secret))
self.assertEqual('password', mitogen.core.UnicodeType(secret))
def test_decays_on_write(self):
secret = self.make()
io = StringIO()
io.write(secret)
self.assertEquals(8, io.tell())
self.assertEquals('password', io.getvalue())
self.assertEqual(8, io.tell())
self.assertEqual('password', io.getvalue())
def test_message_roundtrip(self):
secret = self.make()
msg = mitogen.core.Message.pickled(secret)
secret2 = msg.unpickle()
self.assertEquals(type(secret), type(secret2))
self.assertEquals(repr(secret), repr(secret2))
self.assertEquals(mitogen.core.b(secret),
self.assertEqual(type(secret), type(secret2))
self.assertEqual(repr(secret), repr(secret2))
self.assertEqual(mitogen.core.b(secret),
mitogen.core.b(secret2))
@ -88,30 +88,30 @@ class KwargsTest(testlib.TestCase):
def test_empty(self):
kw = self.klass({})
self.assertEquals({}, kw)
self.assertEquals('Kwargs({})', repr(kw))
self.assertEqual({}, kw)
self.assertEqual('Kwargs({})', repr(kw))
klass, (dct,) = kw.__reduce__()
self.assertTrue(klass is self.klass)
self.assertTrue(type(dct) is dict)
self.assertEquals({}, dct)
self.assertEqual({}, dct)
@unittest.skipIf(condition=(sys.version_info >= (2, 6)),
reason='py<2.6 only')
def test_bytes_conversion(self):
kw = self.klass({u'key': 123})
self.assertEquals({'key': 123}, kw)
self.assertEquals("Kwargs({'key': 123})", repr(kw))
self.assertEqual({'key': 123}, kw)
self.assertEqual("Kwargs({'key': 123})", repr(kw))
@unittest.skipIf(condition=not mitogen.core.PY3,
reason='py3 only')
def test_unicode_conversion(self):
kw = self.klass({mitogen.core.b('key'): 123})
self.assertEquals({u'key': 123}, kw)
self.assertEquals("Kwargs({'key': 123})", repr(kw))
self.assertEqual({u'key': 123}, kw)
self.assertEqual("Kwargs({'key': 123})", repr(kw))
klass, (dct,) = kw.__reduce__()
self.assertTrue(klass is self.klass)
self.assertTrue(type(dct) is dict)
self.assertEquals({u'key': 123}, dct)
self.assertEqual({u'key': 123}, dct)
key, = dct
self.assertTrue(type(key) is mitogen.core.UnicodeType)
@ -125,20 +125,20 @@ class ToTextTest(testlib.TestCase):
def test_bytes(self):
s = self.func(mitogen.core.b('bytes'))
self.assertEquals(mitogen.core.UnicodeType, type(s))
self.assertEquals(s, u'bytes')
self.assertEqual(mitogen.core.UnicodeType, type(s))
self.assertEqual(s, u'bytes')
def test_unicode(self):
s = self.func(u'text')
self.assertEquals(mitogen.core.UnicodeType, type(s))
self.assertEquals(s, u'text')
self.assertEqual(mitogen.core.UnicodeType, type(s))
self.assertEqual(s, u'text')
def test_adorned_unicode(self):
s = self.func(AdornedUnicode(u'text'))
self.assertEquals(mitogen.core.UnicodeType, type(s))
self.assertEquals(s, u'text')
self.assertEqual(mitogen.core.UnicodeType, type(s))
self.assertEqual(s, u'text')
def test_integer(self):
s = self.func(123)
self.assertEquals(mitogen.core.UnicodeType, type(s))
self.assertEquals(s, u'123')
self.assertEqual(mitogen.core.UnicodeType, type(s))
self.assertEqual(s, u'123')

@ -96,12 +96,12 @@ class ClientTest(testlib.TestCase):
def _test_simple_client(self, path):
router, context = self._try_connect(path)
try:
self.assertEquals(0, context.context_id)
self.assertEquals(1, mitogen.context_id)
self.assertEquals(0, mitogen.parent_id)
self.assertEqual(0, context.context_id)
self.assertEqual(1, mitogen.context_id)
self.assertEqual(0, mitogen.parent_id)
resp = context.call_service(service_name=MyService, method_name='ping')
self.assertEquals(mitogen.context_id, resp['src_id'])
self.assertEquals(0, resp['auth_id'])
self.assertEqual(mitogen.context_id, resp['src_id'])
self.assertEqual(0, resp['auth_id'])
finally:
router.broker.shutdown()
router.broker.join()

Loading…
Cancel
Save