Matthew Schinckel avatar Matthew Schinckel committed 20f02b3

Add coverage support to tox.

Comments (0)

Files changed (4)

-tox
+tox
+coverage
     global_settings.STATIC_ROOT = global_settings.MEDIA_ROOT
     
     global_settings.SECRET_KEY = '334ebe58-a77d-4321-9d01-a7d2cb8d3eea'
+    global_settings.TEST_RUNNER = 'django_coverage.coverage_runner.CoverageRunner'
     
     from django.test.utils import get_runner
     test_runner = get_runner(global_settings)

timedelta/forms.py

         super(TimedeltaFormField, self).__init__(*args, **defaults)
         
     def clean(self, value):
+        """
+        This doesn't really need to be here: it should be tested in
+        parse()...
+        
+        >>> t = TimedeltaFormField()
+        >>> t.clean('1 day')
+        datetime.timedelta(1)
+        >>> t.clean('1 day, 0:00:00')
+        datetime.timedelta(1)
+        >>> t.clean('1 day, 8:42:42.342')
+        datetime.timedelta(1, 31362, 342000)
+        >>> t.clean('3 days, 8:42:42.342161')
+        datetime.timedelta(3, 31362, 342161)
+        >>> try:
+        ...  t.clean('3 days, 8:42:42.3.42161')
+        ... except forms.ValidationError as arg:
+        ...  six.print_(arg.messages[0])
+        Enter a valid time span: e.g. "3 days, 4 hours, 2 minutes"
+        >>> t.clean('5 day, 8:42:42')
+        datetime.timedelta(5, 31362)
+        >>> t.clean('1 days')
+        datetime.timedelta(1)
+        >>> t.clean('1 second')
+        datetime.timedelta(0, 1)
+        >>> t.clean('1 sec')
+        datetime.timedelta(0, 1)
+        >>> t.clean('10 seconds')
+        datetime.timedelta(0, 10)
+        >>> t.clean('30 seconds')
+        datetime.timedelta(0, 30)
+        >>> t.clean('1 minute, 30 seconds')
+        datetime.timedelta(0, 90)
+        >>> t.clean('2.5 minutes')
+        datetime.timedelta(0, 150)
+        >>> t.clean('2 minutes, 30 seconds')
+        datetime.timedelta(0, 150)
+        >>> t.clean('.5 hours')
+        datetime.timedelta(0, 1800)
+        >>> t.clean('30 minutes')
+        datetime.timedelta(0, 1800)
+        >>> t.clean('1 hour')
+        datetime.timedelta(0, 3600)
+        >>> t.clean('5.5 hours')
+        datetime.timedelta(0, 19800)
+        >>> t.clean('1 day, 1 hour, 30 mins')
+        datetime.timedelta(1, 5400)
+        >>> t.clean('8 min')
+        datetime.timedelta(0, 480)
+        >>> t.clean('3 days, 12 hours')
+        datetime.timedelta(3, 43200)
+        >>> t.clean('3.5 day')
+        datetime.timedelta(3, 43200)
+        >>> t.clean('1 week')
+        datetime.timedelta(7)
+        >>> t.clean('2 weeks, 2 days')
+        datetime.timedelta(16)
+        >>> try:
+        ...  t.clean(six.u('2 we\xe8k, 2 days'))
+        ... except forms.ValidationError as arg:
+        ...  six.print_(arg.messages[0])
+        Enter a valid time span: e.g. "3 days, 4 hours, 2 minutes"
+        """
+        
         super(TimedeltaFormField, self).clean(value)
         if value == '' and not self.required:
             return ''
         defaults = {'widget':forms.Select(choices=choices)}
         defaults.update(kwargs)
         super(TimedeltaChoicesField, self).__init__(*args, **defaults)
-
-
-def test_clean():
-    """
-    >>> t = TimedeltaFormField()
-    >>> t.clean('1 day')
-    datetime.timedelta(1)
-    >>> t.clean('1 day, 0:00:00')
-    datetime.timedelta(1)
-    >>> t.clean('1 day, 8:42:42.342')
-    datetime.timedelta(1, 31362, 342000)
-    >>> t.clean('3 days, 8:42:42.342161')
-    datetime.timedelta(3, 31362, 342161)
-    >>> try:
-    ...  t.clean('3 days, 8:42:42.3.42161')
-    ... except forms.ValidationError as arg:
-    ...  six.print_(arg.messages[0])
-    Enter a valid time span: e.g. "3 days, 4 hours, 2 minutes"
-    >>> t.clean('5 day, 8:42:42')
-    datetime.timedelta(5, 31362)
-    >>> t.clean('1 days')
-    datetime.timedelta(1)
-    >>> t.clean('1 second')
-    datetime.timedelta(0, 1)
-    >>> t.clean('1 sec')
-    datetime.timedelta(0, 1)
-    >>> t.clean('10 seconds')
-    datetime.timedelta(0, 10)
-    >>> t.clean('30 seconds')
-    datetime.timedelta(0, 30)
-    >>> t.clean('1 minute, 30 seconds')
-    datetime.timedelta(0, 90)
-    >>> t.clean('2.5 minutes')
-    datetime.timedelta(0, 150)
-    >>> t.clean('2 minutes, 30 seconds')
-    datetime.timedelta(0, 150)
-    >>> t.clean('.5 hours')
-    datetime.timedelta(0, 1800)
-    >>> t.clean('30 minutes')
-    datetime.timedelta(0, 1800)
-    >>> t.clean('1 hour')
-    datetime.timedelta(0, 3600)
-    >>> t.clean('5.5 hours')
-    datetime.timedelta(0, 19800)
-    >>> t.clean('1 day, 1 hour, 30 mins')
-    datetime.timedelta(1, 5400)
-    >>> t.clean('8 min')
-    datetime.timedelta(0, 480)
-    >>> t.clean('3 days, 12 hours')
-    datetime.timedelta(3, 43200)
-    >>> t.clean('3.5 day')
-    datetime.timedelta(3, 43200)
-    >>> t.clean('1 week')
-    datetime.timedelta(7)
-    >>> t.clean('2 weeks, 2 days')
-    datetime.timedelta(16)
-    >>> try:
-    ...  t.clean(six.u('2 we\xe8k, 2 days'))
-    ... except forms.ValidationError as arg:
-    ...  six.print_(arg.messages[0])
-    Enter a valid time span: e.g. "3 days, 4 hours, 2 minutes"
-    """
-    pass
 [tox]
 envlist = py26,py27,py32,pypy,py27-django-1.4,py27-django-1.5,py27-django-trunk
+[base]
+deps=
+  coverage
+  django_coverage
+
 [testenv]
+commands= python setup.py test
 deps=django
-commands= python setup.py test
+  {[base]deps}
+
 [testenv:py27-django-1.4]
 deps= django>=1.4,<1.5
+  {[base]deps}
+
 [testenv:py27-django-1.5]
 deps= django>=1.5,<1.6
+  {[base]deps}
+
 [testenv:py27-django-trunk]
 deps= git+git://github.com/django/django.git
+  {[base]deps}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.