2019-01-21 15:25:46 +00:00
|
|
|
|
|
|
|
import unittest2
|
|
|
|
|
|
|
|
import testlib
|
2019-01-21 19:38:23 +00:00
|
|
|
import mitogen.core
|
2019-01-21 15:25:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ConstructorTest(testlib.TestCase):
|
|
|
|
klass = mitogen.core.Error
|
|
|
|
|
|
|
|
def test_literal_no_format(self):
|
|
|
|
e = self.klass('error')
|
|
|
|
self.assertEquals(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.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.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.assertTrue(isinstance(e.args[0], mitogen.core.UnicodeType))
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest2.main()
|