Debian Codegraph @

extra_tests/cffi_tests/cffi0/test_version.py

raw symbols SCIP
1 # Generated by pypy/tool/import_cffi.py
2 import os, sys
3 import pytest
4 import cffi, _cffi_backend
5 #from pathlib import Path --- but on pypy, this module should be skipped anyway
6
7 def setup_module(mod):
8 if '_cffi_backend' in sys.builtin_module_names:
9 pytest.skip("this is embedded version")
10
11 #BACKEND_VERSIONS = {
12 # '0.4.2': '0.4', # did not change
13 # '0.7.1': '0.7', # did not change
14 # '0.7.2': '0.7', # did not change
15 # '0.8.1': '0.8', # did not change (essentially)
16 # '0.8.4': '0.8.3', # did not change
17 # }
18
19 def _read(p):
20 with open(p) as f:
21 return f.read()
22
23 def test_version():
24 v = cffi.__version__
25 version_info = '.'.join(str(i) for i in cffi.__version_info__)
26 version_info = version_info.replace('.beta.', 'b')
27 version_info = version_info.replace('.plus', '+')
28 version_info = version_info.replace('.rc', 'rc')
29 assert v == version_info
30 #v = BACKEND_VERSIONS.get(v, v)
31 assert v == _cffi_backend.__version__
32
33 def test_doc_version():
34 cffi_root = Path(os.path.dirname(__file__)).parent.parent
35 p = cffi_root / 'doc/source/conf.py'
36 content = _read(p)
37 #
38 v = cffi.__version__
39 assert ("version = '%s'\n" % v[:4]) in content
40 assert ("release = '%s'\n" % v) in content
41
42 def test_pyproject_version():
43 cffi_root = Path(os.path.dirname(__file__)).parent.parent
44 p = cffi_root / 'setup.py'
45 content = _read(p)
46 #
47 v = cffi.__version__.replace('+', '')
48 assert ("version='%s'" % v) in content
49
50 def test_c_version():
51 cffi_root = Path(os.path.dirname(__file__)).parent.parent
52 v = cffi.__version__
53 p = cffi_root / 'src/c/test_c.py'
54 content = _read(p)
55 #v = BACKEND_VERSIONS.get(v, v)
56 assert (('assert __version__ == "%s"' % v) in content)
57
58 def test_embedding_h():
59 cffi_root = Path(os.path.dirname(__file__)).parent.parent
60 v = cffi.__version__
61 p = cffi_root / 'src/cffi/_embedding.h'
62 content = _read(p)
63 assert ('cffi version: %s"' % (v,)) in content