def test_log_inexistent_key(self): KEY = 'this.key.cannot.exist' sample = {} vm = FakeVM() log = FakeLogger() with MonkeyPatchScope([(vmstats, '_log', log)]): with vmstats._skip_if_missing_stats(vm): sample[KEY] self.assertEqual(len(log.messages), 1) self.assertEqual(log.messages[0][0], logging.WARNING) self.assertIn(KEY, log.messages[0][1])
def test_log_inexistent_key(self): KEY = 'this.key.cannot.exist' sample = {} vm = FakeVM() log = FakeLogger() with MonkeyPatchScope([(vmstats, '_log', log)]): with vmstats._skip_if_missing_stats(vm): sample[KEY] assert len(log.messages) == 1 assert log.messages[0][0] == logging.WARNING assert KEY in log.messages[0][1]