Skip to content

Are factory.django.DjangoModelFactory fixtures in conftest.py available across applications? #52

Closed
@tony

Description

@tony

pytest-dev/pytest-django#508

I'm using factory_boy with https://github.com/pytest-dev/pytest-django.

python: 3.6.2
django: 1.11.4
pytest-django: 3.1.2
factory-boy: 2.8.1 (downgraded due to #47 (comment))
pytest-factoryboy: 1.3.1

Here's my app1/conftest.py:

# -*- coding: utf-8 -*-
import factory
import pytest
from django.contrib.auth import get_user_model
from django.core.management import call_command
from pytest_factoryboy import register

class UserFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = get_user_model()

    username = factory.Sequence(lambda n: "user%03d" % n)
    password = factory.Sequence(lambda n: "pass%03d" % n)

register(UserFactory)

This makes user available as a fixture for me. However, it only works in tests in the same application, not project-wide (in different django application test directories).

Am I doing it wrong, then? I'm trying to narrow down if this is a mistake on my end, a bug, a potential feature, or expected behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions