我ruby 1.9.2p180 (2011-02-18) [i386-mingw32]在我的Windows 7机器上安装了.现在我尝试使用命令"gem install json"安装JSON gem并得到以下错误.
ERROR: Error installing JSON:
The 'json' native gem requires installed build tools.
Please update your PATH to include build tools or download the DevKit
from '[http://rubyinstaller.org/downloads][1]' and follow the instructions
at '[http://github.com/oneclick/rubyinstaller/wiki/Development-Kit][2]'
Run Code Online (Sandbox Code Playgroud)
然后我去下载DevKit-4.5.0-20100819-1536-sfx.exe.将它提取到C:\ DevKit.然后从命令提示符执行以下命令.
ruby dk.rb init
Run Code Online (Sandbox Code Playgroud)
执行上述命令后,我确认已生成config.yaml,并且它自动添加了我的ruby文件夹的路径.这是config.yaml文件底部的行" - C:/ Ruby192"
ruby dk.rb review
Run Code Online (Sandbox Code Playgroud)
我得到的消息是,当您运行"ruby dk.rb install"时,devkit功能将被注入到rubies中
ruby dk.rb install
Run Code Online (Sandbox Code Playgroud)
我收到以下消息.
[INFO] RubyGems override already in place for C:/Ruby192, skipping.
[INFO] Installing C:/Ruby192/lib/ruby/site_ruby/devkit.rb
Run Code Online (Sandbox Code Playgroud)
现在我尝试使用该命令再次执行JSON gem gem install json.然后得到与以前相同的错误消息.
ERROR: …Run Code Online (Sandbox Code Playgroud) 在我开始在python项目中执行测试之前,我读了一些环境变量并设置了一些读取这些值的变量.我的测试将根据读取的这些值在所需的环境中运行.
例如:假设环境变量被称为"ENV_NAME"和"ENV_NUMBER"
现在,我想使用py.test运行测试
如果我硬编码这些环境变量,例如:ENV_NAME ='staging',我的代码中的ENV_NUMBER ='5'然后通过在项目目录的根目录执行py.test命令来运行测试,所有测试都成功运行.
但是,我不想硬编码这些值.有没有办法,我可以将这些环境变量作为py.test的命令行参数发送?
我的想法更多
py.test -ENV_NAME ='staging'-ENV_NUMBER ='5'.但是,这不起作用.
请帮忙!谢谢!
我正在尝试在GitHub上配置Web挂钩,以便它可以将POST发送到http://127.0.0.1:8080/github-webhook/
我的詹金斯正在http://127.0.0.1:8080上运行
我的詹金斯肯定在http://127.0.0.1:8080/上运行.所以,这肯定不是问题.
我想在使用pytest执行所有测试后运行特定代码
例如:我在执行任何测试之前打开数据库连接.我想在执行所有测试后关闭连接.
我如何用py.test实现这一目标?是否有夹具或某些东西可以做到这一点?
谢谢!
我想为每个测试方法创建一个单独的日志文件。我想在 conftest.py 文件中执行此操作,并将日志文件实例传递给测试方法。这样,每当我在测试方法中记录某些内容时,它都会记录到单独的日志文件中,并且非常容易分析。
我尝试了以下方法。在 conftest.py 文件中我添加了以下内容:
logs_dir = pkg_resources.resource_filename("test_results", "logs")
def pytest_runtest_setup(item):
test_method_name = item.name
testpath = item.parent.name.strip('.py')
path = '%s/%s' % (logs_dir, testpath)
if not os.path.exists(path):
os.makedirs(path)
log = logger.make_logger(test_method_name, path) # Make logger takes care of creating the logfile and returns the python logging object.
Run Code Online (Sandbox Code Playgroud)
这里的问题是 pytest_runtest_setup 无法向测试方法返回任何内容。至少,我不知道。
因此,我想到在 conftest.py 文件中创建一个带有scope =“function”的固定方法,并从测试方法中调用此固定装置。但是,fixture 方法不知道 Pytest.Item 对象。对于 pytest_runtest_setup 方法,它接收 item 参数,并使用该参数我们能够找到测试方法名称和测试方法路径。
请帮忙!