import re 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'])", """ all_courses = self.env['education.lms.course'].with_user(self.user_student_a).search([]) print(f"\\nDEBUG ALL COURSES: {all_courses.ids}") 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)