|
|
@ -24,14 +24,16 @@ class ConstructorTest(unittest2.TestCase):
|
|
|
|
def test_from_exc(self):
|
|
|
|
def test_from_exc(self):
|
|
|
|
ve = plain_old_module.MyError('eek')
|
|
|
|
ve = plain_old_module.MyError('eek')
|
|
|
|
e = self.klass(ve)
|
|
|
|
e = self.klass(ve)
|
|
|
|
|
|
|
|
self.assertEquals(e.type_name, 'plain_old_module.MyError')
|
|
|
|
self.assertEquals(e.args[0], 'plain_old_module.MyError: eek')
|
|
|
|
self.assertEquals(e.args[0], 'plain_old_module.MyError: eek')
|
|
|
|
|
|
|
|
|
|
|
|
def test_form_base_exc(self):
|
|
|
|
def test_form_base_exc(self):
|
|
|
|
ve = SystemExit('eek')
|
|
|
|
ve = SystemExit('eek')
|
|
|
|
|
|
|
|
type_name = mitogen.core.qualname(SystemExit) # varies across 2/3.
|
|
|
|
|
|
|
|
|
|
|
|
e = self.klass(ve)
|
|
|
|
e = self.klass(ve)
|
|
|
|
self.assertEquals(e.args[0],
|
|
|
|
self.assertEquals(e.type_name, type_name)
|
|
|
|
# varies across 2/3.
|
|
|
|
self.assertEquals(e.args[0], '%s: eek' % (type_name,))
|
|
|
|
'%s.%s: eek' % (type(ve).__module__, type(ve).__name__))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_from_exc_tb(self):
|
|
|
|
def test_from_exc_tb(self):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
@ -40,6 +42,7 @@ class ConstructorTest(unittest2.TestCase):
|
|
|
|
ve = sys.exc_info()[1]
|
|
|
|
ve = sys.exc_info()[1]
|
|
|
|
e = self.klass(ve)
|
|
|
|
e = self.klass(ve)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.assertTrue(e.type_name, 'plain_old_module.MyError')
|
|
|
|
self.assertTrue(e.args[0].startswith('plain_old_module.MyError: eek'))
|
|
|
|
self.assertTrue(e.args[0].startswith('plain_old_module.MyError: eek'))
|
|
|
|
self.assertTrue('test_from_exc_tb' in e.args[0])
|
|
|
|
self.assertTrue('test_from_exc_tb' in e.args[0])
|
|
|
|
|
|
|
|
|
|
|
@ -50,17 +53,20 @@ class PickleTest(unittest2.TestCase):
|
|
|
|
def test_string_noargs(self):
|
|
|
|
def test_string_noargs(self):
|
|
|
|
e = self.klass('%s%s')
|
|
|
|
e = self.klass('%s%s')
|
|
|
|
e2 = pickle.loads(pickle.dumps(e))
|
|
|
|
e2 = pickle.loads(pickle.dumps(e))
|
|
|
|
|
|
|
|
self.assertEquals(e2.type_name, None)
|
|
|
|
self.assertEquals(e2.args[0], '%s%s')
|
|
|
|
self.assertEquals(e2.args[0], '%s%s')
|
|
|
|
|
|
|
|
|
|
|
|
def test_string_args(self):
|
|
|
|
def test_string_args(self):
|
|
|
|
e = self.klass('%s%s', 1, 1)
|
|
|
|
e = self.klass('%s%s', 1, 1)
|
|
|
|
e2 = pickle.loads(pickle.dumps(e))
|
|
|
|
e2 = pickle.loads(pickle.dumps(e))
|
|
|
|
|
|
|
|
self.assertEquals(e2.type_name, None)
|
|
|
|
self.assertEquals(e2.args[0], '11')
|
|
|
|
self.assertEquals(e2.args[0], '11')
|
|
|
|
|
|
|
|
|
|
|
|
def test_from_exc(self):
|
|
|
|
def test_from_exc(self):
|
|
|
|
ve = plain_old_module.MyError('eek')
|
|
|
|
ve = plain_old_module.MyError('eek')
|
|
|
|
e = self.klass(ve)
|
|
|
|
e = self.klass(ve)
|
|
|
|
e2 = pickle.loads(pickle.dumps(e))
|
|
|
|
e2 = pickle.loads(pickle.dumps(e))
|
|
|
|
|
|
|
|
self.assertEquals(e2.type_name, 'plain_old_module.MyError')
|
|
|
|
self.assertEquals(e2.args[0], 'plain_old_module.MyError: eek')
|
|
|
|
self.assertEquals(e2.args[0], 'plain_old_module.MyError: eek')
|
|
|
|
|
|
|
|
|
|
|
|
def test_from_exc_tb(self):
|
|
|
|
def test_from_exc_tb(self):
|
|
|
@ -71,6 +77,7 @@ class PickleTest(unittest2.TestCase):
|
|
|
|
e = self.klass(ve)
|
|
|
|
e = self.klass(ve)
|
|
|
|
|
|
|
|
|
|
|
|
e2 = pickle.loads(pickle.dumps(e))
|
|
|
|
e2 = pickle.loads(pickle.dumps(e))
|
|
|
|
|
|
|
|
self.assertEquals(e2.type_name, 'plain_old_module.MyError')
|
|
|
|
self.assertTrue(e2.args[0].startswith('plain_old_module.MyError: eek'))
|
|
|
|
self.assertTrue(e2.args[0].startswith('plain_old_module.MyError: eek'))
|
|
|
|
self.assertTrue('test_from_exc_tb' in e2.args[0])
|
|
|
|
self.assertTrue('test_from_exc_tb' in e2.args[0])
|
|
|
|
|
|
|
|
|
|
|
|