def test_dataset_add_delete_field(self):
        """Tests that when fields are added or removed from a dataset field
        schema, those changes are reflected on the samples in the dataset.
        """
        dataset = fo.Dataset()

        sample = fo.Sample(filepath="test1.png")
        dataset.add_sample(sample)

        field_name = "field1"
        ftype = fo.IntField

        # Field not in schema
        with self.assertRaises(AttributeError):
            sample.get_field(field_name)
        with self.assertRaises(KeyError):
            sample[field_name]
        with self.assertRaises(AttributeError):
            getattr(sample, field_name)

        # Field added to dataset
        dataset.add_sample_field(field_name, ftype)
        self.assertIsNone(sample.get_field(field_name))
        self.assertIsNone(sample[field_name])
        self.assertIsNone(getattr(sample, field_name))

        # Field removed from dataset
        dataset.delete_sample_field(field_name)
        with self.assertRaises(AttributeError):
            sample.get_field(field_name)
        with self.assertRaises(KeyError):
            sample[field_name]
        with self.assertRaises(AttributeError):
            getattr(sample, field_name)

        # Field added to dataset and sample value set
        value = 51
        dataset.add_sample_field(field_name, ftype)
        sample[field_name] = value
        self.assertEqual(sample.get_field(field_name), value)
        self.assertEqual(sample[field_name], value)
        self.assertEqual(getattr(sample, field_name), value)

        # Field removed from dataset
        dataset.delete_sample_field(field_name)
        with self.assertRaises(AttributeError):
            sample.get_field(field_name)
        with self.assertRaises(KeyError):
            sample[field_name]
        with self.assertRaises(AttributeError):
            getattr(sample, field_name)
Tests that when fields are added or removed from a dataset field
        schema, those changes are reflected on the samples in the dataset.
        
tests/unittests/synchronization_tests.py