Opened 9 years ago

Closed 8 years ago

#3731 closed (worksforme)

Missing exception output with ` test`

Reported by: Benjamin Schwarze Owned by: ttarabula
Component: Testing framework Version: master
Severity: Keywords: sprintsept14
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


I tried to set up a splitted test environment today.

I created a tests directory within my application directory and added an file.
This looks like that:

  - myapp
    - tests

Within the file I imported my test cases from other modules.

After that I executed the test suite via:

bschwarze@devbox:~/mysite$ ./ test
Creating test database...
Creating table django_admin_log
Creating table auth_message
Creating table auth_group
Creating table auth_user
Creating table auth_permission
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table myapp_car
Installing index for admin.LogEntry model
Installing index for auth.Message model
Installing index for auth.Permission model
Installing index for myapp.Car model
Loading 'initial_data' fixtures...
No fixtures found.

Ran 0 tests in 0.000s

Destroying test database...

But it reported Run 0 tests ..., although I was sure I added my tests correctly.
After asking for help in Django IRC, I tried to import my tests module in Django shell.

This gave me an import error. After fixing that everything worked fine.

I think test should output such import errors, too.

Change History (6)

comment:1 Changed 9 years ago by SmileyChris

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Summary changed from Missing exception output with splitted to Missing exception output with ` test`
  • Triage Stage changed from Unreviewed to Design decision needed

comment:2 Changed 8 years ago by russellm

  • Triage Stage changed from Design decision needed to Accepted

Silent failure is never a good thing.

comment:3 Changed 8 years ago by ttarabula

  • Owner changed from nobody to ttarabula
  • Status changed from new to assigned

comment:4 Changed 8 years ago by ttarabula

  • Keywords sprintsept14 added

comment:5 Changed 8 years ago by ttarabula

  • Triage Stage changed from Accepted to Unreviewed

Can't replicate this bug. It appears to have been fixed at some point.

In django.test.simple, the inner try/except seems to deal with this case:

def get_tests(app_module):
        app_path = app_module.__name__.split('.')[:-1]
        test_module = __import__('.'.join(app_path + [TEST_MODULE]), {}, {}, TEST_MODULE)
    except ImportError, e:
        # Couldn't import Was it due to a missing file, or
        # due to an import error in a that actually exists?
        import os.path
        from imp import find_module
            mod = find_module(TEST_MODULE, [os.path.dirname(app_module.__file__)])
        except ImportError:
            # 'tests' module doesn't exist. Move on.
            test_module = None
            # The module exists, so there must be an import error in the 
            # test module itself. We don't need the module; so if the
            # module was a single file module (i.e.,, close the file
            # handle returned by find_module. Otherwise, the test module
            # is a directory, and there is nothing to close.
            if mod[0]:
    return test_module

comment:6 Changed 8 years ago by ttarabula

  • Resolution set to worksforme
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.
Back to Top