Beispiel #1
0
 def test_deprecation(self):
     reset_warning_registry()
     with warnings.catch_warnings(record=True) as w:
         warnings.simplefilter("always")
         text.javascript_quote('thingy')
         self.assertEqual(len(w), 1)
         self.assertIn('escapejs()', repr(w[0].message))
Beispiel #2
0
 def test_if_tag_eq_deprecated(self):
     reset_warning_registry()
     with warnings.catch_warnings(record=True) as warns:
         warnings.simplefilter('always')
         output = self.engine.render_to_string('if-tag-eq-deprecated')
         self.assertEqual(output, 'yes')
     self.assertEqual(len(warns), 1)
     self.assertEqual(
         str(warns[0].message),
         "Operator '=' is deprecated and will be removed in Django 2.0. "
         "Use '==' instead.")
Beispiel #3
0
 def test_if_tag_eq_deprecated(self):
     reset_warning_registry()
     with warnings.catch_warnings(record=True) as warns:
         warnings.simplefilter('always')
         output = self.engine.render_to_string('if-tag-eq-deprecated')
         self.assertEqual(output, 'yes')
     self.assertEqual(len(warns), 1)
     self.assertEqual(
         str(warns[0].message),
         "Operator '=' is deprecated and will be removed in Django 1.10. "
         "Use '==' instead."
     )
Beispiel #4
0
    def test_chaining05(self):
        reset_warning_registry()
        with warnings.catch_warnings(record=True) as warns:
            warnings.simplefilter('always')
            output = self.engine.render_to_string('chaining05', {'a': 'a < b'})
            self.assertEqual(output, 'A &lt; b')

        self.assertEqual(len(warns), 1)
        self.assertEqual(
            str(warns[0].message),
            "escape isn't the last filter in ['escape_filter', 'capfirst'] and "
            "will be applied immediately in Django 2.0 so the output may change."
        )
Beispiel #5
0
    def test_class_definition_warnings(self):
        """
        Ensure a warning is raised upon class definition to suggest renaming
        the faulty method.
        """
        reset_warning_registry()
        with warnings.catch_warnings(record=True) as recorded:
            warnings.simplefilter('always')

            class Manager(six.with_metaclass(RenameManagerMethods)):
                def old(self):
                    pass
            self.assertEqual(len(recorded), 1)
            msg = str(recorded[0].message)
            self.assertEqual(msg, '`Manager.old` method should be renamed `new`.')
Beispiel #6
0
    def test_class_definition_warnings(self):
        """
        Ensure a warning is raised upon class definition to suggest renaming
        the faulty method.
        """
        reset_warning_registry()
        with warnings.catch_warnings(record=True) as recorded:
            warnings.simplefilter('always')

            class Manager(six.with_metaclass(RenameManagerMethods)):
                def old(self):
                    pass
            self.assertEqual(len(recorded), 1)
            msg = str(recorded[0].message)
            self.assertEqual(msg,
                '`Manager.old` method should be renamed `new`.')
Beispiel #7
0
    def test_deprecated_request(self):
        """
        Ensure the correct warning is raised when WSGIRequest.REQUEST is
        accessed.
        """
        reset_warning_registry()
        with warnings.catch_warnings(record=True) as recorded:
            warnings.simplefilter('always')
            request = RequestFactory().get('/')
            request.REQUEST  # evaluate

            msgs = [str(warning.message) for warning in recorded]
            self.assertEqual(msgs, [
                '`request.REQUEST` is deprecated, use `request.GET` or '
                '`request.POST` instead.',
                '`MergeDict` is deprecated, use `dict.update()` instead.',
            ])
Beispiel #8
0
    def test_deprecated_request(self):
        """
        Ensure the correct warning is raised when WSGIRequest.REQUEST is
        accessed.
        """
        reset_warning_registry()
        with warnings.catch_warnings(record=True) as recorded:
            warnings.simplefilter('always')
            request = RequestFactory().get('/')
            request.REQUEST  # evaluate

            msgs = [str(warning.message) for warning in recorded]
            self.assertEqual(msgs, [
                '`request.REQUEST` is deprecated, use `request.GET` or '
                '`request.POST` instead.',
                '`MergeDict` is deprecated, use `dict.update()` instead.',
            ])