コード例 #1
0
    def test_reverse(self):
        """Test all code paths through reverse_fallback and reverse_any"""

        self.assertEqual(
            reverse_fallback('test', reverse, 'not-exists'),
            'test',
        )
        self.assertEqual(
            reverse_fallback('test', reverse, 'admin:index'),
            '/admin/',
        )
        self.assertEqual(
            reverse_any((
                'not-exists',
                'admin:index',
            )),
            '/admin/',
        )
        with six.assertRaisesRegex(
                self,
                NoReverseMatch,
                "Reverse for any of 'not-exists-1', 'not-exists-2' with"
                " arguments '\[\]' and keyword arguments '{}' not found."
        ):
            reverse_any(('not-exists-1', 'not-exists-2'))
コード例 #2
0
    def test_reverse(self):
        """Test all code paths through reverse_fallback and reverse_any"""

        self.assertEqual(reverse_fallback("test", reverse, "not-exists"),
                         "test")
        self.assertEqual(reverse_fallback("test", reverse, "admin:index"),
                         "/admin/")
        self.assertEqual(reverse_any(("not-exists", "admin:index")), "/admin/")
        with self.assertRaisesRegex(
                NoReverseMatch,
                r"Reverse for any of 'not-exists-1', 'not-exists-2' with"
                r" arguments '\[\]' and keyword arguments '{}' not found.",
        ):
            reverse_any(("not-exists-1", "not-exists-2"))