diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2008-02-22 12:50:10 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2008-02-22 12:50:10 +0000 |
| commit | c1f45c326c4bdeb8821844f6ee4bfd2817ab6a63 (patch) | |
| tree | 6f7629baf1ea3d4da32a1f2958d5eca9f8688bdd /tests | |
| parent | 54546f23f09a989ee3c1c3e629eac98706b6262e (diff) | |
Fixed #6436 -- Added check for absolute paths in fixture loading. Fixtures specified as an absolute path were being loaded multiple times. Thanks to btoll@bestweb.net for the report, fix, and catch of a duplicate ticket.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7145 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/fixtures_regress/fixtures/absolute.json | 9 | ||||
| -rw-r--r-- | tests/regressiontests/fixtures_regress/models.py | 22 |
2 files changed, 31 insertions, 0 deletions
diff --git a/tests/regressiontests/fixtures_regress/fixtures/absolute.json b/tests/regressiontests/fixtures_regress/fixtures/absolute.json new file mode 100644 index 0000000000..37ed3f6886 --- /dev/null +++ b/tests/regressiontests/fixtures_regress/fixtures/absolute.json @@ -0,0 +1,9 @@ +[ + { + "pk": "1", + "model": "fixtures_regress.absolute", + "fields": { + "name": "Load Absolute Path Test" + } + } +]
\ No newline at end of file diff --git a/tests/regressiontests/fixtures_regress/models.py b/tests/regressiontests/fixtures_regress/models.py index a62925eb37..144debe05a 100644 --- a/tests/regressiontests/fixtures_regress/models.py +++ b/tests/regressiontests/fixtures_regress/models.py @@ -1,6 +1,7 @@ from django.db import models from django.contrib.auth.models import User from django.conf import settings +import os class Animal(models.Model): name = models.CharField(max_length=150) @@ -28,6 +29,16 @@ class Stuff(models.Model): name = None return unicode(name) + u' is owned by ' + unicode(self.owner) +class Absolute(models.Model): + name = models.CharField(max_length=40) + + load_count = 0 + + def __init__(self, *args, **kwargs): + super(Absolute, self).__init__(*args, **kwargs) + Absolute.load_count += 1 + + __test__ = {'API_TESTS':""" >>> from django.core import management @@ -49,4 +60,15 @@ __test__ = {'API_TESTS':""" >>> Stuff.objects.all() [<Stuff: None is owned by None>] +############################################### +# Regression test for ticket #6436 -- +# os.path.join will throw away the initial parts of a path if it encounters +# an absolute path. This means that if a fixture is specified as an absolute path, +# we need to make sure we don't discover the absolute path in every fixture directory. + +>>> load_absolute_path = os.path.join(os.path.dirname(__file__), 'fixtures', 'absolute.json') +>>> management.call_command('loaddata', load_absolute_path, verbosity=0) +>>> Absolute.load_count +1 + """} |
