まだオープンソースではないサードパーティの Django アプリを pip を使用してインストールしましたが、現在は単体テストを実装しています。ただし、単体テストを実行しようとすると、テスト ケースごとに次のトレースバックが発生します。
ERROR: test_form_page_loads (myapp.tests.tests.ViewTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/yiqing/repos/dotfiles/common/virtualenvwrapper_hooks/filer_demo/local/lib/python2.7/site-packages/sampling/tests/tests.py", line 47, in test_form_page_loads
response = self.client.get(self.form_url)
File "/home/yiqing/repos/dotfiles/common/virtualenvwrapper_hooks/filer_demo/local/lib/python2.7/site-packages/django/test/client.py", line 453, in get
response = super(Client, self).get(path, data=data, **extra)
File "/home/yiqing/repos/dotfiles/common/virtualenvwrapper_hooks/filer_demo/local/lib/python2.7/site-packages/django/test/client.py", line 271, in get
parsed = urlparse(path)
File "/usr/lib/python2.7/urlparse.py", line 135, in urlparse
tuple = urlsplit(url, scheme, allow_fragments)
File "/usr/lib/python2.7/urlparse.py", line 168, in urlsplit
cached = _parse_cache.get(key, None)
File "/home/yiqing/repos/dotfiles/common/virtualenvwrapper_hooks/filer_demo/local/lib/python2.7/site-packages/django/utils/functional.py", line 156, in __hash__
return hash(self.__cast())
File "/home/yiqing/repos/dotfiles/common/virtualenvwrapper_hooks/filer_demo/local/lib/python2.7/site-packages/django/utils/functional.py", line 139, in __cast
return self.__bytes_cast()
File "/home/yiqing/repos/dotfiles/common/virtualenvwrapper_hooks/filer_demo/local/lib/python2.7/site-packages/django/utils/functional.py", line 135, in __bytes_cast
return bytes(func(*self.__args, **self.__kw))
File "/home/yiqing/repos/dotfiles/common/virtualenvwrapper_hooks/filer_demo/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 496, in reverse
return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
File "/home/yiqing/repos/dotfiles/common/virtualenvwrapper_hooks/filer_demo/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 382, in _reverse_with_prefix
possibilities = self.reverse_dict.getlist(lookup_view)
File "/home/yiqing/repos/dotfiles/common/virtualenvwrapper_hooks/filer_demo/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 297, in reverse_dict
self._populate()
File "/home/yiqing/repos/dotfiles/common/virtualenvwrapper_hooks/filer_demo/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 263, in _populate
for pattern in reversed(self.url_patterns):
File "/home/yiqing/repos/dotfiles/common/virtualenvwrapper_hooks/filer_demo/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 347, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/yiqing/repos/dotfiles/common/virtualenvwrapper_hooks/filer_demo/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 342, in urlconf_module
self._urlconf_module = import_module(self.urlconf_name)
File "/home/yiqing/repos/dotfiles/common/virtualenvwrapper_hooks/filer_demo/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
ImportError: No module named urls
関連する場合に備えて、このアプリのディレクトリ構造は次のとおりです。
myapp/
├── admin.py
├── conf.py
├── forms.py
├── __init__.py
├── models.py
├── templates
├── tests
│ ├── __init__.py
│ ├── models.py
│ ├── settings.py
│ └── tests.py
├── urls.py
└── views.py