Added setUp() method to FlatpageModelTests.

This commit is contained in:
Mads Jensen 2017-10-11 21:27:15 +02:00 committed by Tim Graham
parent 41be85862d
commit bd8deeccd5
1 changed files with 7 additions and 6 deletions

View File

@ -5,11 +5,12 @@ from django.test.utils import override_script_prefix
class FlatpageModelTests(SimpleTestCase): class FlatpageModelTests(SimpleTestCase):
def test_get_absolute_url_urlencodes(self): def setUp(self):
pf = FlatPage(title="Café!", url='/café/') self.page = FlatPage(title='Café!', url='/café/')
self.assertEqual(pf.get_absolute_url(), '/caf%C3%A9/')
@override_script_prefix('/beverages/') def test_get_absolute_url_urlencodes(self):
self.assertEqual(self.page.get_absolute_url(), '/caf%C3%A9/')
@override_script_prefix('/prefix/')
def test_get_absolute_url_honors_script_prefix(self): def test_get_absolute_url_honors_script_prefix(self):
pf = FlatPage(title="Tea!", url='/tea/') self.assertEqual(self.page.get_absolute_url(), '/prefix/caf%C3%A9/')
self.assertEqual(pf.get_absolute_url(), '/beverages/tea/')