import re with open('addons/education_lms/tests/test_education_lms.py', 'r') as f: text = f.read() text = text.replace( """ print(f"\\nDEBUG USER GROUPS: {self.user_student_a.groups_id.mapped('name')}")""", """ rule = self.env.ref('education_lms.rule_lms_course_student') print(f"\\nDEBUG RULE PERM_READ: {rule.perm_read}") print(f"DEBUG USER GROUPS: {self.user_student_a.groups_id.mapped('name')}")""" ) with open('addons/education_lms/tests/test_education_lms.py', 'w') as f: f.write(text)