Hi all,

The software we're developing uses sphinx search engine whose index
updating process doesn't play well with django's unittest setup, as a
result we have to move all the tests from django to nosetest.  I found
one of your test talk on djangocon and you mentioned that we could
'instantiate Client out of django unittest framework', I've tried but
kept bumping into the `ImportError: No module named urls` exception.

Here is our test code:

#! /usr/bin/env python

import os
os.environ['DJANGO_SETTINGS_MODULE']='hivemind.settings'

from django.test.utils import setup_test_environment
setup_test_environment()

from django.core.management import call_command
from django.test.client import Client
from nose.tools import with_setup

from hivemind import settings
from hivemind.engine.models import *
from hivemind.indexer.models import update_index, search
from hivemind.utils.debugger import dump_tables


def teardown():
    dump_tables()

def setup():
    call_command('flush', verbosity=0, interactive=False)
    update_index()


@with_setup(setup, teardown)
def test_api():
    mine_expertise(0)

    # following code is using the api to redo the test_engine
    # modification parts.
    c = Client()

    r = c.post('/api/expertise/6/update/', {'threshold':10, 'filter':
5})
    assert 200==r.status_code
    r = c.get('/api/expertise/6/')
    assert 200==r.status_code

Here is the exception:
======================================================================
ERROR: hivemind.tests.test_api
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/nose-0.11.0-py2.6.egg/nose/case.py", line 183,
in runTest
    self.test(*self.arg)
  File "/Users/alexdong/Projects/hivemind/trunk/hivemind/tests.py",
line 70, in test_api
    r = c.post('/api/expertise/6/update/', {'threshold':10, 'filter':
5})
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/django/test/client.py", line 318, in post
    response = self.request(**r)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/django/core/handlers/base.py", line 90, in
get_response
    request.path_info)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/django/core/urlresolvers.py", line 222, in
resolve
    sub_match = pattern.resolve(new_path)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/django/core/urlresolvers.py", line 220, in
resolve
    for pattern in self.url_patterns:
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/django/core/urlresolvers.py", line 249, in
_get_url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns",
self.urlconf_module)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/django/core/urlresolvers.py", line 244, in
_get_urlconf_module
    self._urlconf_module = import_module(self.urlconf_name)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/django/utils/importlib.py", line 35, in
import_module
    __import__(name)
ImportError: No module named urls

----------------------------------------------------------------------

Cheers,
Alex

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to