try: # python 2.x import unittest2 as unittest except ImportError: # python 3.x import unittest import funcsigs class TestFormatAnnotation(unittest.TestCase): def test_string(self): self.assertEqual(funcsigs.formatannotation("annotation"), "'annotation'") def test_builtin_type(self): self.assertEqual(funcsigs.formatannotation(int), "int") def test_user_type(self): class dummy(object): pass self.assertEqual(funcsigs.formatannotation(dummy), "tests.test_formatannotation.dummy") if __name__ == "__main__": unittest.begin()
self.logs.run(self.opts) getlogger.return_value.removeHandler.assert_called_once_with(Ellipsis) @mock.patch('logging.open', mock.mock_open(), create=True) @mock.patch('platform.system') @mock.patch('logging.getLogger') def test_run_logfile_linux(self, getlogger, system): system.return_value = 'Linux' self.opts.logfile = '/dev/null' self.logs.run(self.opts) logger = getlogger.return_value self.assertTrue(logger.addHandler.called) self.assertIsInstance(logger.addHandler.call_args[0][0], logging.handlers.WatchedFileHandler) @mock.patch('logging.open', mock.mock_open(), create=True) @mock.patch('platform.system') @mock.patch('logging.getLogger') def test_run_logfile_windows(self, getlogger, system): system.return_value = 'Windows' self.opts.logfile = '/dev/null' self.logs.run(self.opts) logger = getlogger.return_value self.assertTrue(logger.addHandler.called) self.assertIsInstance(logger.addHandler.call_args[0][0], logging.FileHandler) if __name__ == '__main__': unittest.begin()