def test_register_filter(self):
        """
        Register the filter, and its wildly available.
        """
        formatter.register('uppercase', UppercaseMarkupFilter)

        # It's ready to be called
        result = formatter('This is some text', filter_name='uppercase')
        self.assertEqual(result, 'THIS IS SOME TEXT')
Exemplo n.º 2
0
    def test_register_filter(self):
        """
        Register the filter, and its wildly available.
        """
        formatter.register('uppercase', UppercaseMarkupFilter)

        # It's ready to be called
        result = formatter('This is some text', filter_name='uppercase')
        self.assertEqual(result, 'THIS IS SOME TEXT')
Exemplo n.º 3
0
    def test_unregister_filter(self):
        # Unregistering a filter that does not exist is simply ignored
        formatter.unregister('does-not-exist')

        # Unregistering an registered filter, and it no longer works and will
        # raise a ValueError.
        formatter.register('uppercase', UppercaseMarkupFilter)
        formatter.unregister('uppercase')

        self.assertRaises(ValueError, formatter, 'This is some text',
                          filter_name='uppercase')
Exemplo n.º 4
0
    def test_unregister_filter(self):
        # Unregistering a filter that does not exist is simply ignored
        formatter.unregister('does-not-exist')

        # Unregistering an registered filter, and it no longer works and will
        # raise a ValueError.
        formatter.register('uppercase', UppercaseMarkupFilter)
        formatter.unregister('uppercase')

        self.assertRaises(
            ValueError, formatter, 'This is some text', filter_name='uppercase'
        )
Exemplo n.º 5
0
    def test_fallback_filter(self):
        """
        You can call the formatter without a `filter_name` as long as a
        `MARKUP_FILTER_FALLBACK` setting is set.
        """
        self.assertRaises(ValueError, formatter, 'This is some text',
                          filter_name=None)

        formatter.register('uppercase', UppercaseMarkupFilter)

        with self.settings(MARKUP_FILTER_FALLBACK='uppercase'):
            result = formatter('This is some text', filter_name=None)
            self.assertEqual(result, 'THIS IS SOME TEXT')
Exemplo n.º 6
0
    def test_fallback_filter(self):
        """
        You can call the formatter without a `filter_name` as long as a
        `MARKUP_FILTER_FALLBACK` setting is set.
        """
        self.assertRaises(
            ValueError, formatter, 'This is some text', filter_name=None
        )

        formatter.register('uppercase', UppercaseMarkupFilter)

        with self.settings(MARKUP_FILTER_FALLBACK='uppercase'):
            result = formatter('This is some text', filter_name=None)
            self.assertEqual(result, 'THIS IS SOME TEXT')