def test_nonworking(self): def bad_execute(args, **kwargs): raise ValueError() with mock.patch('bfg9000.shell.which', mock_which), \ mock.patch('bfg9000.shell.execute', bad_execute): # noqa msg = "^no working c compiler found; tried 'cc'$" with self.assertRaisesRegex(IOError, msg): common.choose_builder(self.env, known_langs['c'], 'cc', (cc.CcBuilder, ))
def test_choose(self): with mock.patch('bfg9000.shell.which', mock_which), \ mock.patch('bfg9000.shell.execute', mock_execute): # noqa builder = common.choose_builder(self.env, known_langs['c'], (cc.CcBuilder, ), candidates='cc') self.assertEqual(builder.brand, 'gcc')
def test_not_found(self): def bad_which(*args, **kwargs): if args[0] == ['cc']: raise IOError('badness') else: return mock_which(*args, **kwargs) with mock.patch('bfg9000.shell.which', bad_which), \ mock.patch('bfg9000.shell.execute', mock_execute), \ mock.patch('warnings.warn', lambda s: None): # noqa builder = common.choose_builder(self.env, known_langs['c'], 'cc', (cc.CcBuilder, )) self.assertEqual(builder.brand, 'unknown')