changeset 6:8d0793b2358b

update testapp to django 1.0b1
author Victor Ng <victor@monkeybean.ca>
date Thu, 28 Aug 2008 11:44:53 -0400
parents 22ae9aa457af
children dfba3a3a4343
files examples/README.TXT examples/project/__init__.py examples/project/manage.py examples/project/settings.py examples/project/urls.py examples/project/zoo/models.py examples/project/zoo/test_doctest_modules.py
diffstat 6 files changed, 198 insertions(+), 159 deletions(-) [+]
line wrap: on
line diff
--- a/examples/README.TXT	Thu Aug 28 11:29:21 2008 -0400
+++ b/examples/README.TXT	Thu Aug 28 11:44:53 2008 -0400
@@ -1,25 +1,48 @@
-If you change directory into the 'project' directory, you should be able  to
-run the nose test runner and get reasonable results.
+The 'project' sample Django project was created using Django 1.0b1.
 
-Note that you *won't* be running your doctests unless you tell nose to do so.
+Using a more recent version of Django may cause problems.  You've been
+warned.
+
 
-As usual, you need to tell nose to run doctest test strings in modules that
-contain standard test classes.
+If you change directory into the 'project' directory, you should be
+able  to run the nose test runner and get reasonable results.
 
-A successful run should hit *7* test cases.
+Note that you *won't* be running your doctests unless you tell nose to
+do so.
+
+As usual, you need to tell nose to run doctest test strings in modules
+that contain standard test classes.
+
+A successful run should hit *11* test cases excercising :
 
-    C:\dev\nosedjango\examples\project>nosetests -v --with-django --with-doctest --d
-    octest-tests --doctest-tests
-    Doctest: project.zoo.models ... ok
-    Doctest: project.zoo.models.Zoo ... ok
-    Doctest: project.zoo.models.Zoo.__str__ ... ok
-    Doctest: project.zoo.models.func ... ok
-    This is just a stub for a regular test method ... ok
-    Doctest: project.zoo.test_foo.blah ... ok
-    project.tests.test_views.test_view_index ... ok
+    * race conditions between test cases that create objects in test
+      methods
+    * race conditions between test cases that create objects in 
+      fixture loading
+    * doctests
+    * test functions
+    * mixes of doctests and test modules
+    * docstrings in models
+
+--- Sample test run below ---
 
-    ----------------------------------------------------------------------
-    Ran 7 tests in 0.562s
+C:\dev\nosedjango\examples\project>nosetests -v --with-django --with-doctest --doctest-tests --doctest-tests
+doctest: project.zoo.models.zoo ... ok
+Doctest: project.zoo.models.Zoo.__str__ ... ok
+Doctest: project.zoo.models.func ... ok
+This is just a stub for a regular test method ... ok
+Doctest: project.zoo.test_doctest_modules.test_docstring ... ok
+Doctest: project.zoo.test_doctest_modules.test_docstring ... ok
+project.zoo.test_fixtures.TestFixture1.test_count ... ok
+project.zoo.test_fixtures.TestFixture2.test_count ... ok
+project.zoo.test_race.TestDBRace1.test1 ... ok
+project.zoo.test_race.TestDBRace2.test1 ... ok
+project.tests.test_views.test_view_index ... ok
 
-    OK
-    Destroying test database...
+----------------------------------------------------------------------
+Ran 11 tests in 0.859s
+
+OK
+Destroying test database...
+
+C:\dev\nosedjango\examples\project>
--- a/examples/project/manage.py	Thu Aug 28 11:29:21 2008 -0400
+++ b/examples/project/manage.py	Thu Aug 28 11:44:53 2008 -0400
@@ -1,11 +1,11 @@
-#!/usr/bin/env python
-from django.core.management import execute_manager
-try:
-    import settings # Assumed to be in the same directory.
-except ImportError:
-    import sys
-    sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
-    sys.exit(1)
-
-if __name__ == "__main__":
-    execute_manager(settings)
+#!/usr/bin/env python
+from django.core.management import execute_manager
+try:
+    import settings # Assumed to be in the same directory.
+except ImportError:
+    import sys
+    sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
+    sys.exit(1)
+
+if __name__ == "__main__":
+    execute_manager(settings)
--- a/examples/project/settings.py	Thu Aug 28 11:29:21 2008 -0400
+++ b/examples/project/settings.py	Thu Aug 28 11:44:53 2008 -0400
@@ -1,74 +1,82 @@
-# Django settings for dtt project.
-
-DEBUG = True
-TEMPLATE_DEBUG = DEBUG
-
-ADMINS = (
-    # ('Your Name', 'your_email@domain.com'),
-)
-
-MANAGERS = ADMINS
-
-DATABASE_ENGINE = 'sqlite3'           # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
-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.
-#DATABASE_PORT = ''             # Set to empty string for default. Not used with sqlite3.
-
-
-# Local time zone for this installation. All choices can be found here:
-# http://www.postgresql.org/docs/current/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
-TIME_ZONE = 'America/Chicago'
-
-# Language code for this installation. All choices can be found here:
-# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
-# http://blogs.law.harvard.edu/tech/stories/storyReader$15
-LANGUAGE_CODE = 'en-us'
-
-SITE_ID = 1
-
-# Absolute path to the directory that holds media.
-# Example: "/home/media/media.lawrence.com/"
-MEDIA_ROOT = ''
-
-# URL that handles the media served from MEDIA_ROOT.
-# Example: "http://media.lawrence.com"
-MEDIA_URL = ''
-
-# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
-# trailing slash.
-# Examples: "http://foo.com/media/", "/media/".
-ADMIN_MEDIA_PREFIX = '/media/'
-
-# Make this unique, and don't share it with anybody.
-SECRET_KEY = 'gl6%_ew1u)@)4#^blbji7(25urbdmr82jtov=%i$crckk^t%y@'
-
-# List of callables that know how to import templates from various sources.
-TEMPLATE_LOADERS = (
-    'django.template.loaders.filesystem.load_template_source',
-    'django.template.loaders.app_directories.load_template_source',
-#     'django.template.loaders.eggs.load_template_source',
-)
-
-MIDDLEWARE_CLASSES = (
-    'django.middleware.common.CommonMiddleware',
-    'django.contrib.sessions.middleware.SessionMiddleware',
-    'django.contrib.auth.middleware.AuthenticationMiddleware',
-    'django.middleware.doc.XViewMiddleware',
-)
-
-ROOT_URLCONF = 'dtt.urls'
-
-TEMPLATE_DIRS = (
-    # Put strings here, like "/home/html/django_templates".
-    # Always use forward slashes, even on Windows.
-)
-
-INSTALLED_APPS = (
-    'django.contrib.contenttypes',
-    'django.contrib.auth',
-    'django.contrib.sessions',
-    'django.contrib.sites',
-    'project.zoo'
-)
+# Django settings for p1 project.
+
+DEBUG = True
+TEMPLATE_DEBUG = DEBUG
+
+ADMINS = (
+    # ('Your Name', 'your_email@domain.com'),
+)
+
+MANAGERS = ADMINS
+
+DATABASE_ENGINE = 'sqlite3'           # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
+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.
+DATABASE_PORT = ''             # Set to empty string for default. Not used with sqlite3.
+
+# Local time zone for this installation. Choices can be found here:
+# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
+# although not all choices may be available on all operating systems.
+# If running in a Windows environment this must be set to the same as your
+# system time zone.
+TIME_ZONE = 'America/Chicago'
+
+# Language code for this installation. All choices can be found here:
+# http://www.i18nguy.com/unicode/language-identifiers.html
+LANGUAGE_CODE = 'en-us'
+
+SITE_ID = 1
+
+# If you set this to False, Django will make some optimizations so as not
+# to load the internationalization machinery.
+USE_I18N = True
+
+# Absolute path to the directory that holds media.
+# Example: "/home/media/media.lawrence.com/"
+MEDIA_ROOT = ''
+
+# URL that handles the media served from MEDIA_ROOT. Make sure to use a
+# trailing slash if there is a path component (optional in other cases).
+# Examples: "http://media.lawrence.com", "http://example.com/media/"
+MEDIA_URL = ''
+
+# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
+# trailing slash.
+# Examples: "http://foo.com/media/", "/media/".
+ADMIN_MEDIA_PREFIX = '/media/'
+
+# Make this unique, and don't share it with anybody.
+SECRET_KEY = '3r+%mj&(wg@l2wcq)&g!x^cj2@u28vr=pahbive*#am44-p$u)'
+
+# List of callables that know how to import templates from various sources.
+TEMPLATE_LOADERS = (
+    'django.template.loaders.filesystem.load_template_source',
+    'django.template.loaders.app_directories.load_template_source',
+#     'django.template.loaders.eggs.load_template_source',
+)
+
+MIDDLEWARE_CLASSES = (
+    'django.middleware.common.CommonMiddleware',
+    'django.contrib.sessions.middleware.SessionMiddleware',
+    'django.contrib.auth.middleware.AuthenticationMiddleware',
+    'django.middleware.doc.XViewMiddleware',
+)
+
+ROOT_URLCONF = 'p1.urls'
+
+TEMPLATE_DIRS = (
+    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
+    # Always use forward slashes, even on Windows.
+    # Don't forget to use absolute paths, not relative paths.
+)
+
+INSTALLED_APPS = (
+    'django.contrib.admin',
+    'django.contrib.auth',
+    'django.contrib.contenttypes',
+    'django.contrib.sessions',
+    'django.contrib.sites',
+    'project.zoo'
+)
--- a/examples/project/urls.py	Thu Aug 28 11:29:21 2008 -0400
+++ b/examples/project/urls.py	Thu Aug 28 11:44:53 2008 -0400
@@ -1,9 +1,16 @@
-from django.conf.urls.defaults import *
-
-urlpatterns = patterns('',
-    # Example:
-    # (r'^dtt/', include('dtt.apps.foo.urls.foo')),
-
-    # Uncomment this for admin:
-#     (r'^admin/', include('django.contrib.admin.urls')),
-)
+from django.conf.urls.defaults import *
+
+# Uncomment the next two lines to enable the admin:
+# from django.contrib import admin
+# admin.autodiscover()
+
+urlpatterns = patterns('',
+    # Example:
+    # (r'^p1/', include('p1.foo.urls')),
+
+    # Uncomment the next line to enable admin documentation:
+    # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
+
+    # Uncomment the next line for to enable the admin:
+    # (r'^admin/(.*)', admin.site.root),
+)
--- a/examples/project/zoo/models.py	Thu Aug 28 11:29:21 2008 -0400
+++ b/examples/project/zoo/models.py	Thu Aug 28 11:44:53 2008 -0400
@@ -1,45 +1,46 @@
-"""
-Module-level doctest.
-
-    >>> Zoo
-    <class 'project.zoo.models.Zoo'>
-    >>> 1 + 1
-    2
-"""
-from django.db import models
-
-# Create your models here.
-class Zoo(models.Model):
-    """
-    Class-level doctest
-
-    >>> Zoo
-    <class 'project.zoo.models.Zoo'>
-    >>> 1 + 1
-    2
-    >>> Zoo.objects.all()
-    []
-    >>> z = Zoo(name='Bronx')
-    >>> z.save()
-    >>> z
-    <Zoo: Bronx>
-    >>> Zoo.objects.all()
-    [<Zoo: Bronx>]
-    """
-    name = models.CharField(max_length=100)
-
-    def __str__(self):
-        """
-        Function in class test
-        >>> 1 + 2
-        3
-        """
-        return self.name
-
-def func():
-    """
-    Function-level test
-        >>> 1+3
-        4
-    """
-    pass
+from django.db import models
+
+"""
+Module-level doctest.
+
+    >>> Zoo
+    <class 'project.zoo.models.Zoo'>
+    >>> 1 + 1
+    2
+"""
+
+def func():
+    """
+    Function-level test
+        >>> 1+3
+        4
+    """
+    pass
+# Create your models here.
+class Zoo(models.Model):
+    """
+    Class-level doctest
+
+    >>> Zoo
+    <class 'project.zoo.models.Zoo'>
+    >>> 1 + 1
+    2
+    >>> Zoo.objects.all()
+    []
+    >>> z = Zoo(name='Bronx')
+    >>> z.save()
+    >>> z
+    <Zoo: Bronx>
+    >>> Zoo.objects.all()
+    [<Zoo: Bronx>]
+    """
+    name = models.CharField(max_length=100)
+
+    def __str__(self):
+        """
+        Function in class test
+        >>> 1 + 2
+        3
+        """
+        return self.name
+
--- a/examples/project/zoo/test_doctest_modules.py	Thu Aug 28 11:29:21 2008 -0400
+++ b/examples/project/zoo/test_doctest_modules.py	Thu Aug 28 11:44:53 2008 -0400
@@ -3,7 +3,7 @@
     ''' This is just a stub for a regular test method'''
     pass
 
-def blah():
+def test_docstring():
     '''
     This is a doctest that might get skipped