def test_get_on_dropped(self): f = Interval(interval_metadata=self.im, bounds=[(1, 2)], fuzzy=[(True, False)], metadata={'name': 'sagA'}) f.drop() self.assertEqual(f.fuzzy, [(True, False)]) self.assertEqual(f.bounds, [(1, 2)]) self.assertEqual(f.metadata, {'name': 'sagA'})
def test_repr(self): f = Interval(interval_metadata=self.im, bounds=[(1, 2)], metadata={'name': 'sagA'}) exp = (r"Interval\(interval_metadata=<[0-9]+>, bounds=\[\(1, 2\)\]," " fuzzy=\[\(False, False\)\], metadata={'name': 'sagA'}\)") obs = repr(f) self.assertRegex(obs, exp) # test for dropped f.drop() exp = (r"Interval\(dropped=True, bounds=\[\(1, 2\)\]," " fuzzy=\[\(False, False\)\], metadata={'name': 'sagA'}\)") obs = repr(f) self.assertRegex(obs, exp)
def test_drop(self): f = Interval(interval_metadata=self.im, bounds=[(1, 2)], metadata={'name': 'sagA'}) f.drop() self.assertTrue(f._interval_metadata is None) self.assertTrue(f.dropped) self.assertTrue(f.bounds, [(1, 2)]) self.assertTrue(f.metadata, {'name': 'sagA'}) # test the idempotence f.drop() self.assertTrue(f._interval_metadata is None) self.assertTrue(f.dropped) self.assertTrue(f.bounds, [(1, 2)]) self.assertTrue(f.metadata, {'name': 'sagA'})
def test_set_delete_on_dropped(self): f = Interval(interval_metadata=self.im, bounds=[(1, 2)], fuzzy=[(True, False)], metadata={'name': 'sagA'}) f.drop() with self.assertRaises(RuntimeError): f.fuzzy = None with self.assertRaises(RuntimeError): f.bounds = [(1, 2)] with self.assertRaises(RuntimeError): f.metadata = {} with self.assertRaises(RuntimeError): del f.fuzzy with self.assertRaises(RuntimeError): del f.metadata