Example #1
0
    def test_htmlsafe_repr(self):
        class MyFactor(CustomFactor):
            inputs = [TestingDataSet.float_col]
            window_length = 3

        self.assertEqual(
            repr_htmlsafe(MyFactor()),
            repr(MyFactor()),
        )
Example #2
0
    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)"
Example #3
0
    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(
            "<", "&lt;").replace(">", "&gt;")
Example #4
0
    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('<', '&lt;').replace('>', '&gt;'))
Example #5
0
    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("<", "&lt;").replace(">", "&gt;")

        assert repr_htmlsafe(
            MyFactor()) == "(Error Displaying {})".format(converted)
Example #6
0
    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('<', '&lt;').replace('>', '&gt;')

        self.assertEqual(
            repr_htmlsafe(MyFactor()),
            f'(Error Displaying {converted})',
        )