def test_debug(self): with mock.patch('logging.addLevelName'), \ mock.patch('logging.root.addHandler'), \ mock.patch('colorama.init'): # noqa with mock.patch('logging.root.setLevel') as setLevel: log.init() setLevel.assert_called_once_with(log.INFO) with mock.patch('logging.root.setLevel') as setLevel: log.init(debug=True) setLevel.assert_called_once_with(log.DEBUG)
def test_warn_once(self): with mock.patch('logging.addLevelName'), \ mock.patch('logging.root.addHandler'), \ mock.patch('logging.root.setLevel'), \ mock.patch('colorama.init'): # noqa with mock.patch('warnings.filterwarnings') as filterwarnings: log.init() filterwarnings.assert_called_once_with( 'default', category=log.UserDeprecationWarning) with mock.patch('warnings.filterwarnings') as filterwarnings: log.init(warn_once=True) self.assertEqual(filterwarnings.mock_calls, [ mock.call('default', category=log.UserDeprecationWarning), mock.call('once') ])
def test_colors(self): with mock.patch('logging.addLevelName'), \ mock.patch('logging.root.addHandler'), \ mock.patch('logging.root.setLevel'): # noqa with mock.patch('colorama.init') as colorama: log.init() colorama.assert_called_once_with() with mock.patch('colorama.init') as colorama: log.init(color='always') colorama.assert_called_once_with(strip=False) with mock.patch('colorama.init') as colorama: log.init(color='never') colorama.assert_called_once_with(strip=True, convert=False)
def setUp(self): self.stream = StringIO() log.init(stream=self.stream)