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}")""", """ 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')}")""" ) with open('addons/education_lms/tests/test_education_lms.py', 'w') as f: f.write(text)