简体   繁体   English

“AssertionError: False is not True”当我试图运行我的代码时

[英]"AssertionError: False is not True" When I am trying to run my code

I am getting an error on this function:我在这个 function 上收到错误消息:

def test_returns_true_when_feature_is_enabled(self):
    # Arrange
    mock_client = mock.MagicMock()
    mock_client.is_feature_enabled.return_value = True
    with patch.object(fullstack_service, 'get_optly_object', return_value=mock_client):
      with patch('services.js_validator.js_validator_service_rollout._get_account_id', return_value=123):
        # Act / Assert
        self.assertTrue(should_use_js_validator_service())

The error I get is:我得到的错误是:

AssertionError: False is not true
test/services_test/js_validator_test/js_validator_service_rollout_test.py:44: AssertionError

How can I fix this?我怎样才能解决这个问题?

With a liberal use of the Inte.net, I found that on GeeksforGeeks , when the first parameter is False , assertTrue fails the test and prints the (seemingly optional) second parameter.通过自由使用 Inte.net,我发现在GeeksforGeeks上,当第一个参数为False时, assertTrue失败并打印(看似可选的)第二个参数。 When the first parameter is True , it doesn't do anything.当第一个参数为True时,它什么都不做。 The issue is that the function should_use_js_validator_service() , which you have passed to assertTrue , does not return a truthy value.问题是您传递给assertTrue的 function should_use_js_validator_service()没有返回真值。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我得到 AssertionError: True is not false 我的代码可能有什么问题? - I get AssertionError: True is not false what may be wrong with my code? 每当我在我的 django 项目上运行 tests.py 时,“AssertionError: False is not true”不断弹出 - "AssertionError: False is not true" keeps popping up whenever i run tests.py on my django project 当我尝试运行代码时,它会出错 - When I am trying to run the code it gives error KeyError:尝试运行预测模型时为真/假 - KeyError: True/False when trying to run prediction model AssertionError:移至基于函数的视图时,False不是true - AssertionError: False is not true when moving to Function Based Views 我正在尝试运行现有代码,但是当我尝试运行代码时,错误显示“没有名为 fetch 的模块” - I am trying to run and existing code but when I try to run the code the error shows “No module named fetch” 为什么我在尝试运行我的 Discord 机器人时会收到此错误 - Why am I getting this error when I am trying to run my Discord bot 为什么当我运行“ 0和True”或“ 0和False”时得到0 - Why do I get 0 when I run “0 and True” or “0 and False” 我想获取网址,而不是代码中的True或False - I want to get the URLs, not True or False in my code 我的Palindrome代码中的一个bug。 我的函数运行正常,除非当我调用('abba')返回false而不是True时。 为什么 - a bug in my Palindrome code . My function runs fine except when i call ('abba') returns false instead of True . Why
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM