[Checkins]
SVN: martian/branches/jw-philipp-using-ndir-directives/src/martian/tests/
Port test for scan_for_module_components over to scan_for_classes.
Philipp von Weitershausen
philikon at philikon.de
Sun May 4 08:56:06 EDT 2008
Log message for revision 86357:
Port test for scan_for_module_components over to scan_for_classes.
Changed:
A martian/branches/jw-philipp-using-ndir-directives/src/martian/tests/scan_for_module_components.txt
A martian/branches/jw-philipp-using-ndir-directives/src/martian/tests/scan_for_module_components_fixture/
U martian/branches/jw-philipp-using-ndir-directives/src/martian/tests/scan_for_module_components_fixture/__init__.py
U martian/branches/jw-philipp-using-ndir-directives/src/martian/tests/scan_for_module_components_fixture/test2.py
U martian/branches/jw-philipp-using-ndir-directives/src/martian/tests/scan_for_module_components_fixture/test3.py
U martian/branches/jw-philipp-using-ndir-directives/src/martian/tests/scan_for_module_components_fixture/test4.py
U martian/branches/jw-philipp-using-ndir-directives/src/martian/tests/test_all.py
-=-
Copied: martian/branches/jw-philipp-using-ndir-directives/src/martian/tests/scan_for_module_components.txt (from rev 86233, grokcore.component/trunk/src/grokcore/component/tests/scan_for_module_components.txt)
===================================================================
--- martian/branches/jw-philipp-using-ndir-directives/src/martian/tests/scan_for_module_components.txt (rev 0)
+++ martian/branches/jw-philipp-using-ndir-directives/src/martian/tests/scan_for_module_components.txt 2008-05-04 12:56:06 UTC (rev 86357)
@@ -0,0 +1,36 @@
+Scanning for the context object
+-------------------------------
+
+Let's import a module that contains no ``Context`` subclass, nor classes
+that implement ``IContext``::
+
+ >>> import martian.tests.scan_for_module_components_fixture as tests
+ >>> IContext = tests.IContext
+
+We shouldn't see any classes that are contexts::
+
+ >>> from martian.util import scan_for_classes
+ >>> from martian.tests.scan_for_module_components_fixture import test1
+ >>> list(scan_for_classes(test1, interface=IContext))
+ []
+
+Now we look at a module with a single ``Context`` subclass::
+
+ >>> from martian.tests.scan_for_module_components_fixture import test2
+ >>> list(scan_for_classes(test2, interface=IContext))
+ [<class 'martian.tests.scan_for_module_components_fixture.test2.MyContext'>]
+
+Now we'll look at a module with a single class that implements ``IContext``::
+
+ >>> from martian.tests.scan_for_module_components_fixture import test3
+ >>> list(scan_for_classes(test3, interface=IContext))
+ [<class 'martian.tests.scan_for_module_components_fixture.test3.MyContext'>]
+
+Let's finish by looking at a module which defines multiple contexts::
+
+ >>> from martian.tests.scan_for_module_components_fixture import test4
+ >>> len(list(scan_for_classes(test4, interface=IContext)))
+ 4
+
+
+
Copied: martian/branches/jw-philipp-using-ndir-directives/src/martian/tests/scan_for_module_components_fixture (from rev 86233, grokcore.component/trunk/src/grokcore/component/tests/scan_for_module_components_fixture)
Modified: martian/branches/jw-philipp-using-ndir-directives/src/martian/tests/scan_for_module_components_fixture/__init__.py
===================================================================
--- grokcore.component/trunk/src/grokcore/component/tests/scan_for_module_components_fixture/__init__.py 2008-05-03 15:12:03 UTC (rev 86233)
+++ martian/branches/jw-philipp-using-ndir-directives/src/martian/tests/scan_for_module_components_fixture/__init__.py 2008-05-04 12:56:06 UTC (rev 86357)
@@ -1,4 +1,7 @@
-from grokcore.component.tests.scan_for_module_components_fixture import test1
-from grokcore.component.tests.scan_for_module_components_fixture import test2
-from grokcore.component.tests.scan_for_module_components_fixture import test3
-from grokcore.component.tests.scan_for_module_components_fixture import test4
+from zope.interface import Interface, implements
+
+class IContext(Interface):
+ pass
+
+class Context(object):
+ implements(IContext)
Modified: martian/branches/jw-philipp-using-ndir-directives/src/martian/tests/scan_for_module_components_fixture/test2.py
===================================================================
--- grokcore.component/trunk/src/grokcore/component/tests/scan_for_module_components_fixture/test2.py 2008-05-03 15:12:03 UTC (rev 86233)
+++ martian/branches/jw-philipp-using-ndir-directives/src/martian/tests/scan_for_module_components_fixture/test2.py 2008-05-04 12:56:06 UTC (rev 86357)
@@ -2,7 +2,7 @@
# this module is used in a scan_for_context.txt test.
import os
-from grokcore.component import Context
+from martian.tests.scan_for_module_components_fixture import Context
foo = "Bar"
Modified: martian/branches/jw-philipp-using-ndir-directives/src/martian/tests/scan_for_module_components_fixture/test3.py
===================================================================
--- grokcore.component/trunk/src/grokcore/component/tests/scan_for_module_components_fixture/test3.py 2008-05-03 15:12:03 UTC (rev 86233)
+++ martian/branches/jw-philipp-using-ndir-directives/src/martian/tests/scan_for_module_components_fixture/test3.py 2008-05-04 12:56:06 UTC (rev 86357)
@@ -2,7 +2,7 @@
# this module is used in a scan_for_context.txt test.
import os
-from grokcore.component.interfaces import IContext
+from martian.tests.scan_for_module_components_fixture import IContext
from zope.interface import implements
foo = "Bar"
Modified: martian/branches/jw-philipp-using-ndir-directives/src/martian/tests/scan_for_module_components_fixture/test4.py
===================================================================
--- grokcore.component/trunk/src/grokcore/component/tests/scan_for_module_components_fixture/test4.py 2008-05-03 15:12:03 UTC (rev 86233)
+++ martian/branches/jw-philipp-using-ndir-directives/src/martian/tests/scan_for_module_components_fixture/test4.py 2008-05-04 12:56:06 UTC (rev 86357)
@@ -2,8 +2,7 @@
# this module is used in a scan_for_context.txt test.
import os
-from grokcore.component import Context
-from grokcore.component.interfaces import IContext
+from martian.tests.scan_for_module_components_fixture import IContext, Context
from zope.interface import implements
foo = "Bar"
Modified: martian/branches/jw-philipp-using-ndir-directives/src/martian/tests/test_all.py
===================================================================
--- martian/branches/jw-philipp-using-ndir-directives/src/martian/tests/test_all.py 2008-05-04 12:53:09 UTC (rev 86356)
+++ martian/branches/jw-philipp-using-ndir-directives/src/martian/tests/test_all.py 2008-05-04 12:56:06 UTC (rev 86357)
@@ -76,5 +76,8 @@
package='martian',
globs=globs,
optionflags=optionflags),
+ doctest.DocFileSuite('scan_for_module_components.txt',
+ package='martian.tests',
+ optionflags=optionflags),
])
return suite
More information about the Checkins
mailing list