Django Unit Tests – Changes to self properties are persisting from test to test

I have a test class that has a setup like this. We import a dictionary from a test_helpers file that has some default data. The data is set as FORM_DATA[‘value_A’] = 0 and FORM_DATA[‘value_B’] = 1000000 from the start. Whether I set FORM_DATA to a self.form_data value, or assign it to a variable in each… Read More Django Unit Tests – Changes to self properties are persisting from test to test

E TypeError: Direct assignment to the forward side of a many-to-many set is prohibited. Use subjects.set() instead

I am writing a test to some api calls, the issue that I am getting is that I can’t figure out how to assign a many-to-many variable(subjects) in Django. models.py class Subject(BaseModel): id = models.AutoField(primary_key=True) name = models.TextField(null=False, blank=False) answers = models.ManyToManyField("registration.Answer", through="AnswerSubject") class Answer(BaseModel): id = models.AutoField(primary_key=True) text = models.TextField(null=False, blank=False) subjects = models.ManyToManyField("subjects.Subject",… Read More E TypeError: Direct assignment to the forward side of a many-to-many set is prohibited. Use subjects.set() instead