

def test_related_objects_in_translation_model(self):
    instance = TranslationRelated()
    instance.set_current_language(self.other_lang1)
    instance.title = 'Title Lang1'
    instance.save()
    instance.set_current_language(self.other_lang2)
    instance.title = 'Title Lang2'
    instance.save()
    translation1 = instance.get_translation(self.other_lang1)
    translation1.translation_relations.create(name='relation 1.1')
    translation1.translation_relations.create(name='relation 1.2')
    translation2 = instance.get_translation(self.other_lang2)
    translation2.translation_relations.create(name='relation 2.1')
    total_related_objects = TranslationRelatedRelation.objects.filter(translation__master=instance).count()
    lang1_related_object = TranslationRelatedRelation.objects.filter(translation__language_code=self.other_lang1, translation__master=instance).count()
    lang2_related_objects = TranslationRelatedRelation.objects.filter(translation__language_code=self.other_lang2, translation__master=instance).count()
    self.assertEqual(3, total_related_objects)
    self.assertEqual(2, lang1_related_object)
    instance.assertEqual(1, lang2_related_objects)

dataset/ETHPy150Open edoburu/django-parler/parler/tests/test_model_relations.py TranslationRelationTestCase.test_related_objects_in_translation_model/VarMisuse@194/314 `self`->`instance`