0

I've created a project to find out what project structure is right for my other python project.

What I really want to do is to run some tests.

example.py looks like this

import unittest
from A.A import A

__author__ = 'michael'


class ExampleTest(unittest.TestCase):
    def setUp(self):
        self.a = A()
        pass

    def test_stub(self):
        self.assertEquals(self.a.foo(), 'foo')

if __name__ == '__main__':
    unittest.main()

When I'm runnining

/Temp $ nosetests

I'm getting django exception.

Traceback (most recent call last):
  File "/usr/local/bin/nosetests", line 9, in <module>
    load_entry_point('nose==1.3.0', 'console_scripts', 'nosetests')()
  File "/usr/local/lib/python2.7/dist-packages/nose/core.py", line 118, in __init__
    **extra_args)
  File "/usr/lib/python2.7/unittest/main.py", line 94, in __init__
    self.parseArgs(argv)
  File "/usr/local/lib/python2.7/dist-packages/nose/core.py", line 135, in parseArgs
    self.config.configure(argv, doc=self.usage())
  File "/usr/local/lib/python2.7/dist-packages/nose/config.py", line 344, in configure
    self.plugins.configure(options, self)
  File "/usr/local/lib/python2.7/dist-packages/nose/plugins/manager.py", line 284, in configure
    cfg(options, config)
  File "/usr/local/lib/python2.7/dist-packages/nose/plugins/manager.py", line 99, in __call__
    return self.call(*arg, **kw)
  File "/usr/local/lib/python2.7/dist-packages/nose/plugins/manager.py", line 167, in simple
    result = meth(*arg, **kw)
  File "/usr/local/lib/python2.7/dist-packages/queries/nose_plugin.py", line 22, in configure
    connection.use_debug_cursor = True
  File "/usr/local/lib/python2.7/dist-packages/django/db/__init__.py", line 37, in __setattr__
    return setattr(connections[DEFAULT_DB_ALIAS], name, value)
  File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 196, in __getitem__
    self.ensure_defaults(alias)
  File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 170, in ensure_defaults
    conn = self.databases[alias]
  File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 49, in __get__
    res = instance.__dict__[self.func.__name__] = self.func(instance)
  File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 153, in databases
    self._databases = settings.DATABASES
  File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 54, in __getattr__
    self._setup(name)
  File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 47, in _setup
    % (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting DATABASES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

I don't get it at all. What have django has to do with it?

enter image description here

EDIT1:

Can't show you code, because I've already learned how to run tests with unittest and deleted this project.

But I assure you that the code for was A just about using B. Something like

class A(): def __init(self): self.b = B()

def foo(self): b.foo()

And B was just a class with a foo method that printed string 'foo'.

user1685095
  • 5,787
  • 9
  • 51
  • 100

1 Answers1

0

From the line

File "/usr/local/lib/python2.7/dist-packages/queries/nose_plugin.py", line 22, in configure
    connection.use_debug_cursor = True

It seems that you have installed django-dynamic-fixture. This package installs a nose_plugin that uses django ORM.

  • Disable django-dynamic-fixture (I don't know how to do it) OR
  • Uninstall django-dynamic-fixture OR
  • Work in isolated virtualenvs.
xbello
  • 7,223
  • 3
  • 28
  • 41