1. Jannis Leidel
  2. django-countries

Commits

Chris Beaven  committed e9e25eb

Simplify tests

  • Participants
  • Parent commits 09a91b8
  • Branches default

Comments (0)

Files changed (6)

File django_countries/tests/__init__.py

View file
-from django_countries import settings
-from django_countries.utils.tests import TempAppTestCase
+from django.db import models
+from django_countries import CountryField
+from django_countries.tests.fields import TestCountryField
 
 
-class TestCountryField(TempAppTestCase):
-    test_apps = (
-        'django_countries.tests.countries_test',
-    )
-
-    def create_person(self, country='NZ'):
-        from django_countries.tests.countries_test.models import Person
-        return Person.objects.create(name='Chris Beaven', country=country)
-
-    def test_logic(self):
-        person = self.create_person()
-
-        self.assertEqual(person.country, 'NZ')
-        self.assertNotEqual(person.country, 'ZZ')
-
-        self.assert_(person.country < 'OA')
-        self.assert_(person.country > 'NY')
-
-        self.assert_(person.country)
-        person.country = ''
-        self.assertFalse(person.country)
-
-    def test_unicode(self):
-        person = self.create_person()
-        self.assertEqual(unicode(person.country), 'NZ')
-
-    def test_name(self):
-        person = self.create_person()
-        self.assertEqual(person.country.name, u'New Zealand')
-
-    def test_flag(self):
-        person = self.create_person()
-        expected_url = settings.FLAG_URL % {'code': 'nz', 'code_upper': 'NZ'}
-        self.assertEqual(person.country.flag, expected_url)
-
-    def test_blank(self):
-        from django_countries.tests.countries_test.models import Person
-        person = self.create_person(country=None)
-        self.assertEqual(person.country, '')
-
-        person = Person.objects.get(pk=person.pk)
-        self.assertEqual(person.country, '')
-
-    def test_len(self):
-        person = self.create_person()
-        self.assertEqual(len(person.country), 2)
-
-        person = self.create_person(country=None)
-        self.assertEqual(len(person.country), 0)
+class Person(models.Model):
+    name = models.CharField(max_length=50)
+    country = CountryField(blank=True)

File django_countries/tests/countries_test/__init__.py

Empty file removed.

File django_countries/tests/countries_test/models.py

-from django.db import models
-from django_countries import CountryField
-
-
-class Person(models.Model):
-    name = models.CharField(max_length=50)
-    country = CountryField(blank=True)

File django_countries/tests/fields.py

View file
+from django.test import TestCase
+from django_countries import settings
+
+
+class TestCountryField(TestCase):
+
+    def create_person(self, country='NZ'):
+        from django_countries.tests import Person
+        return Person.objects.create(name='Chris Beaven', country=country)
+
+    def test_logic(self):
+        person = self.create_person()
+
+        self.assertEqual(person.country, 'NZ')
+        self.assertNotEqual(person.country, 'ZZ')
+
+        self.assert_(person.country < 'OA')
+        self.assert_(person.country > 'NY')
+
+        self.assert_(person.country)
+        person.country = ''
+        self.assertFalse(person.country)
+
+    def test_unicode(self):
+        person = self.create_person()
+        self.assertEqual(unicode(person.country), 'NZ')
+
+    def test_name(self):
+        person = self.create_person()
+        self.assertEqual(person.country.name, u'New Zealand')
+
+    def test_flag(self):
+        person = self.create_person()
+        expected_url = settings.FLAG_URL % {'code': 'nz', 'code_upper': 'NZ'}
+        self.assertEqual(person.country.flag, expected_url)
+
+    def test_blank(self):
+        from django_countries.tests import Person
+        person = self.create_person(country=None)
+        self.assertEqual(person.country, '')
+
+        person = Person.objects.get(pk=person.pk)
+        self.assertEqual(person.country, '')
+
+    def test_len(self):
+        person = self.create_person()
+        self.assertEqual(len(person.country), 2)
+
+        person = self.create_person(country=None)
+        self.assertEqual(len(person.country), 0)

File django_countries/utils/__init__.py

Empty file removed.

File django_countries/utils/tests.py

-from django.test import TestCase
-from django.conf import settings
-from django.core.management import call_command
-from django.db.models.loading import load_app
-
-
-class TempAppTestCase(TestCase):
-    """
-    A Django test case which also handles test-only applications.
-
-    """
-    test_apps = ()
-
-    def setUp(self):
-        self.old_INSTALLED_APPS = settings.INSTALLED_APPS
-        settings.INSTALLED_APPS = (tuple(settings.INSTALLED_APPS) +
-                                   self.test_apps)
-        for app in self.test_apps:
-            load_app(app)
-        if self.test_apps:
-            # Create tables for any test-only applications.
-            call_command('syncdb', verbosity=0, interactive=False)
-
-    def tearDown(self):
-        settings.INSTALLED_APPS = self.old_INSTALLED_APPS