Skip to content

Commit fead28f

Browse files
jsf9kmcdonnnj
andcommitted
Adjust version test for new format in version file
The new code matches what is done in cisagov/skeleton-docker: - https://github.com/cisagov/skeleton-docker/blob/722507bd51e06538f1f85b659df616ca7ca7fcbd/tests/conftest.py#L41-L46 - https://github.com/cisagov/skeleton-docker/blob/722507bd51e06538f1f85b659df616ca7ca7fcbd/tests/container_test.py#L61-L68 Co-authored-by: Nick M <50747025+mcdonnnj@users.noreply.github.com>
1 parent 6b79073 commit fead28f

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

tests/test_version.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,20 @@
1010
VERSION_FILE = "src/version.txt"
1111

1212

13+
@pytest.fixture(scope="session")
14+
def project_version():
15+
"""Return the version of the project."""
16+
with open(VERSION_FILE) as f:
17+
project_version = f.read().strip()
18+
return project_version
19+
20+
1321
@pytest.mark.skipif(
1422
GITHUB_RELEASE_TAG in [None, ""],
1523
reason="this is not a release (GITHUB_RELEASE_TAG not set)",
1624
)
17-
def test_release_version():
25+
def test_release_version(project_version):
1826
"""Verify that release tag version agrees with the module version."""
19-
pkg_vars = {}
20-
with open(VERSION_FILE) as f:
21-
exec(f.read(), pkg_vars) # nosec
22-
project_version = pkg_vars["__version__"]
2327
assert (
2428
GITHUB_RELEASE_TAG == f"v{project_version}"
2529
), "GITHUB_RELEASE_TAG does not match the project version"

0 commit comments

Comments
 (0)