import re with open('addons/education_lms/tests/test_education_lms.py', 'r') as f: text = f.read() text = text.replace( """ print(f"\\nDEBUG RULE PERM_READ: {rule.perm_read}")""", """ print(f"\\nDEBUG RULE PERM_READ: {rule.perm_read}") student_ids_as_student = self.user_student_a.with_user(self.user_student_a).student_ids print(f"DEBUG STUDENT IDS AS STUDENT: {student_ids_as_student}")""" ) with open('addons/education_lms/tests/test_education_lms.py', 'w') as f: f.write(text)