Changeset 3661
- Timestamp:
- 08/27/06 08:59:47 (2 years ago)
- Files:
-
- django/trunk/tests/doctest.py (deleted)
- django/trunk/tests/modeltests/basic/models.py (modified) (5 diffs)
- django/trunk/tests/modeltests/choices/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/custom_columns/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/custom_managers/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/custom_methods/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/custom_pk/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/empty/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/field_defaults/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/generic_relations/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/get_latest/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/get_or_create/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/invalid_models/models.py (modified) (1 diff)
- django/trunk/tests/modeltests/lookup/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/m2m_and_m2o/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/m2m_intermediary/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/m2m_multiple/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/m2m_recursive/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/m2o_recursive2/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/m2o_recursive/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/manipulators/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/many_to_many/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/many_to_one/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/many_to_one_null/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/model_inheritance/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/mutually_referential/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/one_to_one/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/ordering/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/or_lookups/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/pagination/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/properties/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/reserved_names/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/reverse_lookup/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/save_delete_hooks/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/serializers/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/str/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/transactions/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/validation/models.py (modified) (2 diffs)
- django/trunk/tests/othertests (deleted)
- django/trunk/tests/regressiontests/cache (added)
- django/trunk/tests/regressiontests/cache/__init__.py (added)
- django/trunk/tests/regressiontests/cache/models.py (added)
- django/trunk/tests/regressiontests/cache/tests.py (copied) (copied from django/trunk/tests/othertests/cache.py) (2 diffs)
- django/trunk/tests/regressiontests/dateformat (added)
- django/trunk/tests/regressiontests/dateformat/__init__.py (added)
- django/trunk/tests/regressiontests/dateformat/models.py (added)
- django/trunk/tests/regressiontests/dateformat/tests.py (copied) (copied from django/trunk/tests/othertests/dateformat.py)
- django/trunk/tests/regressiontests/db_typecasts (added)
- django/trunk/tests/regressiontests/db_typecasts/__init__.py (added)
- django/trunk/tests/regressiontests/db_typecasts/models.py (added)
- django/trunk/tests/regressiontests/db_typecasts/tests.py (copied) (copied from django/trunk/tests/othertests/db_typecasts.py) (2 diffs)
- django/trunk/tests/regressiontests/defaultfilters (added)
- django/trunk/tests/regressiontests/defaultfilters/__init__.py (added)
- django/trunk/tests/regressiontests/defaultfilters/models.py (added)
- django/trunk/tests/regressiontests/defaultfilters/tests.py (copied) (copied from django/trunk/tests/othertests/defaultfilters.py)
- django/trunk/tests/regressiontests/httpwrappers (added)
- django/trunk/tests/regressiontests/httpwrappers/__init__.py (added)
- django/trunk/tests/regressiontests/httpwrappers/models.py (added)
- django/trunk/tests/regressiontests/httpwrappers/tests.py (copied) (copied from django/trunk/tests/othertests/httpwrappers.py)
- django/trunk/tests/regressiontests/initial_sql_regress/models.py (modified) (1 diff)
- django/trunk/tests/regressiontests/many_to_one_regress/models.py (modified) (1 diff)
- django/trunk/tests/regressiontests/markup (added)
- django/trunk/tests/regressiontests/markup/__init__.py (added)
- django/trunk/tests/regressiontests/markup/models.py (added)
- django/trunk/tests/regressiontests/markup/tests.py (copied) (copied from django/trunk/tests/othertests/markup.py) (2 diffs)
- django/trunk/tests/regressiontests/one_to_one_regress/models.py (modified) (2 diffs)
- django/trunk/tests/regressiontests/string_lookup/models.py (modified) (2 diffs)
- django/trunk/tests/regressiontests/templates (added)
- django/trunk/tests/regressiontests/templates/__init__.py (added)
- django/trunk/tests/regressiontests/templates/models.py (added)
- django/trunk/tests/regressiontests/templates/tests.py (copied) (copied from django/trunk/tests/othertests/templates.py) (2 diffs)
- django/trunk/tests/regressiontests/urlpatterns_reverse (added)
- django/trunk/tests/regressiontests/urlpatterns_reverse/__init__.py (added)
- django/trunk/tests/regressiontests/urlpatterns_reverse/models.py (added)
- django/trunk/tests/regressiontests/urlpatterns_reverse/tests.py (copied) (copied from django/trunk/tests/othertests/urlpatterns_reverse.py) (2 diffs)
- django/trunk/tests/runtests.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/tests/modeltests/basic/models.py
r3217 r3661 14 14 return self.headline 15 15 16 API_TESTS = """ 17 16 __test__ = {'API_TESTS': """ 18 17 # No articles are in the system yet. 19 18 >>> Article.objects.all() … … 315 314 [<Article: Article 6>, <Article: Default headline>, <Article: Article 7>, <Article: Updated article 8>] 316 315 317 """ 316 """} 318 317 319 318 from django.conf import settings … … 322 321 323 322 if building_docs or settings.DATABASE_ENGINE == 'postgresql': 324 API_TESTS+= """323 __test__['API_TESTS'] += """ 325 324 # In PostgreSQL, microsecond-level precision is available. 326 325 >>> a9 = Article(headline='Article 9', pub_date=datetime(2005, 7, 31, 12, 30, 45, 180)) … … 331 330 332 331 if building_docs or settings.DATABASE_ENGINE == 'mysql': 333 API_TESTS+= """332 __test__['API_TESTS'] += """ 334 333 # In MySQL, microsecond-level precision isn't available. You'll lose 335 334 # microsecond-level precision once the data is saved. … … 340 339 """ 341 340 342 API_TESTS+= """341 __test__['API_TESTS'] += """ 343 342 344 343 # You can manually specify the primary key when creating a new object. django/trunk/tests/modeltests/choices/models.py
r3075 r3661 24 24 return self.name 25 25 26 API_TESTS ="""26 __test__ = {'API_TESTS':""" 27 27 >>> a = Person(name='Adrian', gender='M') 28 28 >>> a.save() … … 37 37 >>> s.get_gender_display() 38 38 'Female' 39 """ 39 """} django/trunk/tests/modeltests/custom_columns/models.py
r3075 r3661 16 16 return '%s %s' % (self.first_name, self.last_name) 17 17 18 API_TESTS ="""18 __test__ = {'API_TESTS':""" 19 19 # Create a Person. 20 20 >>> p = Person(first_name='John', last_name='Smith') … … 51 51 ... 52 52 AttributeError: 'Person' object has no attribute 'last' 53 """ 53 """} django/trunk/tests/modeltests/custom_managers/models.py
r3075 r3661 59 59 return self.name 60 60 61 API_TESTS ="""61 __test__ = {'API_TESTS':""" 62 62 >>> p1 = Person(first_name='Bugs', last_name='Bunny', fun=True) 63 63 >>> p1.save() … … 105 105 >>> Car._default_manager.order_by('name') 106 106 [<Car: Corvette>, <Car: Neon>] 107 """ 107 """} django/trunk/tests/modeltests/custom_methods/models.py
r3075 r3661 37 37 return [self.__class__(*row) for row in cursor.fetchall()] 38 38 39 API_TESTS ="""39 __test__ = {'API_TESTS':""" 40 40 # Create a couple of Articles. 41 41 >>> from datetime import date … … 56 56 >>> b.articles_from_same_day_2() 57 57 [<Article: Area man programs in Python>] 58 """ 58 """} django/trunk/tests/modeltests/custom_pk/models.py
r3130 r3661 28 28 return self.name 29 29 30 API_TESTS ="""30 __test__ = {'API_TESTS':""" 31 31 >>> dan = Employee(employee_code='ABC123', first_name='Dan', last_name='Jones') 32 32 >>> dan.save() … … 89 89 [<Business: Sears>] 90 90 91 """ 91 """} django/trunk/tests/modeltests/empty/models.py
r3548 r3661 11 11 pass 12 12 13 API_TESTS ="""13 __test__ = {'API_TESTS':""" 14 14 >>> m = Empty() 15 15 >>> m.id … … 24 24 >>> existing.save() 25 25 26 """ 26 """} django/trunk/tests/modeltests/field_defaults/models.py
r3031 r3661 20 20 return self.headline 21 21 22 API_TESTS ="""22 __test__ = {'API_TESTS':""" 23 23 >>> from datetime import datetime 24 24 … … 49 49 >>> d.seconds < 5 50 50 True 51 """ 51 """} django/trunk/tests/modeltests/generic_relations/models.py
r3160 r3661 54 54 return self.name 55 55 56 API_TESTS ="""56 __test__ = {'API_TESTS':""" 57 57 # Create the world in 7 lines of code... 58 58 >>> lion = Animal(common_name="Lion", latin_name="Panthera leo") … … 106 106 >>> TaggedItem.objects.filter(content_type__pk=ctype.id, object_id=quartz.id) 107 107 [<TaggedItem: clearish>] 108 """ 108 """} django/trunk/tests/modeltests/get_latest/models.py
r3075 r3661 30 30 return self.name 31 31 32 API_TESTS ="""32 __test__ = {'API_TESTS':""" 33 33 # Because no Articles exist yet, get_latest() raises ArticleDoesNotExist. 34 34 >>> Article.objects.latest() … … 77 77 >>> Person.objects.latest('birthday') 78 78 <Person: Stephanie> 79 """ 79 """} django/trunk/tests/modeltests/get_or_create/models.py
r3092 r3661 16 16 return '%s %s' % (self.first_name, self.last_name) 17 17 18 API_TESTS ="""18 __test__ = {'API_TESTS':""" 19 19 # Acting as a divine being, create an Person. 20 20 >>> from datetime import date … … 50 50 >>> Person.objects.count() 51 51 2 52 """ 52 """} django/trunk/tests/modeltests/invalid_models/models.py
r3215 r3661 79 79 80 80 81 error_log= """invalid_models.fielderrors: "charfield": CharFields require a "maxlength" attribute.81 model_errors = """invalid_models.fielderrors: "charfield": CharFields require a "maxlength" attribute. 82 82 invalid_models.fielderrors: "floatfield": FloatFields require a "decimal_places" attribute. 83 83 invalid_models.fielderrors: "floatfield": FloatFields require a "max_digits" attribute. django/trunk/tests/modeltests/lookup/models.py
r3552 r3661 16 16 return self.headline 17 17 18 API_TESTS =r"""18 __test__ = {'API_TESTS':r""" 19 19 # Create a couple of Articles. 20 20 >>> from datetime import datetime … … 192 192 [<Article: Article with \ backslash>] 193 193 194 """ 194 """} django/trunk/tests/modeltests/m2m_and_m2o/models.py
r3321 r3661 22 22 23 23 24 API_TESTS ="""24 __test__ = {'API_TESTS':""" 25 25 >>> Issue.objects.all() 26 26 [] … … 63 63 >>> Issue.objects.filter(Q(client=r.id) | Q(cc__id__exact=r.id)) 64 64 [<Issue: 1>, <Issue: 2>, <Issue: 3>] 65 """ 65 """} django/trunk/tests/modeltests/m2m_intermediary/models.py
r3075 r3661 35 35 return '%s (%s)' % (self.reporter, self.position) 36 36 37 API_TESTS ="""37 __test__ = {'API_TESTS':""" 38 38 # Create a few Reporters. 39 39 >>> r1 = Reporter(first_name='John', last_name='Smith') … … 66 66 >>> r1.writer_set.all() 67 67 [<Writer: John Smith (Main writer)>] 68 """ 68 """} django/trunk/tests/modeltests/m2m_multiple/models.py
r3075 r3661 29 29 return self.headline 30 30 31 API_TESTS ="""31 __test__ = {'API_TESTS':""" 32 32 >>> from datetime import datetime 33 33 … … 77 77 >>> c4.secondary_article_set.all() 78 78 [<Article: Area man steals>, <Article: Area man runs>] 79 """ 79 """} django/trunk/tests/modeltests/m2m_recursive/models.py
r3215 r3661 23 23 return self.name 24 24 25 API_TESTS ="""25 __test__ = {'API_TESTS':""" 26 26 >>> a = Person(name='Anne') 27 27 >>> a.save() … … 190 190 [<Person: Chuck>] 191 191 192 """ 192 """} django/trunk/tests/modeltests/m2o_recursive2/models.py
r3075 r3661 18 18 return self.full_name 19 19 20 API_TESTS ="""20 __test__ = {'API_TESTS':""" 21 21 # Create two Person objects -- the mom and dad in our family. 22 22 >>> dad = Person(full_name='John Smith Senior', mother=None, father=None) … … 41 41 >>> kid.fathers_child_set.all() 42 42 [] 43 """ 43 """} django/trunk/tests/modeltests/m2o_recursive/models.py
r3075 r3661 20 20 return self.name 21 21 22 API_TESTS ="""22 __test__ = {'API_TESTS':""" 23 23 # Create a few Category objects. 24 24 >>> r = Category(id=None, name='Root category', parent=None) … … 38 38 >>> c.parent 39 39 <Category: Root category> 40 """ 40 """} django/trunk/tests/modeltests/manipulators/models.py
r3075 r3661 22 22 return self.name 23 23 24 API_TESTS ="""24 __test__ = {'API_TESTS':""" 25 25 >>> from django.utils.datastructures import MultiValueDict 26 26 … … 89 89 >>> a2.release_date 90 90 datetime.date(2005, 2, 13) 91 """ 91 """} django/trunk/tests/modeltests/many_to_many/models.py
r3246 r3661 29 29 ordering = ('headline',) 30 30 31 API_TESTS ="""31 __test__ = {'API_TESTS':""" 32 32 # Create a couple of Publications. 33 33 >>> p1 = Publication(id=None, title='The Python Journal') … … 232 232 [<Article: NASA uses Python>] 233 233 234 """ 234 """} django/trunk/tests/modeltests/many_to_one/models.py
r3248 r3661 26 26 ordering = ('headline',) 27 27 28 API_TESTS ="""28 __test__ = {'API_TESTS':""" 29 29 # Create a few Reporters. 30 30 >>> r = Reporter(first_name='John', last_name='Smith', email='john@example.com') … … 264 264 [] 265 265 266 """ 266 """} django/trunk/tests/modeltests/many_to_one_null/models.py
r3075 r3661 24 24 return self.headline 25 25 26 API_TESTS ="""26 __test__ = {'API_TESTS':""" 27 27 # Create a Reporter. 28 28 >>> r = Reporter(name='John Smith') … … 122 122 [<Article: First>, <Article: Fourth>] 123 123 124 """ 124 """} django/trunk/tests/modeltests/model_inheritance/models.py
r3075 r3661 27 27 return "%s the italian restaurant" % self.name 28 28 29 API_TESTS ="""29 __test__ = {'API_TESTS':""" 30 30 # Make sure Restaurant has the right fields in the right order. 31 31 >>> [f.name for f in Restaurant._meta.fields] … … 51 51 52 52 53 """ 53 """} django/trunk/tests/modeltests/mutually_referential/models.py
r2809 r3661 15 15 parent = ForeignKey(Parent) 16 16 17 API_TESTS ="""17 __test__ = {'API_TESTS':""" 18 18 # Create a Parent 19 19 >>> q = Parent(name='Elizabeth') … … 30 30 >>> q.delete() 31 31 32 """ 32 """} django/trunk/tests/modeltests/one_to_one/models.py
r3246 r3661 31 31 return "%s the waiter at %s" % (self.name, self.restaurant) 32 32 33 API_TESTS ="""33 __test__ = {'API_TESTS':""" 34 34 # Create a couple of Places. 35 35 >>> p1 = Place(name='Demon Dogs', address='944 W. Fullerton') … … 152 152 >>> r = Restaurant.objects.get(pk=1) 153 153 >>> r.delete() 154 """ 154 """} django/trunk/tests/modeltests/ordering/models.py
r3075 r3661 25 25 return self.headline 26 26 27 API_TESTS ="""27 __test__ = {'API_TESTS':""" 28 28 # Create a couple of Articles. 29 29 >>> from datetime import datetime … … 65 65 >>> Article.objects.order_by('?') 66 66 [...] 67 """ 67 """} django/trunk/tests/modeltests/or_lookups/models.py
r3075 r3661 24 24 return self.headline 25 25 26 API_TESTS ="""26 __test__ = {'API_TESTS':""" 27 27 >>> from datetime import datetime 28 28 >>> from django.db.models import Q … … 102 102 >>> Article.objects.complex_filter(Q(pk=1) | Q(pk=2)) 103 103 [<Article: Hello>, <Article: Goodbye>] 104 """ 104 """} django/trunk/tests/modeltests/pagination/models.py
r3075 r3661 16 16 return self.headline 17 17 18 API_TESTS ="""18 __test__ = {'API_TESTS':""" 19 19 # prepare a list of objects for pagination 20 20 >>> from datetime import datetime … … 65 65 9 66 66 67 """ 67 """} django/trunk/tests/modeltests/properties/models.py
r3145 r3661 21 21 full_name_2 = property(_get_full_name, _set_full_name) 22 22 23 API_TESTS ="""23 __test__ = {'API_TESTS':""" 24 24 >>> a = Person(first_name='John', last_name='Lennon') 25 25 >>> a.save() … … 38 38 >>> a2.first_name 39 39 'Paul' 40 """ 40 """} django/trunk/tests/modeltests/reserved_names/models.py
r3075 r3661 25 25 return self.when 26 26 27 API_TESTS ="""27 __test__ = {'API_TESTS':""" 28 28 >>> import datetime 29 29 >>> day1 = datetime.date(2005, 1, 1) … … 54 54 >>> Thing.objects.filter(where__month=1) 55 55 [<Thing: a>] 56 """ 56 """} django/trunk/tests/modeltests/reverse_lookup/models.py
r3075 r3661 28 28 return self.name 29 29 30 API_TESTS ="""30 __test__ = {'API_TESTS':""" 31 31 >>> john = User(name="John Doe") 32 32 >>> john.save() … … 57 57 ... 58 58 TypeError: Cannot resolve keyword 'choice' into field 59 """ 59 """} django/trunk/tests/modeltests/save_delete_hooks/models.py
r3075 r3661 25 25 print "After deletion" 26 26 27 API_TESTS ="""27 __test__ = {'API_TESTS':""" 28 28 >>> p1 = Person(first_name='John', last_name='Smith') 29 29 >>> p1.save() … … 40 40 >>> Person.objects.all() 41 41 [] 42 """ 42 """} django/trunk/tests/modeltests/serializers/models.py
r3237 r3661 38 38 return self.headline 39 39 40 API_TESTS ="""40 __test__ = {'API_TESTS':""" 41 41 # Create some data: 42 42 >>> from datetime import datetime … … 119 119 [<Article: Just kidding; I love TV poker>, <Article: Time to reform copyright>] 120 120 121 """ 121 """} django/trunk/tests/modeltests/str/models.py
r3072 r3661 18 18 return self.headline 19 19 20 API_TESTS ="""20 __test__ = {'API_TESTS':""" 21 21 # Create an Article. 22 22 >>> from datetime import datetime … … 29 29 >>> a 30 30 <Article: Area man programs in Python> 31 """ 31 """} django/trunk/tests/modeltests/transactions/models.py
r3075 r3661 18 18 return "%s %s" % (self.first_name, self.last_name) 19 19 20 API_TESTS ="""20 __test__ = {'API_TESTS':""" 21 21 >>> from django.db import connection, transaction 22 """ 22 """} 23 23 24 24 from django.conf import settings … … 27 27 28 28 if building_docs or settings.DATABASE_ENGINE != 'mysql': 29 API_TESTS+= """29 __test__['API_TESTS'] += """ 30 30 # the default behavior is to autocommit after each save() action 31 31 >>> def create_a_reporter_then_fail(first, last): django/trunk/tests/modeltests/validation/models.py
r3075 r3661 21 21 return self.name 22 22 23 API_TESTS ="""23 __test__ = {'API_TESTS':""" 24 24 25 25 >>> import datetime … … 147 147 {'email': ['Enter a valid e-mail address.']} 148 148 149 """ 149 """} django/trunk/tests/regressiontests/cache/tests.py
r2687 r3661 3 3 4 4 from django.core.cache import cache 5 import time 5 import time, unittest 6 6 7 7 # functions/classes for complex data type tests … … 12 12 return 24 13 13 14 # simple set/get 15 cache.set("key", "value") 16 assert cache.get("key") == "value" 14 class Cache(unittest.TestCase): 15 def test_simple(self): 16 # simple set/get 17 cache.set("key", "value") 18 self.assertEqual(cache.get("key"), "value") 17 19 18 # get with non-existent keys 19 assert cache.get("does not exist") is None 20 assert cache.get("does not exist", "bang!") == "bang!" 20 def test_non_existent(self): 21 # get with non-existent keys 22 self.assertEqual(cache.get("does not exist"), None) 23 self.assertEqual(cache.get("does not exist", "bang!"), "bang!") 21 24 22 # get_many 23 cache.set('a', 'a') 24 cache.set('b', 'b') 25 cache.set('c', 'c') 26 cache.set('d', 'd') 27 assert cache.get_many(['a', 'c', 'd']) == {'a' : 'a', 'c' : 'c', 'd' : 'd'} 28 assert cache.get_many(['a', 'b', 'e']) == {'a' : 'a', 'b' : 'b'} 25 def test_get_many(self): 26 # get_many 27 cache.set('a', 'a') 28 cache.set('b', 'b') 29 cache.set('c', 'c') 30 cache.set('d', 'd') 31 self.assertEqual(cache.get_many(['a', 'c', 'd']), {'a' : 'a', 'c' : 'c', 'd' : 'd'}) 32 self.assertEqual(cache.get_many(['a', 'b', 'e']), {'a' : 'a', 'b' : 'b'}) 29 33 30 # delete 31 cache.set("key1", "spam") 32 cache.set("key2", "eggs") 33 assert cache.get("key1") == "spam" 34 cache.delete("key1") 35 assert cache.get("key1") is None 36 assert cache.get("key2") == "eggs" 34 def test_delete(self): 35 # delete 36 cache.set("key1", "spam") 37 cache.set("key2", "eggs") 38 self.assertEqual(cache.get("key1"), "spam") 39 cache.delete("key1") 40 self.assertEqual(cache.get("key1"), None) 41 self.assertEqual(cache.get("key2"), "eggs") 37 42 38 # has_key 39 cache.set("hello", "goodbye") 40 assert cache.has_key("hello") == True 41 assert cache.has_key("goodbye") == False 43 def test_has_key(self): 44 # has_key 45 cache.set("hello", "goodbye") 46 self.assertEqual(cache.has_key("hello"), True) 47 self.assertEqual(cache.has_key("goodbye"), False) 42 48 43 # test data types 44 stuff = { 45 'string' : 'this is a string', 46 'int' : 42, 47 'list' : [1, 2, 3, 4], 48 'tuple' : (1, 2, 3, 4), 49 'dict' : {'A': 1, 'B' : 2}, 50 'function' : f, 51 'class' : C, 52 } 53 for (key, value) in stuff.items(): 54 cache.set(key, value) 55 assert cache.get(key) == value 49 def test_data_types(self): 50 # test data types 51 stuff = { 52 'string' : 'this is a string', 53 'int' : 42, 54 'list' : [1, 2, 3, 4], 55 'tuple' : (1, 2, 3, 4), 56 'dict' : {'A': 1, 'B' : 2}, 57 'function' : f, 58 'class' : C, 59 } 60 for (key, value) in stuff.items(): 61 cache.set(key, value) 62 self.assertEqual(cache.get(key), value) 56 63 57 # expiration 58 cache.set('expire', 'very quickly', 1) 59 time.sleep(2) 60 assert cache.get("expire") == None 64 def test_expiration(self): 65 # expiration 66 cache.set('expire', 'very quickly', 1) 67 time.sleep(2) 68 self.assertEqual(cache.get("expire"), None) 69 70 if __name__ == '__main__': 71 unittest.main() django/trunk/tests/regressiontests/db_typecasts/tests.py
r2809 r3661 2 2 3 3 from django.db.backends import util as typecasts 4 import datetime 4 import datetime, unittest 5 5 6 6 TEST_CASES = { … … 46 46 } 47 47 48 for k, v in TEST_CASES.items(): 49 for inpt, expected in v: 50 got = getattr(typecasts, k)(inpt) 51 assert got == expected, "In %s: %r doesn't match %r. Got %r instead." % (k, inpt, expected, got) 48 class DBTypeCasts(unittest.TestCase): 49 def test_typeCasts(self): 50 for k, v in TEST_CASES.items(): 51 for inpt, expected in v: 52 got = getattr(typecasts, k)(inpt) 53 assert got == expected, "In %s: %r doesn't match %r. Got %r instead." % (k, inpt, expected, got) 54 55 if __name__ == '__main__': 56 unittest.main()
