Ejemplo n.º 1
0
 def test_seting_proportions_validates_them(self):
     some_proportions = (0, .1, .2, .3)
     other_proportions = (.4, .5, .6, .7)
     pr = ProportionalRegion(some_proportions)
     with patch.object(visuals, '_validate_proportions') as m_validate:
         pr.proportions = other_proportions
     self.assertIsNone(m_validate.assert_called_with(other_proportions))
Ejemplo n.º 2
0
 def test_region_in_returns_correct_borders(self):
     # create an image to work with
     h, w = 100, 200
     image = _generic_image(height=h, width=w)
     # specify the correct values for a given proportion set
     top_proportion, left_proportion, bottom_proportion, right_proportion =\
         proportions =\
         _generic_proportions()
     top_spec = int(round(h * top_proportion))
     left_spec = int(round(w * left_proportion))
     bottom_spec = int(round(h * bottom_proportion))
     right_spec = int(round(w * right_proportion))
     border_pixels_spec = top_spec, left_spec, bottom_spec, right_spec
     # confirm the calculation
     pr = ProportionalRegion(proportions)
     border_pixels = pr.region_in(image)
     self.assertEqual(border_pixels, border_pixels_spec)