I am following Test driven development and am working through Django models with mixer, Pytest and pytest-django.
This is the test for the Project model:
class TestProject:
def test_model_valid_fields(self, django_user_model):
project = mixer.blend(
'workspaces.Project',
title="Road map",
non_model_field="some value"
)
assert project.pk == 1
assert project.title == "Road map"
assert project.non_model_field == "some value"
The Project model, notice that Project model has only the title
field:
class Project(models.Model):
title = models.CharField(max_length=200)
Two things:
- How is mixer allowing the use of non model fields?
- Why is Pytest not raising an error, since the Project model does not have
non_model_field
field?
What am I missing here?