summaryrefslogtreecommitdiff
path: root/tests/forms_tests/models.py
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2014-11-18 21:52:26 +0100
committerAymeric Augustin <aymeric.augustin@m4x.org>2014-11-19 21:35:40 +0100
commitb69b4008d1046c1682728f20b57423870fea710b (patch)
tree7d1d2b266c47340fdac7c3de5b095e659d88adc2 /tests/forms_tests/models.py
parentf88ad710faf0ebb53d96d6ab59f525c9aea4be41 (diff)
Removed usage of a global variable.
Diffstat (limited to 'tests/forms_tests/models.py')
-rw-r--r--tests/forms_tests/models.py16
1 files changed, 6 insertions, 10 deletions
diff --git a/tests/forms_tests/models.py b/tests/forms_tests/models.py
index 2ec0aa11ef..82fa005025 100644
--- a/tests/forms_tests/models.py
+++ b/tests/forms_tests/models.py
@@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-import os
import datetime
+import itertools
+import os
import tempfile
from django.core.files.storage import FileSystemStorage
@@ -10,6 +11,10 @@ from django.db import models
from django.utils.encoding import python_2_unicode_compatible
+callable_default_counter = itertools.count()
+callable_default = lambda: next(callable_default_counter)
+
+
temp_storage_location = tempfile.mkdtemp(dir=os.environ['DJANGO_TEST_TEMP_DIR'])
temp_storage = FileSystemStorage(location=temp_storage_location)
@@ -18,15 +23,6 @@ class BoundaryModel(models.Model):
positive_integer = models.PositiveIntegerField(null=True, blank=True)
-callable_default_value = 0
-
-
-def callable_default():
- global callable_default_value
- callable_default_value = callable_default_value + 1
- return callable_default_value
-
-
class Defaults(models.Model):
name = models.CharField(max_length=255, default='class default value')
def_date = models.DateField(default=datetime.date(1980, 1, 1))