Example #1
0
 def test_regions(self):
     sample = decaptcha.monochrome(self.captcha.channel(220, 227))
     regions = decaptcha.regions(sample, threshold=1)
     self.assertTrue(
         regions == EXPECTED_REGIONS,
         "Expected regions %s, instead got %s" %
         (EXPECTED_REGIONS, regions))
Example #2
0
 def test_guess_character(self):
     sample = decaptcha.monochrome(self.captcha.channel(220, 227))
     regions = decaptcha.regions(sample)
     segment = self.captcha.segment(sample, regions[0], crop=False)
     exp_seg = Image.open(TEST_SEGMENT_IMG(1))
     self.assertTrue(segment.histogram() == exp_seg.histogram(),
                     "Segment is wrong")
     predictions = self.captcha.guess_character(segment)
     self.assertTrue(
         predictions[0] == EXPECTED_OUTPUT,
         "Expected %s, got %s" % (EXPECTED_OUTPUT, predictions[0]))
Example #3
0
 def test_guess_character(self):
     sample = decaptcha.monochrome(self.captcha.channel(220, 227))
     regions = decaptcha.regions(sample)
     segment = self.captcha.segment(sample, regions[0], crop=False)
     exp_seg = Image.open(TEST_SEGMENT_IMG(1))
     self.assertTrue(segment.histogram() == exp_seg.histogram(),
                     "Segment is wrong")
     predictions = self.captcha.guess_character(segment)
     self.assertTrue(predictions[0] == EXPECTED_OUTPUT,
                     "Expected %s, got %s" %
                     (EXPECTED_OUTPUT, predictions[0]))
Example #4
0
 def test_regions(self):
     sample = decaptcha.monochrome(self.captcha.channel(220, 227))
     regions = decaptcha.regions(sample, threshold=1)
     self.assertTrue(regions == EXPECTED_REGIONS,
                     "Expected regions %s, instead got %s"
                     % (EXPECTED_REGIONS, regions))