[Checkins] SVN: zope.pytest/trunk/src/zope/pytest/tests/sample_fixtures/zcml/mypkg/ Fix interface usage in ZCML sample fixture.

Uli Fouquet uli at gnufix.de
Sun Jan 23 07:08:28 EST 2011


Log message for revision 119853:
  Fix interface usage in ZCML sample fixture.

Changed:
  U   zope.pytest/trunk/src/zope/pytest/tests/sample_fixtures/zcml/mypkg/app.py
  U   zope.pytest/trunk/src/zope/pytest/tests/sample_fixtures/zcml/mypkg/configure.zcml
  U   zope.pytest/trunk/src/zope/pytest/tests/sample_fixtures/zcml/mypkg/interfaces.py
  A   zope.pytest/trunk/src/zope/pytest/tests/sample_fixtures/zcml/mypkg/tests/__init__.py
  U   zope.pytest/trunk/src/zope/pytest/tests/sample_fixtures/zcml/mypkg/tests/test_app.py
  U   zope.pytest/trunk/src/zope/pytest/tests/sample_fixtures/zcml/mypkg/tests/test_foo.py

-=-
Modified: zope.pytest/trunk/src/zope/pytest/tests/sample_fixtures/zcml/mypkg/app.py
===================================================================
--- zope.pytest/trunk/src/zope/pytest/tests/sample_fixtures/zcml/mypkg/app.py	2011-01-23 11:27:51 UTC (rev 119852)
+++ zope.pytest/trunk/src/zope/pytest/tests/sample_fixtures/zcml/mypkg/app.py	2011-01-23 12:08:27 UTC (rev 119853)
@@ -1,14 +1,11 @@
-import zope.interface
+from zope.interface import implements
+from mypkg.interfaces import ISampleApp, IFoo
 
-class AppSample(object):
-    pass
+class SampleApp(object):
+    implements(ISampleApp)
 
-class IFoo(zope.interface.Interface):
-    def do_foo():
-        pass
-
 class FooUtility(object):
-    zope.interface.implements(IFoo)
+    implements(IFoo)
 
     def do_foo(self):
         return "Foo!"

Modified: zope.pytest/trunk/src/zope/pytest/tests/sample_fixtures/zcml/mypkg/configure.zcml
===================================================================
--- zope.pytest/trunk/src/zope/pytest/tests/sample_fixtures/zcml/mypkg/configure.zcml	2011-01-23 11:27:51 UTC (rev 119852)
+++ zope.pytest/trunk/src/zope/pytest/tests/sample_fixtures/zcml/mypkg/configure.zcml	2011-01-23 12:08:27 UTC (rev 119853)
@@ -4,7 +4,7 @@
 
   <include package="zope.component" file="meta.zcml" />
   <utility component=".app.FooUtility" 
-	   provides=".app.IFoo" 
+	   provides=".interfaces.IFoo" 
 	   name="foo utility" />
 
 </configure>

Modified: zope.pytest/trunk/src/zope/pytest/tests/sample_fixtures/zcml/mypkg/interfaces.py
===================================================================
--- zope.pytest/trunk/src/zope/pytest/tests/sample_fixtures/zcml/mypkg/interfaces.py	2011-01-23 11:27:51 UTC (rev 119852)
+++ zope.pytest/trunk/src/zope/pytest/tests/sample_fixtures/zcml/mypkg/interfaces.py	2011-01-23 12:08:27 UTC (rev 119853)
@@ -5,12 +5,12 @@
     """
     pass
 
-class ISampleInterface1(zope.interface.Interface):
-    """Sample interface 1.
-    """
-    pass
+class IFoo(zope.interface.Interface):
+    """A Foo.
 
-class ISampleInterface2(zope.interface.Interface):
-    """Sample interface 2.
+    Foos can do foo.
     """
-    pass
+    def do_foo():
+        """Do the foo.
+        """
+        pass

Added: zope.pytest/trunk/src/zope/pytest/tests/sample_fixtures/zcml/mypkg/tests/__init__.py
===================================================================
--- zope.pytest/trunk/src/zope/pytest/tests/sample_fixtures/zcml/mypkg/tests/__init__.py	                        (rev 0)
+++ zope.pytest/trunk/src/zope/pytest/tests/sample_fixtures/zcml/mypkg/tests/__init__.py	2011-01-23 12:08:27 UTC (rev 119853)
@@ -0,0 +1 @@
+# Make this a package.

Modified: zope.pytest/trunk/src/zope/pytest/tests/sample_fixtures/zcml/mypkg/tests/test_app.py
===================================================================
--- zope.pytest/trunk/src/zope/pytest/tests/sample_fixtures/zcml/mypkg/tests/test_app.py	2011-01-23 11:27:51 UTC (rev 119852)
+++ zope.pytest/trunk/src/zope/pytest/tests/sample_fixtures/zcml/mypkg/tests/test_app.py	2011-01-23 12:08:27 UTC (rev 119853)
@@ -1,5 +1,16 @@
-from mypkg.app import AppSample
+from zope.interface.verify import verifyClass, verifyObject
+from mypkg.app import SampleApp
+from mypkg.interfaces import ISampleApp
 
 def test_app_create():
-    app = AppSample()
+    # Assure we can create instances of `SampleApp`
+    app = SampleApp()
     assert app is not None
+
+def test_app_class_iface():
+    # Assure the class implements the declared interface
+    assert verifyClass(ISampleApp, SampleApp)
+
+def test_app_instance_iface():
+    # Assure instances of the class provide the declared interface
+    assert verifyObject(ISampleApp, SampleApp())

Modified: zope.pytest/trunk/src/zope/pytest/tests/sample_fixtures/zcml/mypkg/tests/test_foo.py
===================================================================
--- zope.pytest/trunk/src/zope/pytest/tests/sample_fixtures/zcml/mypkg/tests/test_foo.py	2011-01-23 11:27:51 UTC (rev 119852)
+++ zope.pytest/trunk/src/zope/pytest/tests/sample_fixtures/zcml/mypkg/tests/test_foo.py	2011-01-23 12:08:27 UTC (rev 119853)
@@ -1,6 +1,6 @@
 import mypkg
 from zope.component import queryUtility
-from mypkg.app import IFoo
+from mypkg.interfaces import IFoo
 from zope.pytest import configure
 
 def pytest_funcarg__config(request):



More information about the checkins mailing list