Skip to content

Commit 4c09d4e

Browse files
committed
Fixup
1 parent 525c621 commit 4c09d4e

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

tests/test_cookiecutter.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
def get_config() -> dict:
2525
"""Generate all the config keys"""
2626
config_file = Path("./cookiecutter.json")
27-
with open(config_file) as file_object:
28-
config = json.load(file_object)
27+
with config_file.open(encoding="utf-8") as f:
28+
config = json.load(f)
2929
return config
3030

3131

@@ -227,6 +227,19 @@ def test_default_project(cookies):
227227
if repo.is_dirty(untracked_files=True):
228228
pytest.fail("Something went wrong with the project's post-generation hook")
229229

230+
# Extract project_name and project_slug from cookiecutter.json
231+
config_file = Path("./cookiecutter.json")
232+
with config_file.open(encoding="utf-8") as f:
233+
generated_config = json.load(f)
234+
github_org = generated_config.get("github_org")
235+
project_name = generated_config.get("project_name")
236+
project_name_lower = project_name.lower()
237+
238+
# Keep this logic aligned with the template's README.md
239+
# It's important that this has -s in the name to test the docker hub image name sanitization
240+
default_image_name = f"{github_org}/{project_name_lower}"
241+
default_image_name_and_tag = f"{default_image_name}:latest"
242+
230243
try:
231244
env = os.environ.copy()
232245
env.pop("VIRTUAL_ENV", None) # Clean VIRTUAL_ENV to avoid conflicts
@@ -273,12 +286,9 @@ def test_default_project(cookies):
273286
env=env,
274287
)
275288

276-
# It's important that this has -s in the name to test the docker hub image name sanitization
277-
default_image = "zenable-io/replace-me:latest"
278-
279289
# Ensure that --help exits 0
280290
subprocess.run(
281-
["docker", "run", "--rm", default_image, "--help"],
291+
["docker", "run", "--rm", default_image_name_and_tag, "--help"],
282292
capture_output=True,
283293
check=True,
284294
cwd=project,
@@ -289,7 +299,7 @@ def test_default_project(cookies):
289299
"docker",
290300
"run",
291301
"--rm",
292-
default_image,
302+
default_image_name_and_tag,
293303
"--debug",
294304
"--verbose",
295305
]

0 commit comments

Comments
 (0)