Exemplo n.º 1
0
def assert_raises_exactly(cls, text):
    try:
        yield
    except Exception as e:
        assert type(e) is cls
        assert five.text(e) == text
    else:
        raise AssertionError('expected to raise')
Exemplo n.º 2
0
def unicode_filter(val):
    if val is None:
        return ''
    elif isinstance(val, five.text):
        return val
    elif isinstance(val, bytes):
        return val.decode('UTF-8')
    else:
        return five.text(val)
Exemplo n.º 3
0
def test_raises_using_reserved_variable():
    cls = compile_to_class('foo')

    template_var_name = 'getVar'

    assert hasattr(Template, template_var_name)

    try:
        # Should raise, getVar is a member of Template
        cls(searchList=[{template_var_name: 'lol'}])
    except AssertionError as e:
        assert template_var_name in five.text(e)
        return

    raise AssertionError('Should have raised `AssertionError`')
Exemplo n.º 4
0
def test_raises_using_reserved_variable():
    cls = compile_to_class("foo")

    template_var_name = "getVar"

    assert hasattr(Template, template_var_name)

    try:
        # Should raise, getVar is a member of Template
        cls(searchList=[{template_var_name: "lol"}])
    except AssertionError as e:
        assert template_var_name in five.text(e)
        return

    raise AssertionError("Should have raised `AssertionError`")
Exemplo n.º 5
0
 def attributes(self):
     attribs = [
         self.setting('indentationStep') + five.text(attrib)
         for attrib in self._generatedAttribs
     ]
     return '\n\n'.join(attribs)
Exemplo n.º 6
0
 def attributes(self):
     attribs = [
         self.setting('indentationStep') + five.text(attrib)
         for attrib in self._generatedAttribs
     ]
     return '\n\n'.join(attribs)