Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(tests): move to compact, human readable, commentable toml layout for test records #43630

Merged
merged 2 commits into from
Oct 13, 2024

Conversation

blaggacao
Copy link
Collaborator

cc @ruthra-kumar — inspired by your feedback about the inconvenience to work with json records

@blaggacao blaggacao merged commit 6efcb91 into frappe:develop Oct 13, 2024
13 checks passed
@blaggacao blaggacao deleted the chore/move-to-toml branch October 13, 2024 00:05
@ruthra-kumar
Copy link
Member

ruthra-kumar commented Oct 13, 2024

How are the toml files read? Is there any upstream change in Frappe?

@blaggacao
Copy link
Collaborator Author

How are the toml files read? Is there any upstream change in Frappe?

Yes, indeed: https://github.com/frappe/frappe/blob/c67c1b05cb401b702ff430dbbe18d57cd6ea2a33/frappe/tests/utils/generators.py#L121-L143

def load_test_records_for(index_doctype) -> dict[str, Any] | list:
	module_path = get_module_path(get_doctype_module(index_doctype), "doctype", frappe.scrub(index_doctype))

	json_path = os.path.join(module_path, "test_records.json")
	if os.path.exists(json_path):
		if not frappe.flags.deprecation_dumpster_invoked:
			from frappe.deprecation_dumpster import deprecation_warning

			deprecation_warning(
				"2024-10-09",
				"v18",
				"Use TOML files for test records; migration script: https://github.com/frappe/frappe/pull/28065",
			)
		with open(json_path) as f:
			return json.load(f)

	toml_path = os.path.join(module_path, "test_records.toml")
	if os.path.exists(toml_path):
		with open(toml_path, "rb") as f:
			return tomli.load(f)

	else:
		return {}

It supports both, still.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants