Django belgeleri (http://docs.djangoproject.com/en/1.3/topics/testing/#running-tests) bunları belirterek bireysel test durumları çalıştırmak söylüyor Django uygulamanızda bir tests.py dosyası. Bu doğruysa, bu komut beklendiği gibi çalışır.Django belirli test vakası Running
import unittest
from my_project.apps.my_app.tests import field_tests, storage_tests
def suite():
tests_loader = unittest.TestLoader().loadTestsFromModule
test_suites = []
test_suites.append(tests_loader(field_tests))
test_suites.append(tests_loader(storage_tests))
return unittest.TestSuite(test_suites)
yapmam testlerini çalıştırmak için::
tests/__init__.py
dosya paketi() işlevi vardır
my_project/apps/my_app/
├── __init__.py
├── tests
│ ├── __init__.py
│ ├── field_tests.py
│ ├── storage_tests.py
├── urls.py
├── utils.py
└── views.py
:
Bir testler dizinde bir Django uygulaması için benim testleri
$ ./manage.py test my_app
Tek bir sınama durumu belirtmeye çalışıldığında bir istisna kaldırılır:Benim testleri birden fazla dosya olduğunda
$ ./manage.py test my_app.StorageTestCase
...
ValueError: Test label 'my_app.StorageTestCase' does not refer to a test
nasıl bir birey test durumda belirtebilirim:
$ ./manage.py test my_app.tests.storage_tests.StorageTestCase
...
ValueError: Test label 'my_app.tests.storage_tests.StorageTestCase' should be of the form app.TestCase or app.TestCase.test_method
Ben istisna mesajı söylediklerini yapmaya çalıştık?
Teşekkür @sdolan yüksek güçte olmalıdır. Aynı problemi hekevintran ile karşılaştı. Django-burnuna geçti ve bu sorunu düzeltdi, ayrıca varsayılan Django test koşucusundan daha iyi çalışıyor. – LeeMobile
Teşekkürler. Django'nun test yolcusunun bunu yapamayacağı bir parça. – hekevintran
Bu bir test çalıştırıyor, ancak tüm bir TestCase'in nasıl çalıştırılacağı? – jMyles