def test_cannot_ignore_error(self): test_journal = [] Logger.add_ignored_code('foo') with self.assertRaises(FooError): Logger.error('foo', 'This foo is bad I have to care') test_journal.append( LogEntry(ERROR, 'bar', 'foo', 'This foo is bad I have to care')) self.assertListEqual(Logger.journal, test_journal)
def test_error(self): test_journal = [] with self.assertRaises(FooError) as cm: Logger.error('foo', 'This foo is bad') self.assertEqual(cm.exception.message, 'This foo is bad') test_journal.append(LogEntry(ERROR, 'bar', 'foo', 'This foo is bad')) self.assertListEqual(Logger.journal, test_journal)
def test_cannot_ignore_error(self): test_journal = [] Logger.add_ignored_code('foo') with self.assertRaises(FooError): Logger.error('foo', 'This foo is bad I have to care') test_journal.append(LogEntry(ERROR, 'bar', 'foo', 'This foo is bad I have to care')) self.assertListEqual(Logger.journal, test_journal)
def test_unknown_codes(self): with self.assertRaises(AssertionError): Logger.warn('does-not-exist', 'Should not exist') with self.assertRaises(AssertionError): Logger.error('does-not-exist', 'Should not exist')
def test_ignore_domain(self): Logger.add_ignored_domain('bar') Logger.warn('baz', 'This baz is bad but I do not care') self.assertListEqual(Logger.journal, []) with self.assertRaises(FooError): Logger.error('foo', 'This foo is bad I need to care')