小编Haj*_*jar的帖子

Django 测试:匹配的查询不存在

我一直在开发一个博客应用程序,它具有三个常规模型:PostCategoryComment。现在我正在尝试为这些模型编写一些测试。当我单独运行测试时,它们会顺利通过。但是当我对 test_models.py 作为一个整体运行测试时,我收到四个错误,告诉我我Comment/Category matching query does not exist.明白这个错误意味着 django 无法id在运行测试时创建的数据库中找到我想要的。我的问题是,为什么仅当我对 test_model 文件运行测试时才会出现这些错误,而当我单独对测试类运行测试时却不会出现这些错误?

python manage.py test blog.tests.test_models.TestPostModel -v 2 # this command doesn't cause errors
python manage.py test blog.tests.test_models -v 2  # but this one causes 4 errors in TestPostModel
Run Code Online (Sandbox Code Playgroud)

测试模型.py

from blog.models import Post, Category, Comment, Recipient
from django.test import TestCase

class TestPostModel(TestCase):
@classmethod
def setUpTestData(cls):
    Post.objects.create(title="creation of the first post", body="i am the body of the first post.") …
Run Code Online (Sandbox Code Playgroud)

python testing django

5
推荐指数
1
解决办法
2700
查看次数

Rails:Selenium :: WebDriver :: Error :: WebDriverError:不可执行:'chromedriver-helper'

我两天前设置了Rails环境,我认为事情进展顺利但是当我运行rake test命令时,由于此加载错误导致它被中止:

Bundler::GemRequireError: There was an error while trying to load the gem 'chromedriver-helper'`
`Caused by: Selenium::WebDriver::Error::WebDriverError: not executable: "C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/chromedriver-helper-2.1.0/bin/chromedriver-helper"
Run Code Online (Sandbox Code Playgroud)

我尝试过一些东西,但没有任何效果.我重新安装了宝石并更新了它.然后我尝试安装它的旧版本.我也尝试添加 gem "selenium-webdriver"gem "chromedriver-helper"Gemfile

spec_helper.rb这:

Capybara.register_driver :selenium do |app|
  Capybara::Selenium::Driver.new(app, browser: :chrome)
end
Run Code Online (Sandbox Code Playgroud)

正如github上提到但不确定我接下来应该尝试什么.

有人可以帮帮我吗?谢谢.

ruby rubygems ruby-on-rails selenium-webdriver

3
推荐指数
1
解决办法
3455
查看次数