def test_htmlsafe_repr(self): class MyFactor(CustomFactor): inputs = [TestingDataSet.float_col] window_length = 3 self.assertEqual( repr_htmlsafe(MyFactor()), repr(MyFactor()), )
def test_htmlsafe_repr_handles_errors(self): class MyFactor(CustomFactor): inputs = [TestingDataSet.float_col] window_length = 3 def __repr__(self): raise ValueError("Kaboom!") assert repr_htmlsafe(MyFactor()) == "(Error Displaying MyFactor)"
def test_htmlsafe_repr_escapes_html(self): class MyFactor(CustomFactor): inputs = [TestingDataSet.float_col] window_length = 3 def __repr__(self): return "<b>foo</b>" assert repr_htmlsafe(MyFactor()) == "<b>foo</b>".replace( "<", "<").replace(">", ">")
def test_htmlsafe_repr_escapes_html(self): class MyFactor(CustomFactor): inputs = [TestingDataSet.float_col] window_length = 3 def __repr__(self): return '<b>foo</b>' self.assertEqual( repr_htmlsafe(MyFactor()), '<b>foo</b>'.replace('<', '<').replace('>', '>'))
def test_htmlsafe_repr_escapes_html_when_it_handles_errors(self): class MyFactor(CustomFactor): inputs = [TestingDataSet.float_col] window_length = 3 def __repr__(self): raise ValueError("Kaboom!") MyFactor.__name__ = "<b>foo</b>" converted = MyFactor.__name__.replace("<", "<").replace(">", ">") assert repr_htmlsafe( MyFactor()) == "(Error Displaying {})".format(converted)
def test_htmlsafe_repr_escapes_html_when_it_handles_errors(self): class MyFactor(CustomFactor): inputs = [TestingDataSet.float_col] window_length = 3 def __repr__(self): raise ValueError("Kaboom!") MyFactor.__name__ = '<b>foo</b>' converted = MyFactor.__name__.replace('<', '<').replace('>', '>') self.assertEqual( repr_htmlsafe(MyFactor()), f'(Error Displaying {converted})', )