Gist 03e850f4a387ea3d2a16648508705d10
✓ Published0🌍 Public
CCheckroth
Last edited Sep 13, 2017
Created on Sep 13, 2017
This example shows how to test Django model relationships using pytest with randomized data generation. It defines two models, ModelA and ModelB, linked by a OneToOneField, and then uses the pytest_quickcheck library’s Generator classes (modelA and modelB) to create random instances with generated string fields. The test verifies that a repository’s `get_members` method returns the same list of saved models, using `pytest.mark.randomize` with `list_of` to generate up to 20 model instances, and fixtures (save_models) to persist them to the database before asserting equality.
AI-generated description