[pypy-commit] cffi default: Add a test that the version is consistent.

arigo noreply at buildbot.pypy.org
Fri Jun 29 12:42:10 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r569:e96c7e18aecf
Date: 2012-06-29 12:41 +0200
http://bitbucket.org/cffi/cffi/changeset/e96c7e18aecf/

Log:	Add a test that the version is consistent.

diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -3815,5 +3815,9 @@
     if (v == NULL || PyModule_AddObject(m, "_C_API", v) < 0)
         return;
 
+    v = PyString_FromString("0.2");
+    if (v == NULL || PyModule_AddObject(m, "__version__", v) < 0)
+        return;
+
     init_errno();
 }
diff --git a/cffi/__init__.py b/cffi/__init__.py
--- a/cffi/__init__.py
+++ b/cffi/__init__.py
@@ -3,3 +3,6 @@
 
 from .api import FFI, CDefError, FFIError
 from .ffiplatform import VerificationError, VerificationMissing
+
+__version__ = "0.2"
+__version_info__ = (0, 2)
diff --git a/testing/test_version.py b/testing/test_version.py
new file mode 100644
--- /dev/null
+++ b/testing/test_version.py
@@ -0,0 +1,16 @@
+import os
+import cffi, _cffi_backend
+
+def test_version():
+    v = cffi.__version__
+    assert v == '%s.%s' % cffi.__version_info__
+    assert v == _cffi_backend.__version__
+
+def test_doc_version():
+    parent = os.path.dirname(os.path.dirname(__file__))
+    p = os.path.join(parent, 'doc', 'source', 'conf.py')
+    content = file(p).read()
+    #
+    v = cffi.__version__
+    assert ("version = '%s'\n" % v) in content
+    assert ("release = '%s'\n" % v) in content


More information about the pypy-commit mailing list