forked from Jason-Vaughan/TangleBrain
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_version.py
More file actions
32 lines (23 loc) · 1.22 KB
/
Copy pathtest_version.py
File metadata and controls
32 lines (23 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""Tests for the package version (tanglebrain.__version__).
The version must come from the installed distribution metadata (driven by ``pyproject.toml``), not
a hardcoded literal, so it never drifts from the released version again.
"""
from __future__ import annotations
import unittest
from importlib.metadata import version
import tanglebrain
class VersionTest(unittest.TestCase):
def test_version_is_a_nonempty_string(self):
self.assertIsInstance(tanglebrain.__version__, str)
self.assertTrue(tanglebrain.__version__)
def test_version_tracks_installed_metadata(self):
# Single source of truth: __version__ == the installed dist's version (from pyproject).
# The dev/test env installs the package editable (`make venv`), so metadata is present.
self.assertEqual(tanglebrain.__version__, version("tanglebrain"))
def test_not_the_stale_literal_or_sentinel(self):
# Regression guards: the old frozen literal value and the uninstalled fallback must not
# appear in an installed environment.
self.assertNotEqual(tanglebrain.__version__, "0.1.0")
self.assertNotEqual(tanglebrain.__version__, "0.0.0+unknown")
if __name__ == "__main__":
unittest.main()