Django 1.6.10 は、これらのコードのいずれかを実行すると、アプリの外部にあるテスト モジュールを見つけることができません (参照: https://docs.djangoproject.com/en/1.6/topics/testing/overview/#running-tests )
./manage.py test tests/app1/
./manage.py test tests/app1/test_views
これらのエラーが発生し続けます
django.core.exceptions.ImproperlyConfigured: App with label tests/app1/ could not be found
django.core.exceptions.ImproperlyConfigured: App with label tests/app1/test_views could not be found
これが私のプロジェクト構造です:
- project
- app1
- __init__.py
- models.py
- views.py
- forms.py
- admins.py
- app2
- ..as per above
- tests
- __init__.py (blank)
- app1
- __init__.py (blank)
- test_views.py
- test_forms.py
- app2
- __init__.py (blank)
- test_views.py
- test_walkthrough.py
Django Discovery runner を数回読みましたが、どこが間違っていたのかまだわかりません。何か助けてください - 私は何が欠けていますか
/ に置き換えます。ただし、実行時に同じエラーが発生します
./manage.py test tests.app1.test_views.MyTestCase
./manage.py test tests.app1.test_views.MyTestCase.test_mymethod
ValueError が発生します。
ValueError: Test label 'tests.app1.test_views.MyTestCase.test_mymethod' should be of the form app.TestCase or app.TestCase.test_method
さらに更新:コマンドラインに --testrunner='django.test.runner.DiscoverRunner' を追加すると、ようやく機能するようになりました。Django doc によると、これらのパターンのいずれも機能するようになりました (/ を使用して、ディレクトリへのパスを提供し、そのディレクトリの下のテストを検出します)。
./manage.py test --testrunner='django.test.runner.DiscoverRunner' tests.app1
./manage.py test --testrunner='django.test.runner.DiscoverRunner' tests.app1.test_views.MyTestCase
./manage.py test --testrunner='django.test.runner.DiscoverRunner' tests/app1/
--testrunner の値を提供する必要がある理由はまだわかりません。私も自分のコードでメザニンを使用しており、settings.TEST_RUNNER が django.test.runner.DiscoverRunner を指していることを二重に確認しました。
django 1.6 で --testrunner フラグが必要な理由を説明できる人はいますか? 前もって感謝します。