当前位置: 首页>>代码示例>>Python>>正文


Python Mock.crop方法代码示例

本文整理汇总了Python中unittest.mock.Mock.crop方法的典型用法代码示例。如果您正苦于以下问题:Python Mock.crop方法的具体用法?Python Mock.crop怎么用?Python Mock.crop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在unittest.mock.Mock的用法示例。


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

示例1: test_get_thumbnail

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import crop [as 别名]
def test_get_thumbnail():
    instance = Mock()
    cropped_value = Mock(url="crop.jpg")
    thumbnail_value = Mock(url="thumb.jpg")
    instance.crop = {"10x10": cropped_value}
    instance.thumbnail = {"10x10": thumbnail_value}
    cropped = get_thumbnail(instance, 10, method="crop")
    assert cropped == cropped_value.url
    thumb = get_thumbnail(instance, 10, method="thumbnail")
    assert thumb == thumbnail_value.url
开发者ID:mirumee,项目名称:saleor,代码行数:12,代码来源:test_product_tags.py

示例2: test_get_thumbnail_no_match_by_method

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import crop [as 别名]
def test_get_thumbnail_no_match_by_method():
    instance = Mock()
    cropped_value = Mock(url='crop.jpg')
    instance.crop = {'1000x1000': cropped_value}
    with pytest.warns(UserWarning) as record:
        cropped = get_thumbnail(instance, 800, method='crop')

    assert len(record) == 1
    assert str(record[0].message) == \
        'Thumbnail size crop__800x800 is not defined in settings' \
        ' and it won\'t be generated automatically'
    assert cropped == static('images/placeholder1080x1080.png')
开发者ID:krzysztofwolski,项目名称:saleor,代码行数:14,代码来源:test_product_tags.py

示例3: test_get_thumbnail_no_match_by_method

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import crop [as 别名]
def test_get_thumbnail_no_match_by_method():
    instance = Mock()
    cropped_value = Mock(url="crop.jpg")
    instance.crop = {"1000x1000": cropped_value}
    with pytest.warns(UserWarning) as record:
        cropped = get_thumbnail(instance, 800, method="crop")

    assert len(record) == 1
    assert (
        str(record[0].message)
        == "Thumbnail size crop__800x800 is not defined in settings"
        " and it won't be generated automatically"
    )
    assert cropped == static("images/placeholder1080x1080.png")
开发者ID:mirumee,项目名称:saleor,代码行数:16,代码来源:test_product_tags.py

示例4: test_get_thumbnail_to_smaller

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import crop [as 别名]
def test_get_thumbnail_to_smaller():
    instance = Mock()
    cropped_value = Mock(url="crop.jpg")
    instance.crop = {"100x100": cropped_value}
    cropped = get_thumbnail(instance, 400, method="crop")
    assert cropped == cropped_value.url
开发者ID:mirumee,项目名称:saleor,代码行数:8,代码来源:test_product_tags.py

示例5: test_get_thumbnail_no_match_by_method

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import crop [as 别名]
def test_get_thumbnail_no_match_by_method():
    instance = Mock()
    cropped_value = Mock(url='crop.jpg')
    instance.crop = {'1000x1000': cropped_value}
    cropped = get_thumbnail(instance, 800, method='crop')
    assert cropped == static('images/placeholder1080x1080.png')
开发者ID:elwoodxblues,项目名称:saleor,代码行数:8,代码来源:test_product_tags.py


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