Dosyamda django uygulaması tests.py
, oluşturduğum başka bir modülü helpers
olarak içe aktarıyorum. helpers
, tests.py
ile aynı dizin düzeyinde bulunur. Ben ./manage.py tests
çalıştırdığınızda bu hatayı alıyorum:Django projesi için PYTHONPATH ayarının doğru yolu
$ ./manage.py test
Creating test database for alias 'default'...
E
======================================================================
ERROR: api.tests (unittest.loader.ModuleImportFailure)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/unittest/case.py", line 58, in testPartExecutor
yield
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/unittest/case.py", line 577, in run
testMethod()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/unittest/loader.py", line 32, in testFailure
raise exception
ImportError: Failed to import test module: api.tests
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/unittest/loader.py", line 312, in _find_tests
module = self._get_module_from_name(name)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/unittest/loader.py", line 290, in _get_module_from_name
__import__(name)
File "/Users/bli1/Development/projects/cherngloong/cherngloong/api/tests.py", line 8, in <module>
from helpers.APIHelpers import KeyGrabber
ImportError: No module named 'helpers'
İşte benim proje yapısı şöyledir:
Temelde, tests.py
helpers
modülünü bulamıyorum.
api.helpers.APIHelpers import KeyGrabber
Django paketlerinde genellikle uygulama adıyla başlayan: Ben bu deneyin bir django projesi
api.helpers.APIHelpers'dan KeyGrabber'i almayı denediniz mi? İlk önce ad uygulamasına dikkat edin. – jorlugaqui
@jorlugaqui işe yaradı! Teşekkürler! – Liondancer
Cevabımı kabul edildi olarak işaretleyebilir misiniz :)? – jorlugaqui