class LazyConfigTest(unittest.TestCase): """ Coverage of LazyConfig """ def setUp(self): self.configMocker = ConfigMock() self.config = LazyConfig() def tearDown(self): self.configMocker.finish() def test_laziness(self): """ Do I acquire a config object upon access? """ self.assertFalse('_realConfig' in self.config.__dict__, "oops, test config has _realConfig prematurely") self.config.apparentURL self.assertTrue('_realConfig' in self.config.__dict__, "oops, test config should have _realConfig now but doesn't") def test_attributeAccess(self): """ Try out the attribute proxying properties """ self.assertFalse('_realConfig' in self.config.__dict__, "oops, test config has _realConfig prematurely") self.assertRaises(TypeError, setattr, self.config, 'uninitialized', 20) self.assertEqual(self.config.apparentURL, 'https://app.nomsbook.com') self.config.apparentURL = 'dfgkljdhf' self.assertEqual(self.config.apparentURL, 'dfgkljdhf')
def setUp(self): self.configMocker = ConfigMock() self.config = LazyConfig()