I "relative import" some module in my py file and test file.
from .. import Message
from .Server import StupServerProtocol
It works perfectly with py.test, but when I turn to twisted trial, everything goes wrong.
[ERROR]
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/twisted/trial/runner.py", line 605, in loadByNames
things.append(self.findByName(name))
File "/usr/local/lib/python2.7/site-packages/twisted/trial/runner.py", line 408, in findByName
return filenameToModule(name)
File "/usr/local/lib/python2.7/site-packages/twisted/trial/runner.py", line 96, in filenameToModule
return _importFromFile(fn)
File "/usr/local/lib/python2.7/site-packages/twisted/trial/runner.py", line 120, in _importFromFile
module = imp.load_source(moduleName, fn, fd)
File "Server_test.py", line 12, in <module>
from .. import Message
exceptions.ValueError: Attempted relative import in non-package
And my directory tree is like this:
├── Message
│ ├── __init__.py
├── Protocol
│ ├── Server.py
│ ├── Server_test.py (* i'm want to run this)
│ ├── __init__.py
├── Utils.py
├── Worker
│ ├── RawWorker.py
│ ├── WorkerBase.py
│ ├── __init__.py
Is there something like pytest to replace trial? Or some work around to make trial happy?
Thanks.