1import py, os, sys 2import cffi, _cffi_backend 3 4def setup_module(mod): 5 if '_cffi_backend' in sys.builtin_module_names: 6 py.test.skip("this is embedded version") 7 8#BACKEND_VERSIONS = { 9# '0.4.2': '0.4', # did not change 10# '0.7.1': '0.7', # did not change 11# '0.7.2': '0.7', # did not change 12# '0.8.1': '0.8', # did not change (essentially) 13# '0.8.4': '0.8.3', # did not change 14# } 15 16def test_version(): 17 v = cffi.__version__ 18 version_info = '.'.join(str(i) for i in cffi.__version_info__) 19 version_info = version_info.replace('.beta.', 'b') 20 version_info = version_info.replace('.plus', '+') 21 version_info = version_info.replace('.rc', 'rc') 22 assert v == version_info 23 #v = BACKEND_VERSIONS.get(v, v) 24 assert v == _cffi_backend.__version__ 25 26def test_doc_version(): 27 parent = os.path.dirname(os.path.dirname(cffi.__file__)) 28 p = os.path.join(parent, 'doc', 'source', 'conf.py') 29 content = open(p).read() 30 # 31 v = cffi.__version__ 32 assert ("version = '%s'\n" % v[:4]) in content 33 assert ("release = '%s'\n" % v) in content 34 35def test_doc_version_file(): 36 parent = os.path.dirname(os.path.dirname(cffi.__file__)) 37 v = cffi.__version__.replace('+', '') 38 p = os.path.join(parent, 'doc', 'source', 'installation.rst') 39 content = open(p).read() 40 if " package version %s:" % v not in content: 41 for i in range(5): 42 if " package version %s-%d:" % (v, i) in content: 43 break 44 else: 45 assert 0, "doc/source/installation.rst needs updating" 46 47def test_setup_version(): 48 parent = os.path.dirname(os.path.dirname(cffi.__file__)) 49 p = os.path.join(parent, 'setup.py') 50 content = open(p).read() 51 # 52 v = cffi.__version__.replace('+', '') 53 assert ("version='%s'" % v) in content 54 55def test_c_version(): 56 parent = os.path.dirname(os.path.dirname(cffi.__file__)) 57 v = cffi.__version__ 58 p = os.path.join(parent, 'c', 'test_c.py') 59 content = open(p).read() 60 #v = BACKEND_VERSIONS.get(v, v) 61 assert (('assert __version__ == "%s"' % v) in content) 62 63def test_embedding_h(): 64 parent = os.path.dirname(os.path.dirname(cffi.__file__)) 65 v = cffi.__version__ 66 p = os.path.join(parent, 'cffi', '_embedding.h') 67 content = open(p).read() 68 assert ('cffi version: %s"' % (v,)) in content 69