File: error_test.py

package info (click to toggle)
python-mitogen 0.3.25~a2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 6,220 kB
  • sloc: python: 21,989; sh: 183; makefile: 74; perl: 19; ansic: 18
file content (26 lines) | stat: -rw-r--r-- 870 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import testlib
import mitogen.core


class ConstructorTest(testlib.TestCase):
    klass = mitogen.core.Error

    def test_literal_no_format(self):
        e = self.klass('error')
        self.assertEqual(e.args[0], 'error')
        self.assertIsInstance(e.args[0], mitogen.core.UnicodeType)

    def test_literal_format_chars_present(self):
        e = self.klass('error%s')
        self.assertEqual(e.args[0], 'error%s')
        self.assertIsInstance(e.args[0], mitogen.core.UnicodeType)

    def test_format(self):
        e = self.klass('error%s', 123)
        self.assertEqual(e.args[0], 'error123')
        self.assertIsInstance(e.args[0], mitogen.core.UnicodeType)

    def test_bytes_to_unicode(self):
        e = self.klass(mitogen.core.b('error'))
        self.assertEqual(e.args[0], 'error')
        self.assertIsInstance(e.args[0], mitogen.core.UnicodeType)