On Thu, Jul 1, 2010 at 4:41 PM, Jari Pennanen <jari.penna...@gmail.com>wrote:

> Hi,
>
> I'm trying to use django.test.TestCase class in my project's directory
> "tests", e.g.
>
> myapp/models.py
> myapp/...
> tests/sometest.py
>
> If I use django TestCase inside sometest.py I get:
>
> Traceback (most recent call last):
>  File "\django\django\test\testcases.py", line 256, in __call__
>    self._pre_setup()
>  File "\django\django\test\testcases.py", line 223, in _pre_setup
>    self._fixture_setup()
>  File "\django\django\test\testcases.py", line 486, in _fixture_setup
>    if not connections_support_transactions():
>  File "\django\django\test\testcases.py", line 475, in
> connections_support_transactions
>    for conn in connections.all())
>  File "\django\django\test\testcases.py", line 475, in <genexpr>
>    for conn in connections.all())
> KeyError: 'SUPPORTS_TRANSACTIONS'
>
> But if I use it normally in the "myapp/tests.py", and command
> "manage.py test myapp" it works just fine. Whats the problem here? I
> would prefer to keep my tests outside the main package, and run them
> manually without the manage.py (actually Eclipse runs tests directory
> tests automatically).
>
> My testing file currently is pretty simple:
>
>        from django.test import TestCase
>
>        class SomeTestCase(TestCase):
>                def test_something(self):
>                        pass
>
>
manage.py test, before running any test cases, does a fair amount of setup,
including things like creating a test database for the tests to use. The
error you are seeing is a side-effect of this setup code not running before
the test code is called. If you want to use a different structure for your
tests you can, but you will need to make sure your test runner does
everything necessary to set up the environment properly for a
django.test.TestCase to run.  See:
http://docs.djangoproject.com/en/1.2/topics/testing/#using-different-testing-frameworks

Karen
-- 
http://tracey.org/kmt/

-- 
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