Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_locateAll_filename(self):
self.assertEqual(((94, 94, 4, 4),), tuple(pyscreeze.locateAll('slash.png', 'haystack1.png')))
self.assertEqual(((93, 93, 4, 4), (94, 94, 4, 4), (95, 95, 4, 4)), tuple(pyscreeze.locateAll('slash.png', 'haystack2.png')))
self.assertEqual(((94, 94, 4, 4),), tuple(pyscreeze.locateAll('slash.png', 'haystack1.png', grayscale=True)))
self.assertEqual(((93, 93, 4, 4), (94, 94, 4, 4), (95, 95, 4, 4)), tuple(pyscreeze.locateAll('slash.png', 'haystack2.png', grayscale=True)))
self.assertEqual((), tuple(pyscreeze.locateAll('slash.png', 'colornoise.png')))
self.assertEqual((), tuple(pyscreeze.locateAll('slash.png', 'colornoise.png', grayscale=True)))
imageWidth, imageHeight = largeNoiseIm.size
needle10x10 = largeNoiseIm.crop((imageWidth - 10, imageHeight - 10, imageWidth, imageHeight))
needle100x100 = largeNoiseIm.crop((imageWidth - 100, imageHeight - 100, imageWidth, imageHeight))
needle500x500 = largeNoiseIm.crop((imageWidth - 500, imageHeight - 500, imageWidth, imageHeight))
profiler = cProfile.Profile()
profiler.enable()
list(pyscreeze.locateAll(needle10x10, largeNoiseIm))
profiler.disable()
print('10x10 needle:')
pstats.Stats(profiler).sort_stats('cumulative').print_stats(1)
profiler = cProfile.Profile()
profiler.enable()
list(pyscreeze.locateAll(needle100x100, largeNoiseIm))
profiler.disable()
print('100x100 needle:')
pstats.Stats(profiler).sort_stats('cumulative').print_stats(1)
profiler = cProfile.Profile()
profiler.enable()
list(pyscreeze.locateAll(needle500x500, largeNoiseIm))
profiler.disable()
print('500x500 needle:')
pstats.Stats(profiler).sort_stats('cumulative').print_stats(1)
def test_locateAll_filename(self):
self.assertEqual(((94, 94, 4, 4),), tuple(pyscreeze.locateAll('slash.png', 'haystack1.png')))
self.assertEqual(((93, 93, 4, 4), (94, 94, 4, 4), (95, 95, 4, 4)), tuple(pyscreeze.locateAll('slash.png', 'haystack2.png')))
self.assertEqual(((94, 94, 4, 4),), tuple(pyscreeze.locateAll('slash.png', 'haystack1.png', grayscale=True)))
self.assertEqual(((93, 93, 4, 4), (94, 94, 4, 4), (95, 95, 4, 4)), tuple(pyscreeze.locateAll('slash.png', 'haystack2.png', grayscale=True)))
self.assertEqual((), tuple(pyscreeze.locateAll('slash.png', 'colornoise.png')))
self.assertEqual((), tuple(pyscreeze.locateAll('slash.png', 'colornoise.png', grayscale=True)))
slashFp = open('slash.png' ,'rb')
haystack1Fp = open('haystack1.png' ,'rb')
haystack2Fp = open('haystack2.png' ,'rb')
colorNoiseFp = open('colornoise.png' ,'rb')
slashIm = Image.open(slashFp)
haystack1Im = Image.open(haystack1Fp)
haystack2Im = Image.open(haystack2Fp)
colorNoiseIm = Image.open(colorNoiseFp)
self.assertEqual(((94, 94, 4, 4),), tuple(pyscreeze.locateAll(slashIm, haystack1Im)))
self.assertEqual(((93, 93, 4, 4), (94, 94, 4, 4), (95, 95, 4, 4)), tuple(pyscreeze.locateAll(slashIm, haystack2Im)))
self.assertEqual(((94, 94, 4, 4),), tuple(pyscreeze.locateAll(slashIm, haystack1Im, grayscale=True)))
self.assertEqual(((93, 93, 4, 4), (94, 94, 4, 4), (95, 95, 4, 4)), tuple(pyscreeze.locateAll(slashIm, haystack2Im, grayscale=True)))
self.assertEqual((), tuple(pyscreeze.locateAll(slashIm, colorNoiseIm)))
self.assertEqual((), tuple(pyscreeze.locateAll(slashIm, colorNoiseIm, grayscale=True)))
slashFp.close()
haystack1Fp.close()
haystack2Fp.close()
colorNoiseFp.close()
def test_locateAll_filename(self):
self.assertEqual(((94, 94, 4, 4),), tuple(pyscreeze.locateAll('slash.png', 'haystack1.png')))
self.assertEqual(((93, 93, 4, 4), (94, 94, 4, 4), (95, 95, 4, 4)), tuple(pyscreeze.locateAll('slash.png', 'haystack2.png')))
self.assertEqual(((94, 94, 4, 4),), tuple(pyscreeze.locateAll('slash.png', 'haystack1.png', grayscale=True)))
self.assertEqual(((93, 93, 4, 4), (94, 94, 4, 4), (95, 95, 4, 4)), tuple(pyscreeze.locateAll('slash.png', 'haystack2.png', grayscale=True)))
self.assertEqual((), tuple(pyscreeze.locateAll('slash.png', 'colornoise.png')))
self.assertEqual((), tuple(pyscreeze.locateAll('slash.png', 'colornoise.png', grayscale=True)))
haystack1Fp = open('haystack1.png' ,'rb')
haystack2Fp = open('haystack2.png' ,'rb')
colorNoiseFp = open('colornoise.png' ,'rb')
slashIm = Image.open(slashFp)
haystack1Im = Image.open(haystack1Fp)
haystack2Im = Image.open(haystack2Fp)
colorNoiseIm = Image.open(colorNoiseFp)
self.assertEqual(((94, 94, 4, 4),), tuple(pyscreeze.locateAll(slashIm, haystack1Im)))
self.assertEqual(((93, 93, 4, 4), (94, 94, 4, 4), (95, 95, 4, 4)), tuple(pyscreeze.locateAll(slashIm, haystack2Im)))
self.assertEqual(((94, 94, 4, 4),), tuple(pyscreeze.locateAll(slashIm, haystack1Im, grayscale=True)))
self.assertEqual(((93, 93, 4, 4), (94, 94, 4, 4), (95, 95, 4, 4)), tuple(pyscreeze.locateAll(slashIm, haystack2Im, grayscale=True)))
self.assertEqual((), tuple(pyscreeze.locateAll(slashIm, colorNoiseIm)))
self.assertEqual((), tuple(pyscreeze.locateAll(slashIm, colorNoiseIm, grayscale=True)))
slashFp.close()
haystack1Fp.close()
haystack2Fp.close()
colorNoiseFp.close()
def locateAll(*args, **kwargs):
return pyscreeze.locateAll(*args, **kwargs)
def _locateAll(*args, **kwargs):
return pyscreeze.locateAll(*args, **kwargs)