def test_ts_image_clone(self): """Test TimeStreamImage.clone()""" img = TimeStreamImage() img.path = helpers.FILES["zeros_jpg"] cpy = img.clone() self.assertIsNot(cpy, img) self.assertIsNot(cpy.datetime, img.datetime) self.assertIsNot(cpy.data, img.data) self.assertEqual(cpy.data, img.data) self.assertIs(cpy._pixels, None) self.assertIs(cpy._timestream, None) self.assertIs(cpy._path, None)
def test_ts_image_clone_all(self): """Test TimeStreamImage.clone(), cloning all members""" ts = TimeStream() img = TimeStreamImage() img.parent_timestream = ts img.path = helpers.FILES["zeros_jpg"] cpy = img.clone(True, True, True) self.assertIsNot(cpy, img) self.assertIsNot(cpy.datetime, img.datetime) self.assertEqual(cpy.datetime, img.datetime) self.assertIsNot(cpy.data, img.data) self.assertEqual(cpy.data, img.data) self.assertIsNot(cpy.pixels, img.pixels) np.testing.assert_array_equal(cpy.pixels, img.pixels) # TS should be copied as a refernce, hence *Is*, not Is Not self.assertIs(cpy.parent_timestream, img.parent_timestream) self.assertEqual(cpy.parent_timestream, img.parent_timestream) # Strings are cached, so no assertIsNot for path self.assertEqual(cpy.path, img.path)