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')
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)
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`')
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`")
def attributes(self): attribs = [ self.setting('indentationStep') + five.text(attrib) for attrib in self._generatedAttribs ] return '\n\n'.join(attribs)