本文整理汇总了Python中photologue.models.Photo.get_testPhotoSize_size方法的典型用法代码示例。如果您正苦于以下问题:Python Photo.get_testPhotoSize_size方法的具体用法?Python Photo.get_testPhotoSize_size怎么用?Python Photo.get_testPhotoSize_size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类photologue.models.Photo
的用法示例。
在下文中一共展示了Photo.get_testPhotoSize_size方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ImageResizeTest
# 需要导入模块: from photologue.models import Photo [as 别名]
# 或者: from photologue.models.Photo import get_testPhotoSize_size [as 别名]
class ImageResizeTest(PhotologueBaseTest):
def setUp(self):
super(ImageResizeTest, self).setUp()
self.pp = Photo(title='portrait',
title_slug='portrait'
)
self.pp.image.save(os.path.basename(PORTRAIT_IMAGE_PATH),
ContentFile(open(PORTRAIT_IMAGE_PATH, 'rb').read()))
self.pp.save()
self.ps = Photo(title='square',
title_slug='square',
)
self.ps.image.save(os.path.basename(SQUARE_IMAGE_PATH),
ContentFile(open(SQUARE_IMAGE_PATH, 'rb').read()))
self.ps.save()
def tearDown(self):
super(ImageResizeTest, self).tearDown()
self.pp.delete()
self.ps.delete()
def test_resize_to_fit(self):
self.assertEqual(self.pl.get_testPhotoSize_size(), (100, 75))
self.assertEqual(self.pp.get_testPhotoSize_size(), (75, 100))
self.assertEqual(self.ps.get_testPhotoSize_size(), (100, 100))
def test_resize_to_fit_width(self):
self.s.size = (100, 0)
self.s.save()
self.assertEqual(self.pl.get_testPhotoSize_size(), (100, 75))
self.assertEqual(self.pp.get_testPhotoSize_size(), (100, 133))
self.assertEqual(self.ps.get_testPhotoSize_size(), (100, 100))
def test_resize_to_fit_width_enlarge(self):
self.s.size = (400, 0)
self.s.upscale = True
self.s.save()
self.assertEqual(self.pl.get_testPhotoSize_size(), (400, 300))
self.assertEqual(self.pp.get_testPhotoSize_size(), (400, 533))
self.assertEqual(self.ps.get_testPhotoSize_size(), (400, 400))
def test_resize_to_fit_height(self):
self.s.size = (0, 100)
self.s.save()
self.assertEqual(self.pl.get_testPhotoSize_size(), (133, 100))
self.assertEqual(self.pp.get_testPhotoSize_size(), (75, 100))
self.assertEqual(self.ps.get_testPhotoSize_size(), (100, 100))
def test_resize_to_fit_height_enlarge(self):
self.s.size = (0, 400)
self.s.upscale = True
self.s.save()
self.assertEqual(self.pl.get_testPhotoSize_size(), (533, 400))
self.assertEqual(self.pp.get_testPhotoSize_size(), (300, 400))
self.assertEqual(self.ps.get_testPhotoSize_size(), (400, 400))
def test_resize_and_crop(self):
self.s.crop = True
self.s.save()
self.assertEqual(self.pl.get_testPhotoSize_size(), self.s.size)
self.assertEqual(self.pp.get_testPhotoSize_size(), self.s.size)
self.assertEqual(self.ps.get_testPhotoSize_size(), self.s.size)
def test_resize_rounding_to_fit(self):
self.s.size = (113, 113)
self.s.save()
self.assertEqual(self.pl.get_testPhotoSize_size(), (113, 85))
self.assertEqual(self.pp.get_testPhotoSize_size(), (85, 113))
self.assertEqual(self.ps.get_testPhotoSize_size(), (113, 113))
def test_resize_rounding_cropped(self):
self.s.size = (113, 113)
self.s.crop = True
self.s.save()
self.assertEqual(self.pl.get_testPhotoSize_size(), self.s.size)
self.assertEqual(self.pp.get_testPhotoSize_size(), self.s.size)
self.assertEqual(self.ps.get_testPhotoSize_size(), self.s.size)
def test_resize_one_dimension_width(self):
self.s.size = (100, 150)
self.s.save()
self.assertEqual(self.pl.get_testPhotoSize_size(), (100, 75))
def test_resize_one_dimension_height(self):
self.s.size = (200, 75)
self.s.save()
self.assertEqual(self.pl.get_testPhotoSize_size(), (100, 75))
def test_resize_no_upscale(self):
self.s.size = (1000, 1000)
self.s.save()
self.assertEqual(self.pl.get_testPhotoSize_size(), (200, 150))
def test_resize_no_upscale_mixed_height(self):
self.s.size = (400, 75)
self.s.save()
self.assertEqual(self.pl.get_testPhotoSize_size(), (100, 75))
def test_resize_no_upscale_mixed_width(self):
self.s.size = (100, 300)
#.........这里部分代码省略.........