From a7a3ea4e3d2fa4751c0ceaf20a809d635482b808 Mon Sep 17 00:00:00 2001 From: tzangms Date: Mon, 9 Dec 2013 02:35:02 +0800 Subject: [PATCH] improve unit test coverage --- tests/__init__.py | 23 +++- tests/fixtures/basic.html | 2 +- tests/fixtures/horizontal.html | 210 +++++++++++++++++++++++++++++++++ 3 files changed, 230 insertions(+), 5 deletions(-) create mode 100644 tests/fixtures/horizontal.html diff --git a/tests/__init__.py b/tests/__init__.py index d008b46..6de0100 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -39,14 +39,29 @@ class BootstrapTemplateTagTests(TestCase): def setUp(self): call_command('syncdb', interactive=False) - def test_bootstrap_tag(self): + def test_basic_form(self): form = ExampleForm() html = Template("{% load bootstrap %}{{ form|bootstrap }}").render(Context({'form': form})) - image = os.path.join('fixtures', 'basic.html') - with open(os.path.join(TEST_DIR, image)) as f: + tpl = os.path.join('fixtures', 'basic.html') + with open(os.path.join(TEST_DIR, tpl)) as f: content = f.read() - self.maxDiff = None + with open('/tmp/basic.html', 'w+') as f: + f.write(html) + + self.maxDiff = True + self.assertHTMLEqual(html, content) + + def test_horizontal_form(self): + form = ExampleForm() + + html = Template("{% load bootstrap %}{{ form|bootstrap_horizontal }}").render(Context({'form': form})) + + tpl = os.path.join('fixtures', 'horizontal.html') + with open(os.path.join(TEST_DIR, tpl)) as f: + content = f.read() + + self.maxDiff = True self.assertHTMLEqual(html, content) diff --git a/tests/fixtures/basic.html b/tests/fixtures/basic.html index 322806e..e203d19 100644 --- a/tests/fixtures/basic.html +++ b/tests/fixtures/basic.html @@ -116,7 +116,7 @@
-