[pypy-commit] cffi cffi-1.0: Check that the base class' instances don't allow random attributes

arigo noreply at buildbot.pypy.org
Sat May 2 22:11:36 CEST 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: cffi-1.0
Changeset: r1904:ece4874b2b8e
Date: 2015-05-02 22:12 +0200
http://bitbucket.org/cffi/cffi/changeset/ece4874b2b8e/

Log:	Check that the base class' instances don't allow random attributes

diff --git a/_cffi1/test_ffi_obj.py b/_cffi1/test_ffi_obj.py
--- a/_cffi1/test_ffi_obj.py
+++ b/_cffi1/test_ffi_obj.py
@@ -55,6 +55,12 @@
     NULL = _cffi1_backend.FFI.NULL
     assert _cffi1_backend.FFI().typeof(NULL).cname == "void *"
 
+def test_ffi_no_attr():
+    ffi = _cffi1_backend.FFI()
+    py.test.raises(AttributeError, "ffi.no_such_name")
+    py.test.raises(AttributeError, "ffi.no_such_name = 42")
+    py.test.raises(AttributeError, "del ffi.no_such_name")
+
 def test_ffi_string():
     ffi = _cffi1_backend.FFI()
     p = ffi.new("char[]", b"foobar\x00baz")


More information about the pypy-commit mailing list