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

A fixture which gives access to all databases in tests

Open dferens opened this issue 1 year ago • 1 comments
trafficstars

Hi,

At my company we have a problem that we have to use mark on every test:

@pytest.mark.django_db(databases="__all__")
def test_something(db):
   ...

@pytest.mark.django_db(databases="__all__")
def test_other(db):
    ...

# + a bunch of tests which needs to be marked as well

I'd like to propose a solution:

def setup_db(db, django_db_all_databases):
    pass

def test_something(setup_db):
    ...

def test_other(setup_db):
    ...

Let me know what you think. If you approve this, I will improve this PR with tests, docs, docstrings and so on. I wanted to know your opinion first.

Thanks!

dferens avatar Feb 13 '24 12:02 dferens

Hey, can anyone look into this?

dferens avatar May 07 '24 14:05 dferens