• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python assertpy.assert_that函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中assertpy.assert_that函数的典型用法代码示例。如果您正苦于以下问题:Python assert_that函数的具体用法?Python assert_that怎么用?Python assert_that使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了assert_that函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_valid

 def test_valid(self):
     msg = CommandMessage(original_text='.count ham',
                          text='ham',
                          sender='[email protected]/Oklahomer')
     assert_that(hipchat_count(msg, {})) \
         .described_as(".count command increments count") \
         .is_equal_to('1')
开发者ID:oklahomer,项目名称:sarah,代码行数:7,代码来源:test_hipchat_plugin.py


示例2: test_is_close_to_bad_tolerance_arg_type_failure

 def test_is_close_to_bad_tolerance_arg_type_failure(self):
     try:
         d2 = datetime.datetime.today()
         assert_that(self.d1).is_close_to(d2, 123)
         fail('should have raised error')
     except TypeError as ex:
         assert_that(str(ex)).is_equal_to('given tolerance arg must be timedelta, but was <int>')
开发者ID:ramab1988,项目名称:assertpy,代码行数:7,代码来源:test_date.py


示例3: test_is_equal_to_ignoring_milliseconds_failure

 def test_is_equal_to_ignoring_milliseconds_failure(self):
     try:
         d2 = datetime.datetime.today() + datetime.timedelta(days=1)
         assert_that(self.d1).is_equal_to_ignoring_milliseconds(d2)
         fail('should have raised error')
     except AssertionError as ex:
         assert_that(str(ex)).matches('Expected <\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}> to be equal to <\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}>, but was not.')
开发者ID:ramab1988,项目名称:assertpy,代码行数:7,代码来源:test_date.py


示例4: devices_do_not_contain_places

 def devices_do_not_contain_places(self, device_id: str) -> list:
     """ The opposite of `device_and_place_contain_each_other`."""
     device, _ = self.get(self.DEVICES, '', device_id)
     assert_that(device).does_not_contain('place')
     for component_id in device.get('components', []):
         component, _ = self.get(self.DEVICES, '', component_id)
         assert_that(component).does_not_contain('place')
开发者ID:eReuse,项目名称:DeviceHub,代码行数:7,代码来源:__init__.py


示例5: test_is_between_bad_arg2_type_failure

 def test_is_between_bad_arg2_type_failure(self):
     try:
         d2 = datetime.datetime.today()
         assert_that(self.d1).is_between(d2, 123)
         fail('should have raised error')
     except TypeError as ex:
         assert_that(str(ex)).is_equal_to('given high arg must be datetime, but was <int>')
开发者ID:ramab1988,项目名称:assertpy,代码行数:7,代码来源:test_date.py


示例6: test_extracting_dict_missing_key_failure

 def test_extracting_dict_missing_key_failure(self):
     people_as_dicts = [{'first_name': p.first_name, 'last_name': p.last_name} for p in self.people]
     try:
         assert_that(people_as_dicts).extracting('foo')
         fail('should have raised error')
     except ValueError as ex:
         assert_that(str(ex)).matches(r'item keys \[.*\] did not contain key <foo>')
开发者ID:ghostsquad,项目名称:assertpy,代码行数:7,代码来源:test_extracting.py


示例7: test_is_file_directory_failure

 def test_is_file_directory_failure(self):
     try:
         dirname = os.path.dirname(self.tmp.name)
         assert_that(dirname).is_file()
         fail('should have raised error')
     except AssertionError as ex:
         assert_that(str(ex)).matches('Expected <.*> to be a file, but was not.')
开发者ID:ghostsquad,项目名称:assertpy,代码行数:7,代码来源:test_file.py


示例8: test_is_less_than_or_equal_to_failure

 def test_is_less_than_or_equal_to_failure(self):
     try:
         t2 = datetime.timedelta(seconds=90)
         assert_that(t2).is_less_than_or_equal_to(self.t1)
         fail('should have raised error')
     except AssertionError as ex:
         assert_that(str(ex)).matches('Expected <\d{1,2}:\d{2}:\d{2}> to be less than or equal to <\d{1,2}:\d{2}:\d{2}>, but was not.')
开发者ID:ghostsquad,项目名称:assertpy,代码行数:7,代码来源:test_datetime.py


示例9: step_impl

def step_impl(context):
    for row in context.table:
        assert_that(bucket.head_object(row["name"]).status_code
                    ).is_equal_to(404 if row["deleted"] == "1" else 200)

    for row in context.table:
        bucket.delete_object(row["name"])
开发者ID:yunify,项目名称:qsctl,代码行数:7,代码来源:rm.py


示例10: test_expected_exceptions

    def test_expected_exceptions(self):
        def some_func(arg):
            raise RuntimeError('some err')

        assert_that(some_func).raises(RuntimeError).when_called_with('foo')
        assert_that(some_func).raises(RuntimeError).when_called_with('foo')\
            .is_length(8).starts_with('some').is_equal_to('some err')
开发者ID:ghostsquad,项目名称:assertpy,代码行数:7,代码来源:test_readme.py


示例11: test_is_greater_than_failure

 def test_is_greater_than_failure(self):
     try:
         t2 = datetime.timedelta(seconds=90)
         assert_that(self.t1).is_greater_than(t2)
         fail('should have raised error')
     except AssertionError as ex:
         assert_that(str(ex)).matches('Expected <\d{1,2}:\d{2}:\d{2}> to be greater than <\d{1,2}:\d{2}:\d{2}>, but was not.')
开发者ID:ghostsquad,项目名称:assertpy,代码行数:7,代码来源:test_datetime.py


示例12: wait_future_finish

    def wait_future_finish(self, future):
        sleep(.5)  # Why would I need this line?? Check later.

        ret = concurrent.futures.wait([future], 5, return_when=ALL_COMPLETED)
        if len(ret.not_done) > 0:
            logging.error("Jobs are not finished.")
        assert_that(ret.done).contains(future)
开发者ID:gitter-badger,项目名称:sarah,代码行数:7,代码来源:test_hipchat.py


示例13: test__init

    def test__init(self):
        msg = CommandMessage(original_text='.hello',
                             text='',
                             sender='[email protected]/ham')
        response = hipchat_hello(msg, {})

        assert_that(response) \
            .described_as(".hello initiates conversation.") \
            .is_instance_of(UserContext) \
            .has_message("Hello. How are you feeling today?")

        assert_that(response.input_options) \
            .described_as("User has two options to respond.") \
            .is_length(2)

        assert_that([o.next_step.__name__ for o in response.input_options]) \
            .described_as("Those options include 'Good' and 'Bad'") \
            .contains(hipchat_user_feeling_good.__name__,
                      hipchat_user_feeling_bad.__name__)

        assert_that(response.input_options[0].next_step("Good", {})) \
            .described_as("When 'Good,' just return text.") \
            .is_equal_to("Good to hear that.")

        assert_that(response.input_options[1].next_step("Bad", {})) \
            .described_as("When 'Bad,' continue to ask health status") \
            .is_instance_of(UserContext)
开发者ID:oklahomer,项目名称:sarah,代码行数:27,代码来源:test_hipchat_plugin.py


示例14: test_multiple_calls_with_same_word

    def test_multiple_calls_with_same_word(self):
        msg = CommandMessage(original_text='.count ham',
                             text='ham',
                             sender='[email protected]/Oklahomer')
        assert_that(hipchat_count(msg, {})) \
            .described_as("First count returns 1") \
            .is_equal_to('1')

        other_msg = CommandMessage(original_text='.count ham',
                                   text='ham',
                                   sender='[email protected]/Oklahomer')
        assert_that(hipchat_count(other_msg, {})) \
            .described_as("Different counter for different message") \
            .is_equal_to('1')

        assert_that(hipchat_count(msg, {})) \
            .described_as("Same message results in incremented count") \
            .is_equal_to('2')

        reset_msg = CommandMessage(original_text='.reset_count',
                                   text='',
                                   sender='[email protected]/Oklahomer')
        assert_that(hipchat_reset_count(reset_msg, {})) \
            .described_as(".reset_count command resets current count") \
            .is_equal_to("restart counting")

        assert_that(hipchat_count(msg, {})) \
            .described_as("Count restarts") \
            .is_equal_to('1')
开发者ID:oklahomer,项目名称:sarah,代码行数:29,代码来源:test_hipchat_plugin.py


示例15: step_impl

def step_impl(context):
    ok = True
    for row in context.table:
        if row["name"] not in context.output:
            ok = False
            break
    assert_that(ok).is_equal_to(True)
开发者ID:yunify,项目名称:qsctl,代码行数:7,代码来源:ls.py


示例16: step_impl

def step_impl(context):
    resp = bucket.list_objects()
    assert_that(sorted([i["key"] for i in resp["keys"]])
                ).is_equal_to(sorted([row["name"] for row in context.table]))

    for row in context.table:
        bucket.delete_object(row["name"])
开发者ID:yunify,项目名称:qsctl,代码行数:7,代码来源:cp.py


示例17: test_is_not_same_as_failure

def test_is_not_same_as_failure():
    for obj in [object(), 1, 'foo', True, None, 123.456]:
        try:
            assert_that(obj).is_not_same_as(obj)
            fail('should have raised error')
        except AssertionError as ex:
            assert_that(str(ex)).matches('Expected <.+> to be not identical to <.+>, but was.')
开发者ID:ActivisionGameScience,项目名称:assertpy,代码行数:7,代码来源:test_same_as.py


示例18: test_parsing_of_dependency_list_output

    def test_parsing_of_dependency_list_output(self):
        with open(os.path.join(os.path.dirname(__file__), 'mvn_dependency_list_output.txt'), 'r') as output_file:
            output = output_file.read()

        dependencies = self.dependency_list.parse_dependencies(output)

        assert_that(dependencies).is_length(22)
开发者ID:pombredanne,项目名称:ci-tools,代码行数:7,代码来源:test_dependencies.py


示例19: test_is_instance_of

    def test_is_instance_of(self):
        assert_that(self.fred).is_instance_of(Person)
        assert_that(self.fred).is_instance_of(object)

        assert_that(self.joe).is_instance_of(Developer)
        assert_that(self.joe).is_instance_of(Person)
        assert_that(self.joe).is_instance_of(object)
开发者ID:ghostsquad,项目名称:assertpy,代码行数:7,代码来源:test_class.py


示例20: test_expected_exception_all_failure

def test_expected_exception_all_failure():
    try:
        assert_that(func_noop).raises(RuntimeError).when_called_with('a', 'b', 3, 4, foo=1, bar=2, baz='dog')
        fail('should have raised error')
    except AssertionError as ex:
        assert_that(str(ex)).is_equal_to(
            "Expected <func_noop> to raise <RuntimeError> when called with ('a', 'b', 3, 4, 'bar': 2, 'baz': 'dog', 'foo': 1).")
开发者ID:ActivisionGameScience,项目名称:assertpy,代码行数:7,代码来源:test_expected_exception.py



注:本文中的assertpy.assert_that函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python assertpy.fail函数代码示例发布时间:2022-05-24
下一篇:
Python assertions.assert_unavailable函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap