File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ import tempfile
2+
3+ import pytest
4+
5+ from linearmodels import __version__ , version_tuple
6+
7+ try :
8+ from linearmodels ._build .git_version import get_version , write_version_file
9+
10+ HAS_SETUPTOOLS_SCM = True
11+ except ImportError :
12+ HAS_SETUPTOOLS_SCM = False
13+
14+
15+ @pytest .mark .skipif (not HAS_SETUPTOOLS_SCM , reason = "setuptools_scm is not installed" )
16+ def test_get_version ():
17+ try :
18+ version , version_fields = get_version ()
19+
20+ assert isinstance (version , str )
21+ assert isinstance (version_fields , tuple )
22+ assert all (isinstance (v , (int , str )) for v in version_fields )
23+ except LookupError :
24+ pytest .skip ("No git repository found" )
25+
26+
27+ @pytest .mark .skipif (not HAS_SETUPTOOLS_SCM , reason = "setuptools_scm is not installed" )
28+ def test_write_version_file ():
29+ with tempfile .NamedTemporaryFile (delete = False ) as tmpfile :
30+
31+ write_version_file (tmpfile .name , __version__ , version_tuple )
32+ with open (tmpfile .name , "r" ) as f :
33+ content = f .read ()
34+
35+ assert f"__version__ = version = '{ __version__ } '" in content
36+ assert f"__version_tuple__ = version_tuple = { version_tuple } " in content
You can’t perform that action at this time.
0 commit comments