[py-dev] py.test patches and problems

Valentino Volonghi aka Dialtone dialtone at divmod.com
Sun Mar 6 01:44:51 CET 2005


I think there is far too magic in py.test :).

Since I need a markdown parser I've started a new project. Unfortunately 
the Markdown test suite is completely useless (whoever wrote it must 
have some problems with blank lines in html output).

Hence I wanted to build my own test suite using py.test

First problem: I'm under MacOSX and I'm using python built with the 
framework. This means _findpy.py is not ready to locate my py dir and 
fails (even if import py finishes without problems).
I modified _findpy.py in this way:

Index: py/bin/_findpy.py
===================================================================
--- py/bin/_findpy.py   (revision 9671)
+++ py/bin/_findpy.py   (working copy)
@@ -27,6 +27,9 @@
 if not searchpy(abspath(os.curdir)):
     if not searchpy(opd(abspath(sys.argv[0]))):
         if not searchpy(opd(__file__)):
-            raise SystemExit, "Could not find 'py' package!"
+            for path in sys.path:
+                if searchpy(path):
+                    break
+            else: raise SystemExit, "Could not find 'py' package!"
 
 import py


And now it works. Pythondir under MacOSX with framework is:
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages
while python executable is under:
/Library/Frameworks/Python.framework/Versions/2.4/bin/python

But then there is another problem with other software that uses 
__import__() function.

I'm working with Nevow and it uses a particular function: namedAny which 
loads a module from PYTHONPATH using the complete path to the module.

This is one of the many error outputs that I have while running 'py.test'.

    def namedAny(name):
        """Get a fully named package, module, module-global object, or 
attribute.
        """
        names = name.split('.')
        topLevelPackage = None
        moduleNames = names[:]
        while not topLevelPackage:
            try:
                trialname = '.'.join(moduleNames)
E               topLevelPackage = __import__(trialname)
~               ImportError: 
__import__('nevow.flat.flatstan.TagSerializer')  << No module named 
TagSerializer

Is there any way to fix this last behaviour? I fear that import hooks 
are too magic, for a py.test newbie like me, to dig in.

-- 
Valentino Volonghi aka Dialtone
Now Running MacOSX 10.3.8
Blog: http://vvolonghi.blogspot.com
http://weever.berlios.de




More information about the Pytest-dev mailing list