Python 无法为openstack nova运行单元测试

Python 无法为openstack nova运行单元测试,python,unit-testing,virtualenv,openstack,openstack-nova,Python,Unit Testing,Virtualenv,Openstack,Openstack Nova,我能够为nova创建虚拟环境来运行单元测试。至少它是这么说的 Nova development environment setup is complete. Nova development uses virtualenv to track and manage Python dependencies while in development and testing. To activate the Nova virtualenv for the extent of your current s

我能够为nova创建虚拟环境来运行单元测试。至少它是这么说的

Nova development environment setup is complete.
Nova development uses virtualenv to track and manage Python dependencies
while in development and testing.
To activate the Nova virtualenv for the extent of your current shell
session you can run:
.....
但是当我尝试运行特定的单元测试用例时,例如:

./run_tests.sh test_libvirt

它说的是:

Running `tools/with_venv.sh python -m nova.openstack.common.lockutils python setup.py testr --testr-args='--subunit --concurrency 0  test_libvirt'`

Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/chinmay/nova/nova/openstack/common/lockutils.py", line 29, in <module>
    from oslo.config import cfg
**ImportError: No module named config**
Ran 0 tests in 0.006s
OK
运行'tools/with_venv.sh python-m nova.openstack.common.lockutils python setup.py testr--testr args='--subunit--concurrency 0 test_libvirt'`
回溯(最近一次呼叫最后一次):
文件“/usr/lib/python2.7/runpy.py”,第162行,在运行模块中作为主模块
“\uuuuu main\uuuuuuuuuuuuuuuuuuuuuuuuu”,fname,loader,pkg\u name)
文件“/usr/lib/python2.7/runpy.py”,第72行,在运行代码中
run_globals中的exec代码
文件“/home/chinmay/nova/nova/openstack/common/lockutils.py”,第29行,在
从oslo.config导入cfg
**ImportError:没有名为config的模块**
在0.006秒内运行了0个测试
好啊
virtaul环境是否设置不正确?env中的oslo.config。是的
source.venv/bin/activate
并重试,但结果相同


我是不是遗漏了什么

请删除
oslo.config
并在您的虚拟环境中重新安装。这可能会解决您的问题:)

是的。试过了。我怀疑env没有正确配置。在那之后,我必须运行testr init,现在我可以运行单元测试了。Thananks如果这解决了您的问题,请选择它作为答案;)