pytest-django icon indicating copy to clipboard operation
pytest-django copied to clipboard

Create a management command to set up a sane pytest configuration

Open IgnisDa opened this issue 4 years ago • 2 comments
trafficstars

I propose we add a management command, maybe something like python manage.py setup_pytest which will create a sane pytest.ini with some default settings. I intend the generated file to look something like this.

~The file itself will be generated using the iniconfig package which pytest already depends on.~ Looks like iniconfig is not capable of writing files, in which case, I will just generate the file using inbuilt strings.

Finally, relevant documentation will also need to be written.

I would make a PR to do all this, when (and if) this is accepted.

IgnisDa avatar Dec 18 '20 01:12 IgnisDa

pytest-django itself is not a Django app, so I'm not sure if we can hook up a custom management command, though it may be possible (I haven't looked too closely).

But in general I think something like this is perhaps better as a cookiecutter template?

bluetech avatar Dec 26 '20 13:12 bluetech

I generally do not recommend cookiecutter since it introduces a dependency for the project. However, we can quickly transform pytest-django to a django app by creating pytest_django/management/commands/setup_pytest.py and then ask users to add pytest_django to their installed apps. Here is a detailed discussion about this topic.

IgnisDa avatar Dec 27 '20 03:12 IgnisDa