Answers for "pytest django"

3

install pytest

pip install pytest
Posted by: Guest on July-24-2020
0

install pytest

pip install -U pytest
Posted by: Guest on February-05-2022
0

pytest

# content of conftest.py @by github -> linkerunk
import pytest


def pytest_addoption(parser):
    parser.addoption(
        "--cmdopt", action="store", default="type1", help="my option: type1 or type2"
    )


@pytest.fixture
def cmdopt(request):
    return request.config.getoption("--cmdopt")
Posted by: Guest on November-20-2021
0

django pytest how to load data

@pytest.fixture(autouse=True)
def setup(self, db):
    call_command('loaddata', './apps/accounts/fixtures/accounts.json')
    call_command('loaddata', './apps/activation/fixtures/activation.json')
    call_command('loaddata', './apps/questionnaire/fixtures/questionnaire.json')
Posted by: Guest on February-26-2022
0

django pytest how to load data

from pytest_django.fixtures import _django_db_fixture_helper

@pytest.fixture(autoscope='module')
def setup_db(request, django_db_setup, django_db_blocker):
    _django_db_fixture_helper(request,·django_db_blocker)
    call_command('loaddata', 'path/to/fixture.json')
Posted by: Guest on February-26-2022

Python Answers by Framework

Browse Popular Code Answers by Language