Use more realistic names in scenario snapshots (#978)

This is helpful to make the error messages more realistic and the names
are indisputably cuter.
This commit is contained in:
Zanie Blue 2024-01-19 10:01:34 -06:00 committed by GitHub
parent 5adb08a304
commit 5fe3444e5a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 307 additions and 219 deletions

File diff suppressed because it is too large Load diff

View file

@ -67,8 +67,11 @@ fn {{module_name}}() -> Result<()> {
let cache_dir = assert_fs::TempDir::new()?;
let venv = create_venv(&temp_dir, &cache_dir, "python{{environment.python}}");
// In addition to the standard filters, remove the scenario version
// In addition to the standard filters, swap out package names for more realistic messages
let mut filters = INSTA_FILTERS.to_vec();
{{#packages}}
filters.push((r"{{name}}", "{{cute_name}}"));
{{/packages}}
filters.push((r"-{{version}}", ""));
insta::with_settings!({

View file

@ -52,6 +52,16 @@ PACKSE = TOOL_ROOT / "packse-scenarios"
REQUIREMENTS = TOOL_ROOT / "requirements.txt"
PROJECT_ROOT = TOOL_ROOT.parent.parent
TARGET = PROJECT_ROOT / "crates" / "puffin" / "tests" / "pip_install_scenarios.rs"
CUTE_NAMES = {
"a": "albatross",
"b": "bluebird",
"c": "crow",
"d": "duck",
"e": "eagle",
"f": "flamingo",
"g": "goose",
"h": "heron",
}
try:
import packse
@ -165,6 +175,11 @@ for scenario in data["scenarios"]:
else []
)
# Generate cute names for each scenario
for scenario in data["scenarios"]:
for package in scenario["packages"]:
package["cute_name"] = CUTE_NAMES[package["name"][0]]
# Render the template
print("Rendering template...", file=sys.stderr)