What classes are the databases specified in the pytest.mark.django_db databases parameter wrapped in?

30 views Asked by At

Having the following test :

    @pytest.mark.django_db(databases=["mongodb", "default"], transaction=False)
    def test_mutation_response():
        assert PostgresQlModel.objects.count() == 1
        assert MongoModel.objects.count() == 1

The first database is a mongo the second one is a Postgresql, When the test is over a flush on both databases happen I do not understand why in the postgres, having in mind that this one accepts transactions and the transaction parameter is being set to False in the helper. So the question is, are both databases wrapped in a TransactionTestCase?

What I would expect is that only the mongodb was flushed not the other one since the transaction parameter is set to False and this database accepts transaction so this one should be wrapped in a TestCase according to the documentation https://pytest-django.readthedocs.io/en/latest/helpers.html#markers, On the other hand is fine that the Mongo db gets flushed because does not accept transactions so is treated by the TransactionTestCase

0

There are 0 answers