# HG changeset patch # User Victor Ng # Date 1219937361 14400 # Node ID 22ae9aa457af506e0ea5edd3dd5d76f894afc286 # Parent 20bca08c0828caedee7fe5ab1e3a364afa7bba3e excercise more bits of the django 1.0b1 test framework diff -r 20bca08c0828 -r 22ae9aa457af .hgignore --- a/.hgignore Thu Aug 28 10:18:23 2008 -0400 +++ b/.hgignore Thu Aug 28 11:29:21 2008 -0400 @@ -2,6 +2,8 @@ *.orig *.pyc +*.swp +*.db *.egg-info build dist diff -r 20bca08c0828 -r 22ae9aa457af examples/project/settings.py --- a/examples/project/settings.py Thu Aug 28 10:18:23 2008 -0400 +++ b/examples/project/settings.py Thu Aug 28 11:29:21 2008 -0400 @@ -10,7 +10,7 @@ MANAGERS = ADMINS DATABASE_ENGINE = 'sqlite3' # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'. -DATABASE_NAME = ':memory:' # Or path to database file if using sqlite3. +DATABASE_NAME = 'zoo.db' # Or path to database file if using sqlite3. #DATABASE_USER = '' # Not used with sqlite3. #DATABASE_PASSWORD = '' # Not used with sqlite3. #DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. diff -r 20bca08c0828 -r 22ae9aa457af examples/project/zoo/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/project/zoo/__init__.py Thu Aug 28 11:29:21 2008 -0400 @@ -0,0 +1,1 @@ +# place holder diff -r 20bca08c0828 -r 22ae9aa457af examples/project/zoo/fixtures/f1.json --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/project/zoo/fixtures/f1.json Thu Aug 28 11:29:21 2008 -0400 @@ -0,0 +1,1 @@ +[{"pk": 1, "model": "zoo.zoo", "fields": {"name": "f1"}}] diff -r 20bca08c0828 -r 22ae9aa457af examples/project/zoo/fixtures/f2.json --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/project/zoo/fixtures/f2.json Thu Aug 28 11:29:21 2008 -0400 @@ -0,0 +1,1 @@ +[{"pk": 1, "model": "zoo.zoo", "fields": {"name": "f2"}}] diff -r 20bca08c0828 -r 22ae9aa457af examples/project/zoo/test_doctest_modules.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/project/zoo/test_doctest_modules.py Thu Aug 28 11:29:21 2008 -0400 @@ -0,0 +1,13 @@ + +def test_regular_test_method(): + ''' This is just a stub for a regular test method''' + pass + +def blah(): + ''' + This is a doctest that might get skipped + + >>> 5 + 5 + 10 + ''' + diff -r 20bca08c0828 -r 22ae9aa457af examples/project/zoo/test_fixtures.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/project/zoo/test_fixtures.py Thu Aug 28 11:29:21 2008 -0400 @@ -0,0 +1,15 @@ +from project.zoo.models import * + +class TestFixture1(object): + fixtures = ['f1.json'] + + def test_count(self): + assert Zoo.objects.count() == 1 + assert Zoo.objects.get(id=1).name == 'f1' + + +class TestFixture2(object): + fixtures = ['f2.json'] + def test_count(self): + assert Zoo.objects.count() == 1 + assert Zoo.objects.get(id=1).name == 'f2' diff -r 20bca08c0828 -r 22ae9aa457af examples/project/zoo/test_foo.py --- a/examples/project/zoo/test_foo.py Thu Aug 28 10:18:23 2008 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ - -def test_regular_test_method(): - ''' This is just a stub for a regular test method''' - pass - -def blah(): - ''' - This is a doctest that might get skipped - - >>> 5 + 5 - 10 - ''' diff -r 20bca08c0828 -r 22ae9aa457af examples/project/zoo/test_race.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/project/zoo/test_race.py Thu Aug 28 11:29:21 2008 -0400 @@ -0,0 +1,23 @@ +# We have two test classes because we want to induce a race condition +# and ensure that the database is always reset between test methods + +from zoo.models import * + +class TestDBRace1(object): + def setup(self): + assert Zoo.objects.count() == 0 + + def test1(self): + obj = Zoo.objects.create(name='sample1') + assert Zoo.objects.count() == 1 + assert Zoo.objects.all()[0].name == 'sample1' + + +class TestDBRace2(object): + def setup(self): + assert Zoo.objects.count() == 0 + + def test1(self): + obj = Zoo.objects.create(name='sample2') + assert Zoo.objects.count() == 1 + assert Zoo.objects.all()[0].name == 'sample2' diff -r 20bca08c0828 -r 22ae9aa457af nosedjango/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nosedjango/__init__.py Thu Aug 28 11:29:21 2008 -0400 @@ -0,0 +1,1 @@ +# Just a place holder for Windows. diff -r 20bca08c0828 -r 22ae9aa457af nosedjango/nosedjango.py --- a/nosedjango/nosedjango.py Thu Aug 28 10:18:23 2008 -0400 +++ b/nosedjango/nosedjango.py Thu Aug 28 11:29:21 2008 -0400 @@ -4,7 +4,6 @@ are run, and tears the test database (or schema) down after all tests are run. """ -import logging import os, sys import re @@ -16,18 +15,25 @@ # the settings file from nose.importer import add_path os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' +import re +NT_ROOT = re.compile(r"^[a-zA-Z]:\\$") def get_SETTINGS_PATH(): + ''' + Hunt down the settings.py module by going up the FS path + ''' cwd = os.getcwd() while cwd: if 'settings.py' in os.listdir(cwd): break cwd = os.path.split(cwd)[0] - if cwd == '/': + if os.name == 'nt' and NT_ROOT.match(cwd): + return None + elif cwd == '/': return None return cwd + SETTINGS_PATH = get_SETTINGS_PATH() -log = logging.getLogger('nose.plugins.nosedjango') class NoseDjango(Plugin): """ diff -r 20bca08c0828 -r 22ae9aa457af setup.py --- a/setup.py Thu Aug 28 10:18:23 2008 -0400 +++ b/setup.py Thu Aug 28 11:29:21 2008 -0400 @@ -12,7 +12,7 @@ install_requires='nose>=0.10', url = "http://www.assembla.com/spaces/nosedjango", license = 'GNU LGPL', - packages = find_packages(exclude=['tests']), + packages = find_packages(), zip_safe = False, include_package_data = True, entry_points = {