0
我調查pyresttest的使用來測試我們的API添加自己的分機呼叫也是新Python和停留在一點:無法與發電機pyresttest
與發電機文件:
import pyresttest.validators as validators from pyresttest.binding import Context import sys import datetime def get_current_date_time(): return datetime.datetime.now().isoformat() GENERATORS = {'date': get_current_date_time}
當我運行此命令,在我的測試情況下使用發電機
pyresttest http://localhost:8181/ generator_test.yaml --import_extension 'date'
我得到這個:
Traceback (most recent call last): File "/usr/local/bin/pyresttest",
line 4, in <module>
__import__('pkg_resources').run_script('pyresttest==1.7.2.dev0', 'pyresttest') File
"/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py",
line 739, in run_script
self.require(requires)[0].run_script(script_name, ns) File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py",
line 1494, in run_script
exec(code, namespace, namespace) File "/usr/local/lib/python2.7/site-packages/pyresttest-1.7.2.dev0-py2.7.egg/EGG-INFO/scripts/pyresttest",
line 4, in <module>
resttest.command_line_run(sys.argv[1:]) File "/usr/local/lib/python2.7/site-packages/pyresttest-1.7.2.dev0-py2.7.egg/pyresttest/resttest.py",
line 914, in command_line_run
main(args) File "/usr/local/lib/python2.7/site-packages/pyresttest 1.7.2.dev0-py2.7.egg/pyresttest/resttest.py",
line 815, in main
register_extensions(extensions) File "/usr/local/lib/python2.7/site-packages/pyresttest-1.7.2.dev0-py2.7.egg/pyresttest/resttest.py",
line 748, in register_extensions
module = __import__(ext, globals(), locals(), package) ImportError: No module named date
我失去了一些東西簡單,或者它是一個錯字的地方? 謝謝。
也許'import_extension'會比我們你認爲它做其他的東西嗎? – pvg
根據這個文檔https://github.com/svanoort/pyresttest/blob/master/extensions.md - >擴展名是在運行時爲loadin指定的,而--import_extensions參數就是爲了這個目的。我已經嘗試了該項目示例中提出的解決方案。 'resttest.py https://api.github.com extension_use_test.yaml --import_extensions'sample_extension' 測試組成功成功::3/3測試通過!' - 效果很好。我現在很困惑。 –