mirror of
https://github.com/agessaman/meshcore-bot.git
synced 2026-10-24 06:42:22 +00:00
test(characterization): fail when a public-API golden is missing instead of regenerating it
Both guards in test_public_api.py rewrote a missing golden and passed, so deleting public_imports.json along with an import would have hidden the removal. They now regenerate only under UPDATE_GOLDEN=1.
This commit is contained in:
1 parent
09a6b50564
commit
b62806f58b
1 file changed
+4
-2
@@ -74,9 +74,10 @@ def test_no_public_name_was_removed():
|
||||
import os
|
||||
|
||||
current = _public_names()
|
||||
if os.environ.get("UPDATE_GOLDEN") == "1" or not GOLDEN.exists():
|
||||
if os.environ.get("UPDATE_GOLDEN") == "1":
|
||||
GOLDEN.write_text(json.dumps(current, indent=1, sort_keys=True) + "\n", encoding="utf-8")
|
||||
return
|
||||
assert GOLDEN.exists(), f"{GOLDEN} missing; generate it with UPDATE_GOLDEN=1"
|
||||
recorded = json.loads(GOLDEN.read_text(encoding="utf-8"))
|
||||
missing = []
|
||||
for module, names in recorded.items():
|
||||
@@ -91,9 +92,10 @@ def test_no_public_name_was_removed():
|
||||
def test_no_imported_public_name_was_dropped():
|
||||
import os
|
||||
|
||||
if os.environ.get("UPDATE_GOLDEN") == "1" or not IMPORTS_GOLDEN.exists():
|
||||
if os.environ.get("UPDATE_GOLDEN") == "1":
|
||||
IMPORTS_GOLDEN.write_text(json.dumps(_public_imports(), indent=1, sort_keys=True) + "\n", encoding="utf-8")
|
||||
return
|
||||
assert IMPORTS_GOLDEN.exists(), f"{IMPORTS_GOLDEN} missing; generate it with UPDATE_GOLDEN=1"
|
||||
recorded = json.loads(IMPORTS_GOLDEN.read_text(encoding="utf-8"))
|
||||
missing = [
|
||||
f"{module}: {name}"
|
||||
|
||||
Reference in new issue
Block a user