Django

Code

Ticket #3310 (new)

Opened 2 years ago

Last modified 1 year ago

manage.py test does not work if there is not a model.py in the application

Reported by: cmgreen@uab.edu Assigned to: nobody
Milestone: Component: Testing framework
Version: SVN Keywords:
Cc: akaihol+django@ambitone.com Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 1 Patch needs improvement: 0

Description

I have a project where I am not using any models. My appdir looked like

   app/views.py
   app/__init__.py
   app/tests.py

I created a tests.py and the get_apps would fail to find the application, even though it was listed under installed apps. When running ./manage.py test app, it would fail saying there was no application with that label.

Attachments

test_applications_with_no_models.patch (9.0 kB) - added by medhat on 01/23/07 10:56:00.
test_applications_with_no_models.version_2.patch (9.2 kB) - added by medhat on 01/26/07 13:36:51.
this should replace the previous patch

Change History

01/18/07 02:37:59 changed by mir@noris.de

  • stage changed from Unreviewed to Accepted.

I could reproduce this.

Traceback (most recent call last):
  File "manage.py", line 11, in ?
    execute_manager(settings)
  File "/home/mir/lib/python/django/core/management.py", line 1459, in execute_manager
    execute_from_command_line(action_mapping, argv)
  File "/home/mir/lib/python/django/core/management.py", line 1382, in execute_from_command_line
    action_mapping[action](args[1:], int(options.verbosity))
  File "/home/mir/lib/python/django/core/management.py", line 1234, in test
    app_list = [get_app(app_label) for app_label in app_labels]
  File "/home/mir/lib/python/django/db/models/loading.py", line 46, in get_app
    raise ImproperlyConfigured, "App with label %s could not be found" % app_label
django.core.exceptions.ImproperlyConfigured: App with label testapp could not be found

01/23/07 10:56:00 changed by medhat

  • attachment test_applications_with_no_models.patch added.

01/23/07 10:58:43 changed by medhat

  • has_patch set to 1.
  • needs_tests set to 1.

I created a patch for this, but I did not create tests... (I was not really sure how to creat tests for it :-)) If someone is interested in using this and add the tests instead of starting from scratch, that would be great.

01/26/07 13:36:51 changed by medhat

  • attachment test_applications_with_no_models.version_2.patch added.

this should replace the previous patch

08/20/07 02:23:40 changed by njharman <njharman@knoggin.com>

This problem has an easy workaround 'touch models.py' in relevant apps.

It can still is a bit of a gotcha though(some of my unittests weren't running for couple months and still wouldn't be if I hadn't added one and noticed the test count not increment). So, I'm working on a minimal patch to resolve this issue.

10/14/07 05:18:58 changed by akaihola

  • cc set to akaihol+django@ambitone.com.

There's an overlapping patch for the problem of testing models in separate files in #5751. It would make sense to merge these patches.


Add/Change #3310 (manage.py test does not work if there is not a model.py in the application)




Change Properties
Action