I'm trying to reproduce example from "Test-driven development with Twisted" at http://twistedmatrix.com/documents/current/core/howto/trial.html.
I created files:
calculus/__init__.py
calculus/base_1.py
calculus/test/__init__.py
calculus/test/test_base_1.py
I modified PYTHONPATH:
[xxx@zzz calculus]$ PYTHONPATH="$PYTHONPATH:`pwd`/.."
I invoked trial:
[xxx@zzz twistedm]$ trial calculus.test.test_base_1
calculus
test
test_base_1 ... [ERROR]
===============================================================================
[ERROR]
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/twisted/trial/runner.py", line 602, in loadByNames
things.append(self.findByName(name))
File "/usr/lib/python2.7/site-packages/twisted/trial/runner.py", line 406, in findByName
return reflect.namedAny(name)
File "/usr/lib/python2.7/site-packages/twisted/python/reflect.py", line 307, in namedAny
raise ObjectNotFound('%r does not name an object' % (name,))
twisted.python.reflect.ObjectNotFound: 'calculus.test.test_base_1' does not name an object
calculus.test.test_base_1
-------------------------------------------------------------------------------
Ran 1 tests in 0.199s
FAILED (errors=1)
Python didn't find my module.
But if I invoke python shell and try to import my modules, python imports them.
I then added a line "sys.path.append('/home/xxx/twistedm/calculus/..')" into file "/usr/lib/python2.7/site-packages/twisted/python/reflect.py". And now all works as it should.
So I've found out that trial looks for modules in sys.path, and setting PYTHONPATH on command line has no effect on sys.path.
The question is how to modify sys.path from command line when invoking trial.