import sys with open('addons/education_lms/tests/test_education_lms.py', 'r') as f: text = f.read() text = text.replace( " res = course_a.with_user(self.user_student_a).read(['name'])", """ print(f"\\nDEBUG COURSE: p={course_a.program_id.id}, y={course_a.academic_year_id.id}, t={course_a.term_id.id}, b={course_a.batch_id.id}") print(f"DEBUG STUDENT: p={self.student_a.program_id.id}, y={self.student_a.academic_year_id.id}, t={self.student_a.academic_term_id.id}, b={self.student_a.batch_id.id}") res = course_a.with_user(self.user_student_a).read(['name'])""" ) with open('addons/education_lms/tests/test_education_lms.py', 'w') as f: f.write(text)