def setUp(self): self.lenient = Lenient()
def test_kwargs_invalid(self): emsg = "Invalid .* option, got 'merge'." with self.assertRaisesRegex(KeyError, emsg): _ = Lenient(merge=True)
def test_default(self): lenient = Lenient() expected = dict(maths=True) self.assertEqual(expected, lenient.__dict__)
def test_kwargs(self): lenient = Lenient(maths=False) expected = dict(maths=False) self.assertEqual(expected, lenient.__dict__)
class Test_context(tests.IrisTest): def setUp(self): self.lenient = Lenient() def test_nop(self): self.assertTrue(self.lenient["maths"]) with self.lenient.context(): self.assertTrue(self.lenient["maths"]) self.assertTrue(self.lenient["maths"]) def test_maths_disable__lenient_true(self): # synchronised self.assertTrue(_LENIENT.enable) self.assertTrue(self.lenient["maths"]) with self.lenient.context(maths=False): # still synchronised self.assertFalse(_LENIENT.enable) self.assertFalse(self.lenient["maths"]) # still synchronised self.assertTrue(_LENIENT.enable) self.assertTrue(self.lenient["maths"]) def test_maths_disable__lenient_false(self): # not synchronised _LENIENT.__dict__["enable"] = False self.assertFalse(_LENIENT.enable) self.assertTrue(self.lenient["maths"]) with self.lenient.context(maths=False): # now synchronised self.assertFalse(_LENIENT.enable) self.assertFalse(self.lenient["maths"]) # still synchronised self.assertTrue(_LENIENT.enable) self.assertTrue(self.lenient["maths"]) def test_maths_enable__lenient_true(self): # not synchronised self.assertTrue(_LENIENT.enable) self.lenient.__dict__["maths"] = False self.assertFalse(self.lenient["maths"]) with self.lenient.context(maths=True): # now synchronised self.assertTrue(_LENIENT.enable) self.assertTrue(self.lenient["maths"]) # still synchronised self.assertFalse(_LENIENT.enable) self.assertFalse(self.lenient["maths"]) def test_maths_enable__lenient_false(self): # synchronised _LENIENT.__dict__["enable"] = False self.assertFalse(_LENIENT.enable) self.lenient.__dict__["maths"] = False self.assertFalse(self.lenient["maths"]) with self.lenient.context(maths=True): # still synchronised self.assertTrue(_LENIENT.enable) self.assertTrue(self.lenient["maths"]) # still synchronised self.assertFalse(_LENIENT.enable) self.assertFalse(self.lenient["maths"])