Twisted Trial是否支持相对导入?

时间:2016-06-10 14:59:26

标签: python twisted trial

我"相对进口"我的py文件和测试文件中的一些模块。

from .. import Message
from .Server import StupServerProtocol

它与py.test完美配合,但当我转向扭曲试验时,一切都出错了。

[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

我的目录树是这样的:

├── 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

是否有像pytest这样的东西来代替试用?或者一些努力让审判开心?

感谢。

0 个答案:

没有答案