| 1 |
|
| 2 |
import os, sys |
| 3 |
import pytest |
| 4 |
import cffi, _cffi_backend |
| 5 |
|
| 6 |
|
| 7 |
def setup_module(mod): |
| 8 |
if '_cffi_backend' in sys.builtin_module_names: |
| 9 |
pytest.skip("this is embedded version") |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 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 |
|
| 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 |
|
| 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 |