Errors on Django Tests Tutorial 5, how to fix.

218 views
Skip to first unread message

Matt Schloepp

unread,
Dec 4, 2013, 12:18:54 PM12/4/13
to django...@googlegroups.com
I'm running Django on Windows with PostgreSQL database. I'm in tutorial 5 and have copy/pasted the code after it's initial failure. I've been following the tutorials to this point, with only a little side experimentation, and everything has been working. It looks like it DB related since I'm not using SQLite. I'm lost. What do I need to add or modify to get the tests to work?

Output:
======================================================================
ERROR: test_was_published_recently_with_future_poll (polls.tests.PollMethodTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\python27\lib\site-packages\django\test\testcases.py", line 178, in __call__
    self._pre_setup()
  File "C:\python27\lib\site-packages\django\test\testcases.py", line 749, in _pre_setup
    self._fixture_setup()
  File "C:\python27\lib\site-packages\django\test\testcases.py", line 861, in _fixture_setup
    if not connections_support_transactions():
  File "C:\python27\lib\site-packages\django\test\testcases.py", line 848, in connections_support_transactions
    for conn in connections.all())
  File "C:\python27\lib\site-packages\django\test\testcases.py", line 848, in <genexpr>
    for conn in connections.all())
  File "C:\python27\lib\site-packages\django\utils\functional.py", line 49, in __get__
    res = instance.__dict__[self.func.__name__] = self.func(instance)
  File "C:\python27\lib\site-packages\django\db\backends\__init__.py", line 664, in supports_transactions
    self.connection.leave_transaction_management()
  File "C:\python27\lib\site-packages\django\db\backends\__init__.py", line 317, in leave_transaction_management
    if managed == self.get_autocommit():
  File "C:\python27\lib\site-packages\django\db\backends\__init__.py", line 324, in get_autocommit
    self.ensure_connection()
  File "C:\python27\lib\site-packages\django\db\backends\__init__.py", line 124, in ensure_connection
    self.connect()
  File "C:\python27\lib\site-packages\django\db\utils.py", line 86, in __exit__
    db_exc_type = getattr(self.wrapper.Database, dj_exc_type.__name__)
AttributeError: 'DatabaseWrapper' object has no attribute 'Database'

----------------------------------------------------------------------
Ran 0 tests in 0.001s

FAILED (errors=1)

 

Matt Schloepp

unread,
Dec 4, 2013, 3:07:50 PM12/4/13
to django...@googlegroups.com
Commenting out my Postgresql DB and putting back the default options for the sqlite DB fixed the issue. 

Is there a tests.py variable I could use to create an If..Else that would allow this to be automatic and not force me to edit my settings.py every time I wanted to run a test.

Thomas Lockhart

unread,
Dec 4, 2013, 5:18:15 PM12/4/13
to django...@googlegroups.com
On 12/4/13 9:18 AM, Matt Schloepp wrote:
I'm running Django on Windows with PostgreSQL database. I'm in tutorial 5 and have copy/pasted the code after it's initial failure. I've been following the tutorials to this point, with only a little side experimentation, and everything has been working. It looks like it DB related since I'm not using SQLite. I'm lost. What do I need to add or modify to get the tests to work?
What version of Django are you running? I think an issue with starting up tests with PostgreSQL were fixed for 1.6 (but I haven't tried it myself). fwiw PostgreSQL is supported as well or better than any other choice, and SQLite just postpones the inevitable transition to something which is full-featured.

hth

                               - Tom

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b0067a22-b212-4ffa-ad5d-7fab897f9ca7%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Matt Schloepp

unread,
Dec 4, 2013, 5:32:14 PM12/4/13
to django...@googlegroups.com
Django is 1.6 and Python is 2.7.5. On Windows 8.1, no virtual-env, but my actual project will be on a *nix VM. I accidentally download and install a development version, I think removed it before installing 1.6 but no previous django versions were installed on this system. Maybe dropping my db and starting over would fix the issue?

Matt Schloepp

unread,
Dec 4, 2013, 5:35:21 PM12/4/13
to django...@googlegroups.com
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'django',
'USER': 'matt',
'PASSWORD':'***********',
'HOST': '127.0.0.1',
        'PORT': '5432',
    },
    'OPTIONS': {
        'autocommit': True,
    }

I forgot to post DB settings
Reply all
Reply to author
Forward
0 new messages