jezdez / django-discover-runner

A Django test runner based on unittest2's test discovery.
http://pypi.python.org/pypi/django-discover-runner
Other
132 stars 13 forks source link

Trying to test multiple apps.... Ran 0 tests in 0.000s #15

Closed typeshige closed 11 years ago

typeshige commented 11 years ago

I have 10+ apps that I want to test and I'm trying to get it to work with django-discover-runner.

If I run one, it looks fine:

± % ./manage.py test content --configuration=Test
Creating test database for alias 'default'...
/home/django/.virtualenvs/astrobiology-alpha/local/lib/python2.7/site-packages/django/utils/hashcompat.py:9: DeprecationWarning: django.utils.hashcompat is deprecated; use hashlib instead
  DeprecationWarning)

.../home/django/.virtualenvs/astrobiology-alpha/local/lib/python2.7/site-packages/django/utils/text.py:221: DeprecationWarning: This function has been deprecated. Use the Truncator class in django.utils.text instead.
  'in django.utils.text instead.', category=DeprecationWarning)

............
----------------------------------------------------------------------
Ran 15 tests in 2.784s

OK
Destroying test database for alias 'default'...

Tests are in file 'test_models.py' in content/tests/

If I run another one, it also looks fine:

± % ./manage.py test groups --configuration=Test
/home/django/.virtualenvs/astrobiology-alpha/local/lib/python2.7/site-packages/django/utils/hashcompat.py:9: DeprecationWarning: django.utils.hashcompat is deprecated; use hashlib instead
  DeprecationWarning)

Creating test database for alias 'default'...
..........E.....
======================================================================
ERROR: test_team_members (tests.test_models.TeamTest)
----------------------------------------------------------------------
Traceback (most recent call last):
.
.
.
IntegrityError: duplicate key value violates unique constraint "reports_naiprojectreport_pkey"

----------------------------------------------------------------------
Ran 16 tests in 0.442s

FAILED (errors=1)
Destroying test database for alias 'default'...

Ok, failed test, but it still found and ran them.

Test file test_models.py in groups/tests/

Let's try running both:

± % ./manage.py test content groups --configuration=Test --traceback
Creating test database for alias 'default'...
/home/django/.virtualenvs/astrobiology-alpha/local/lib/python2.7/site-packages/django/utils/hashcompat.py:9: DeprecationWarning: django.utils.hashcompat is deprecated; use hashlib instead
  DeprecationWarning)

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK
Destroying test database for alias 'default'...

Am I doing something wrong? The above should be valid, right?

Here is my Test configuration:

class Test(Base):

    DATABASES = {
        'default': {
            'ENGINE': 'django.contrib.gis.db.backends.postgis',
            'NAME': 'astrobiology_' + BUILD,
            'USER': 'astrobiology',
            'PASSWORD': 'xxxxxxxxxx',
        },
    }

    @property
    def INSTALLED_APPS(self):
        return (
            #'django_coverage',
            'django_nose',
            'discover_runner',
            'django_jenkins',
        ) + super(Test, self).INSTALLED_APPS

    JENKINS_TASKS = (
        'django_jenkins.tasks.with_coverage',
        'django_jenkins.tasks.django_tests',   # select one django or
        'django_jenkins.tasks.dir_tests',      # directory tests discovery
        'django_jenkins.tasks.run_pep8',
        #'django_jenkins.tasks.run_flake8',
        'django_jenkins.tasks.run_pyflakes',
        'django_jenkins.tasks.run_graphmodels',
        'django_jenkins.tasks.run_pylint',
        'django_jenkins.tasks.run_csslint',
        'django_jenkins.tasks.run_sloccount',
        'django_jenkins.tasks.run_jshint',
        'django_jenkins.tasks.lettuce_tests',
    )

    TEST_RUNNER = 'discover_runner.DiscoverRunner'
    #TEST_DISCOVER_TOP_LEVEL = TEST_DISCOVER_ROOT = PROJECT_ROOT
    #JENKINS_TEST_RUNNER = 'django_jenkins.nose_runner.CINoseTestSuiteRunner'
    DATABASE_ROUTERS = []

Is there anything I'm doing wrong?

Thanks!

carljm commented 11 years ago

discover-runner doesn't really work properly with multiple test labels; see the hack at https://github.com/jezdez/django-discover-runner/blob/master/discover_runner/runner.py#L44

The updated version of discover-runner that was recently merged into Django core for 1.6 does handle this correctly, so the right fix here is probably to backport that code to django-discover-runner for users of pre-1.6 Django versions.

jezdez commented 11 years ago

I just released django-discover-runner which backports the test runner from Django 1.6. Please try again and don't hesitate to let me know if it doesn't work.