本文整理匯總了Python中recorder.Recorder.verify方法的典型用法代碼示例。如果您正苦於以下問題:Python Recorder.verify方法的具體用法?Python Recorder.verify怎麽用?Python Recorder.verify使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類recorder.Recorder
的用法示例。
在下文中一共展示了Recorder.verify方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TestRecorder
# 需要導入模塊: from recorder import Recorder [as 別名]
# 或者: from recorder.Recorder import verify [as 別名]
#.........這裏部分代碼省略.........
self.make_metadata("""<screenshots>
<screenshot>
<name>foobar</name>
<tile_width>1</tile_width>
<tile_height>2</tile_height>
</screenshot>
</screenshots>""")
self.recorder.record()
im = Image.open(join(self.outputdir, "foobar.png"))
(w, h) = im.size
self.assertEquals(10, w)
self.assertEquals(20, h)
self.assertEquals((0, 0, 255, 255), im.getpixel((1, 1)))
self.assertEquals((255, 0, 0, 255), im.getpixel((1, 11)))
def test_one_row_tiles(self):
self.create_temp_image("foobar.png", (10, 10), "blue")
self.create_temp_image("foobar_1_0.png", (10, 10), "red")
self.make_metadata("""<screenshots>
<screenshot>
<name>foobar</name>
<tile_width>2</tile_width>
<tile_height>1</tile_height>
</screenshot>
</screenshots>""")
self.recorder.record()
im = Image.open(join(self.outputdir, "foobar.png"))
(w, h) = im.size
self.assertEquals(20, w)
self.assertEquals(10, h)
self.assertEquals((0, 0, 255, 255), im.getpixel((1, 1)))
self.assertEquals((255, 0, 0, 255), im.getpixel((11, 1)))
def test_fractional_tiles(self):
self.create_temp_image("foobar.png", (10, 10), "blue")
self.create_temp_image("foobar_1_0.png", (9, 10), "red")
self.create_temp_image("foobar_0_1.png", (10, 8), "red")
self.create_temp_image("foobar_1_1.png", (9, 8), "blue")
self.make_metadata("""<screenshots>
<screenshot>
<name>foobar</name>
<tile_width>2</tile_width>
<tile_height>2</tile_height>
</screenshot>
</screenshots>""")
self.recorder.record()
im = Image.open(join(self.outputdir, "foobar.png"))
(w, h) = im.size
self.assertEquals(19, w)
self.assertEquals(18, h)
self.assertEquals((0, 0, 255, 255), im.getpixel((1, 1)))
self.assertEquals((255, 0, 0, 255), im.getpixel((11, 1)))
self.assertEquals((0, 0, 255, 255), im.getpixel((11, 11)))
self.assertEquals((255, 0, 0, 255), im.getpixel((1, 11)))
def test_verify_success(self):
self.create_temp_image("foobar.png", (10, 10), "blue")
self.make_metadata("""<screenshots>
<screenshot>
<name>foobar</name>
<tile_width>1</tile_width>
<tile_height>1</tile_height>
</screenshot>
</screenshots>""")
self.recorder.record()
self.recorder.verify()
def test_verify_failure(self):
self.create_temp_image("foobar.png", (10, 10), "blue")
self.make_metadata("""<screenshots>
<screenshot>
<name>foobar</name>
<tile_width>1</tile_width>
<tile_height>1</tile_height>
</screenshot>
</screenshots>""")
self.recorder.record()
os.unlink(join(self.inputdir, "foobar.png"))
self.create_temp_image("foobar.png", (10, 10), "red")
try:
self.recorder.verify()
self.fail("expected exception")
except VerifyError:
pass # expected