ci: erpnext lazy loading test records (#28080)

This commit is contained in:
David Arnold 2024-10-13 01:22:18 +02:00 committed by GitHub
parent 0204db6547
commit ee1469a045
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -88,8 +88,6 @@ class ParallelTestRunner:
frappe.set_user("Administrator")
path, filename = file_info
module = self.get_module(path, filename)
if "erpnext" in path:
self._pre_create_test_dependency_records(module, path, filename)
test_suite = unittest.TestSuite()
module_test_cases = unittest.TestLoader().loadTestsFromModule(module)
test_suite.addTest(module_test_cases)
@ -97,27 +95,6 @@ class ParallelTestRunner:
test_suite(self.test_result)
self.test_result.stopTestRun()
# If an app depends on pre-creation, its tests should be revised to
# manage state in such a way that created during IntegrationTestCase.setUpClass
# is suitable
def _pre_create_test_dependency_records(self, module, path, filename):
if hasattr(module, "test_dependencies"):
for doctype in module.test_dependencies:
make_test_records(doctype, commit=True)
if hasattr(module, "EXTRA_TEST_RECORD_DEPENDENCIES"):
for doctype in module.EXTRA_TEST_RECORD_DEPENDENCIES:
make_test_records(doctype, commit=True)
if os.path.basename(os.path.dirname(path)) == "doctype":
# test_data_migration_connector.py > data_migration_connector.json
test_record_filename = re.sub("^test_", "", filename).replace(".py", ".json")
test_record_file_path = os.path.join(path, test_record_filename)
if os.path.exists(test_record_file_path):
with open(test_record_file_path) as f:
doc = json.loads(f.read())
doctype = doc["name"]
make_test_records(doctype, commit=True)
def get_module(self, path, filename):
app_path = frappe.get_app_path(self.app)
relative_path = os.path.relpath(path, app_path)