Skip to content

Doctest intermittently getting "Failed: Database access not allowed, use the "django_db" mark to enable" #302

Open
@scherrey

Description

@scherrey

Using Python 3.4, pytest-django 2.8.0, pytest 2.7.0, django 1.7.6, & Postgresql 9.3.9

When running my unit tests I have an intermittent error returning from my one and only Doctest. All my unit tests pass just fine and many use the database. Here's my test invocation:
time py.test -n 7 -s -v --durations=10

273 Goals must be created within the context of a Portfolio.
274 >>> import pytest
275 >>> pytestmark = pytest.mark.django_db()
276 >>> from portfolio.models import Portfolio
277 >>> p, new = Portfolio.objects.get_or_create(name="Sample Goals")
UNEXPECTED EXCEPTION: Database access not allowed, use the "django_db" mark to enable

Removing lines 274 & 275 have no impact.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions