﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
22279	AttributeError: 'db.backends.dummy.base.DatabaseWrapper' object has no attribute 'Database'	Daniel Hahler	nobody	"I am getting a `AttributeError: 'DatabaseWrapper' object has no attribute 'Database'` exception, while trying to setup/use py.test with Django.


> DJANGO_SECRET_KEY=foo DJANGO_SETTINGS_MODULE=config.settings PYTHONPATH=. py.test -s --ipdb project/model/tests.py

self.wrapper is django.db.backends.dummy.base.DatabaseWrapper.


{{{
> …/django-master/django/db/utils.py(86)__exit__()
     85         ):
---> 86             db_exc_type = getattr(self.wrapper.Database, dj_exc_type.__name__)
     87             if issubclass(exc_type, db_exc_type):

ipdb> bt
  …/django-master/django/test/testcases.py(857)<genexpr>()
    855     """"""
    856     return all(conn.features.supports_transactions
--> 857                for conn in connections.all())
    858 
    859 

  …/django-master/django/utils/functional.py(55)__get__()
     53         if instance is None:
     54             return self
---> 55         res = instance.__dict__[self.func.__name__] = self.func(instance)
     56         return res
     57 

  …/django-master/django/db/backends/__init__.py(701)supports_transactions()
    699                 self.connection.commit()
    700         finally:
--> 701             self.connection.leave_transaction_management()
    702         return count == 0
    703 

  …/django-master/django/db/backends/__init__.py(320)leave_transaction_management()
    318                 ""Transaction managed block ended with pending COMMIT/ROLLBACK"")
    319 
--> 320         if managed == self.get_autocommit():
    321             self.set_autocommit(not managed)
    322 

  …/django-master/django/db/backends/__init__.py(327)get_autocommit()
    325         Check the autocommit state.
    326         """"""
--> 327         self.ensure_connection()
    328         return self.autocommit
    329 

  …/django-master/django/db/backends/__init__.py(124)ensure_connection()
    122         if self.connection is None:
    123             with self.wrap_database_errors:
--> 124                 self.connect()
    125 
    126     ##### Backend-specific wrappers for PEP-249 connection methods #####

> …/django-master/django/db/utils.py(86)__exit__()
     84                 Error,
     85         ):
---> 86             db_exc_type = getattr(self.wrapper.Database, dj_exc_type.__name__)
     87             if issubclass(exc_type, db_exc_type):
     88                 dj_exc_value = dj_exc_type(*exc_value.args)

  …/django-master/django/test/testcases.py(182)__call__()
    180         if not skipped:
    181             try:
--> 182                 self._pre_setup()
    183             except Exception:
    184                 result.addError(self, sys.exc_info())

  …/django-master/django/test/testcases.py(749)_pre_setup()
    747                 flush.Command.emit_post_migrate(verbosity=0, interactive=False, database=db_name)
    748         try:
--> 749             self._fixture_setup()
    750         except Exception:
    751             if self.available_apps is not None:

  …/django-master/django/test/testcases.py(870)_fixture_setup()
    868 
    869     def _fixture_setup(self):
--> 870         if not connections_support_transactions():
    871             return super(TestCase, self)._fixture_setup()
    872 

  …/django-master/django/test/testcases.py(857)connections_support_transactions()
    855     """"""
    856     return all(conn.features.supports_transactions
--> 857                for conn in connections.all())
    858 
    859 

  …/django-master/django/test/testcases.py(857)<genexpr>()
    855     """"""
    856     return all(conn.features.supports_transactions
--> 857                for conn in connections.all())
    858 
    859 

  …/django-master/django/utils/functional.py(55)__get__()
     53         if instance is None:
     54             return self
---> 55         res = instance.__dict__[self.func.__name__] = self.func(instance)
     56         return res
     57 

  …/django-master/django/db/backends/__init__.py(701)supports_transactions()
    699                 self.connection.commit()
    700         finally:
--> 701             self.connection.leave_transaction_management()
    702         return count == 0
    703 

  …/django-master/django/db/backends/__init__.py(320)leave_transaction_management()
    318                 ""Transaction managed block ended with pending COMMIT/ROLLBACK"")
    319 
--> 320         if managed == self.get_autocommit():
    321             self.set_autocommit(not managed)
    322 

  …/django-master/django/db/backends/__init__.py(327)get_autocommit()
    325         Check the autocommit state.
    326         """"""
--> 327         self.ensure_connection()
    328         return self.autocommit
    329 

  …/django-master/django/db/backends/__init__.py(124)ensure_connection()
    122         if self.connection is None:
    123             with self.wrap_database_errors:
--> 124                 self.connect()
    125 
    126     ##### Backend-specific wrappers for PEP-249 connection methods #####

> …/django-master/django/db/utils.py(86)__exit__()
     84                 Error,
     85         ):
---> 86             db_exc_type = getattr(self.wrapper.Database, dj_exc_type.__name__)
     87             if issubclass(exc_type, db_exc_type):
     88                 dj_exc_value = dj_exc_type(*exc_value.args)

}}}
"	Bug	closed	Database layer (models, ORM)	dev	Normal	fixed			Ready for checkin	1	0	0	0	0	0
