vendredi 3 juillet 2015

pytest-django fails to get db access despite @pytest.mark.django.db

my very simple test file features the following teardown code.

    @pytest.mark.django_db
    def teardown_module(module):
        print('shutting down ...')
        status = Recipe.objects.all().delete()

Despite having the teardown function marked with @pytest.mark.django_db i end up with the following error.

    def cursor(self):
        """
            Creates a cursor, opening a connection if necessary.
            """
        self.validate_thread_sharing()
        if self.queries_logged:
            cursor = self.make_debug_cursor(self._cursor())
        else:
>           cursor = utils.CursorWrapper(self._cursor(), self)
E           Failed: Database access not allowed, use the "django_db" mark to enable it.

The actual pytest output even lists the relevant function call including the decorator. The entire setup is so dead simple that I fail to see where it could go wrong. Which usually is the worst kind of problem. Funfact: my setup_module function is almost identical and gets executed just fine.

Aucun commentaire:

Enregistrer un commentaire