import re with open('addons/education_lms/tests/test_education_lms.py', 'r') as f: text = f.read() text = text.replace( """ rules = self.env['ir.rule'].with_user(self.user_student_a)._get_rules('education.lms.course', 'read') print(f"\\nDEBUG APPLIED RULES FOR STUDENT A: {rules.mapped('name')}")""", """ print(f"\\nDEBUG USER GROUPS: {self.user_student_a.groups_id.mapped('name')}") print(f"DEBUG HAS STUDENT GROUP: {self.group_student in self.user_student_a.groups_id}")""" ) with open('addons/education_lms/tests/test_education_lms.py', 'w') as f: f.write(text)