Ejemplo n.º 1
0
    def test___str__(self):
        e = exceptions.LocalisedError()
        e.message = b"foo"
        assert str(e) == "foo"

        e = exceptions.LocalisedError()
        e.message = "\xc5"
        assert str(e) == "\xc5"
Ejemplo n.º 2
0
    def test___bytes__(self):
        e = exceptions.LocalisedError()
        e.message = "foo"
        assert bytes(e) == b"foo"

        e = exceptions.LocalisedError()
        e.message = "\xc5"
        assert bytes(e) == b'\xc3\x85'
Ejemplo n.º 3
0
    def test_xlat_simple_NO_raise_error(self):
        x = exceptions.LocalisedError()
        x.message = "Dummy text failed with %(tagword)s"
        x.t = {}
        x.nt = {}

        assert len(x.xlat(lambda x: x)) > 0  # some descriptive fault msg
Ejemplo n.º 4
0
    def test_xlat_raise_error(self):
        x = exceptions.LocalisedError()
        x.message = "Dummy text failed with %(tagword)s"
        x.t = {}
        x.nt = {}

        raises(KeyError, x.xlat, lambda x: x, raiseError=True)
Ejemplo n.º 5
0
    def test_xlat_simple_with_keyword(self):
        x = exceptions.LocalisedError()
        x.message = "Dummy text failed with %(tagword)s"
        x.t = {}
        x.nt = {'tagword': 'hello!'}

        assert x.xlat(lambda x: x) == "Dummy text failed with hello!"