运行带有谷歌云SDK的nosetests --with-gae时出错

1 投票
4 回答
1061 浏览
提问于 2025-04-28 19:41

在新的云SDK下,运行nosetests --with-gae时出错。它在找一个叫dev_appserver.py的文件,但这个文件好像被改名成old_dev_appserver.py了。我可以自己想办法解决,但不知道有没有现成的解决方案?在网上没找到相关信息...

$ nosetests --with-gae --gae-lib-root=~/google-cloud-sdk/platform/google_appengine
Traceback (most recent call last):
  File "/Users/edahl/src/gmj/bin/nosetests", line 9, in <module>
    load_entry_point('nose==1.3.4', 'console_scripts', 'nosetests')()
  File "/Users/edahl/src/gmj/lib/python2.7/site-packages/nose/core.py", line 121, in __init__
    **extra_args)
  File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 94, in __init__
    self.parseArgs(argv)
  File "/Users/edahl/src/gmj/lib/python2.7/site-packages/nose/core.py", line 145, in parseArgs
    self.config.configure(argv, doc=self.usage())
  File "/Users/edahl/src/gmj/lib/python2.7/site-packages/nose/config.py", line 346, in configure
    self.plugins.configure(options, self)
  File "/Users/edahl/src/gmj/lib/python2.7/site-packages/nose/plugins/manager.py", line 284, in configure
    cfg(options, config)
  File "/Users/edahl/src/gmj/lib/python2.7/site-packages/nose/plugins/manager.py", line 99, in __call__
    return self.call(*arg, **kw)
  File "/Users/edahl/src/gmj/lib/python2.7/site-packages/nose/plugins/manager.py", line 167, in simple
    result = meth(*arg, **kw)
  File "/Users/edahl/src/gmj/lib/python2.7/site-packages/nosegae.py", line 80, in configure
    from dev_appserver import fix_sys_path
ImportError: No module named dev_appserver

这是我在google_appengine目录下看到的内容...

$ ls ~/google-cloud-sdk/platform/google_appengine/
BUGS            api_server.py       godoc           php
LICENSE         backends_conversion.py  gofmt           php_cli.py
README          bulkload_client.py  google          remote_api_shell.py
RELEASE_NOTES       bulkloader.py       google_sql.py       run_tests.py
RELEASE_NOTES.go_sdk    demos           goroot          tools
VERSION         download_appstats.py    lib         wrapper_util.py
_php_runtime.py     gen_protorpc.py     new_project_template    wrapper_util.pyc
_python_runtime.py  goapp           old_dev_appserver.py

以前的/usr/local/google_appengine目录似乎已经不再使用了……不过如果我用这个目录,就能让事情正常运转。

[更新]

手动设置单元测试,使用old_dev_appserver像这样是可以工作的:

def main(sdk_path, test_path):
    sys.path.insert(0, sdk_path)
    import old_dev_appserver
    old_dev_appserver.fix_sys_path()
    suite = unittest.loader.TestLoader().discover(test_path)
    unittest.TextTestRunner(verbosity=2).run(suite)
暂无标签

4 个回答

0

根据NoseGAE的文档,它默认会在 /usr/local/google_appengine 这个位置查找google-cloud-sdk。

我把 google-cloud-sdk 文件夹移动到 /usr/local/google_appengine/google-cloud-sdk/ 这个位置后,问题就解决了。

http://farmdev.com/projects/nosegae/

0

你可能需要把路径设置到那个目录下的lib文件夹:

--gae-lib-root=~/google-cloud-sdk/platform/google_appengine/lib

但你也可能需要把你的PATH变量设置一下,让它包含/bin这个路径:

export PATH=$PATH:~/google-cloud-sdk/platform/google_appengine/bin

如果这两种方法都不行,试试加上不使用沙盒的选项:

nosetests -s -v --with-gae --without-sandbox 
1

在我的Mac上,我也遇到了同样的错误:

  1. 是在应用引擎更新之后
  2. 但在我运行GoogleAppEngineLauncher这个应用之前

解决这个问题的方法很简单,就是启动GoogleAppEngineLauncher。这会更新nosetests所需要的符号链接。

希望这个方法对你有用。

2

最后这真是有点傻... 需要扩展一下传给 --gae-lib-root 的用户路径。

nosetests --with-gae --gae-lib-root=/Users/USERNAME/google-cloud-sdk/platform/google_appengine

撰写回答