IronPython and PyFit PYTHONPATH Ordering

Lately I have been working on implementing an acceptance testing stack using the following:

I wasn’t the first person to try PyFit on IronPython and based on this suggestion we have switched from vanilla Iron Python to the Iron Python Community Edition for its almost out of the box compatibility with PyFit.

Anyway I ran into the following ERROR when using PyFit with Iron Python. Preparing a test runner as so:


Environment
IRONPYTHONPATH=c:\tools\pyfit\fit

import sys
import fepy
fepy.install_option('ast')
from fitnesse.FitServerImplementation import TestRunner

Causes the FitServerImplementation not to be found:


FitNesse cannot be started...
Port 80 is already in use.
Use the -p command line argument to use a different port.
Traceback (most recent call last):
File test_runner.py, line 4, in Initialize
File , line 0, in __import__##4
ImportError: No module named FitServerImplementation

This is unexpected because I am not trying to launch FitNesse and PyFit is on the IRONPYTHONPATH. What I discovered was that instead of using the IRONPYTHONPATH which essentially appends PyFit inserting PyFit at the beginning results in a correct PyFit resolution.


IRONPYTHONPATH= #No PyFit Reference

import sys
import fepy

fepy.install_option('ast')
fitpath = "PathTo/PyFIT/fit"
sys.path.insert(0, fitpath)

from fitnesse.FitServerImplementation import TestRunner

Now the TestRunner (or whatever PyFit class be it a fixture, runner, etc) is found. I am not sure why this is the case (my ignorance of python / iron python doesn’t hep) and would appreciate any insights.

2 Responses to “IronPython and PyFit PYTHONPATH Ordering”

  1. Michael Foord Says:

    It’s hard to tell, but it looks from your example like you are using a relative path in your code whereas you specified an absolute path in the environment variable.

    It is either some subtle difference due to this, or the ordering in the order in the path as you suggest.

    Putting some prints into the Fitnesse module may help you diagnose it - but I can’t spot anything obvious from your description here.

  2. peter Says:

    In both examples I am using an absolute path. My /PathToPyFit was just a replacement from the actual path on my system which contained a proprietary fragment.

Leave a Reply