Exemplo n.º 1
0
 def test_foscam_image_template_input_varieties(self):
     fname = self.data_files['open'][0]
     fcis = [
         FoscamImage(fname, template=None),
         FoscamImage(fname, template=DEFAULT_TEMPLATE),
         FoscamImage(fname,
                     template=GrayscaleTemplateImage(DEFAULT_TEMPLATE)),
         FoscamImage(
             fname,
             template=GrayscaleTemplateImage(DEFAULT_TEMPLATE).image),
     ]
     for fci in fcis:
         self._crudely_verify_grayscale_from_dims(fci.template)
Exemplo n.º 2
0
 def test_no_name_given(self):
     template = GrayscaleTemplateImage(
     )  # no input arg img_name, so using default name
     tshape = template.image.shape
     tlen = len(tshape)
     self.assertEqual(
         2, tlen,
         'NOT GRAYSCALE? expected only 2 dims (h, w) for default template image, but got %d dims %s'
         % (tlen, str(tshape)))
Exemplo n.º 3
0
 def setUpClass(cls):
     """ just do this once [whereas setUp gets called for each test]
     """
     super(TemplateTestCase, cls).setUpClass()
     cwd = os.path.dirname(os.path.abspath(__file__))
     cls.data_dir = cwd.replace(os.path.basename(cwd), 'data')
     cls.unreadable_file = os.path.join(cls.data_dir,
                                        'unreadable_template.jpg')
     cls.default_name = DEFAULT_TEMPLATE
     cls.default_template = GrayscaleTemplateImage(
         img_name=cls.default_name)
Exemplo n.º 4
0
 def test_not_using_keyword_arg(self):
     template = GrayscaleTemplateImage(DEFAULT_TEMPLATE)
     self._verify_grayscale_from_dims(template.image)
Exemplo n.º 5
0
 def test_image_unreadable(self):
     with self.assertRaises(IOError):
         template = GrayscaleTemplateImage(
             img_name=self.unreadable_file)  # bad file content
         tshape = template.image.shape  # need this line for image read method to be invoked
Exemplo n.º 6
0
 def test_name_does_not_exist(self):
     bad_name = '/This/Path/Should/Not/Exist/Junk.jpg'
     with self.assertRaises(TypeError):
         template = GrayscaleTemplateImage(img_name=bad_name)