79180888

Date: 2024-11-12 11:28:15
Score: 0.5
Natty:
Report link

The error occurs because pytest does not automatically set the Frappe application context as the bench run-tests command does. To fix this, what you can do is manually initialize the Frappe context in your tests by using pytest fixtures. Set up the context with frappe.init() and frappe.connect() before running the test, and clean up afterward with frappe.destroy(). What this does is that it ensures that the necessary application context is available during test execution. Also make sure to apply patches correctly, as incorrect patching can also cause issues.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Single line (0.5):
  • Low reputation (1):
Posted by: Jatin Garg