本文整理汇总了Python中tests.TestUtilities.execute_coala函数的典型用法代码示例。如果您正苦于以下问题:Python execute_coala函数的具体用法?Python execute_coala怎么用?Python execute_coala使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了execute_coala函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_caching_multi_results
def test_caching_multi_results(self):
"""
Integration test to assert that results are not dropped when coala is
ran multiple times with caching enabled and one section yields a result
and second one doesn't.
"""
filename = 'tests/misc/test_caching_multi_results/'
with bear_test_module():
with simulate_console_inputs('0'):
retval, stdout, stderr = execute_coala(
coala.main,
'coala',
'-c', filename + '.coafile',
'-f', filename + 'test.py')
self.assertIn('This file has', stdout)
self.assertIn(
'Implicit \'Default\' section inheritance is deprecated',
stderr)
retval, stdout, stderr = execute_coala(
coala.main,
'coala',
'-c', filename + '.coafile',
'-f', filename + 'test.py')
self.assertIn('This file has', stdout)
self.assertIn('During execution of coala', stderr)
self.assertIn(
'Implicit \'Default\' section inheritance is deprecated',
stderr)
示例2: test_section_ordering
def test_section_ordering(self, debug=False):
with bear_test_module():
with prepare_file(['#include <a>'], None) as (lines, filename):
retval, stdout, stderr = execute_coala(
coala.main, 'coala', 'b', 'a',
'--non-interactive', '-S',
'a.bears=SpaceConsistencyTestBear',
'a.files={}'.format(filename),
'a.use_spaces=True',
'b.bears=SpaceConsistencyTestBear',
'b.files={}'.format(filename),
'b.use_spaces=True',
'-c', os.devnull,
debug=debug)
stdout_list = stdout.splitlines(True)
self.assertEqual('Executing section b...\n', stdout_list[0])
self.assertEqual('Executing section a...\n', stdout_list[1])
retval, stdout, stderr = execute_coala(
coala.main, 'coala', 'a', 'b',
'--non-interactive', '-S',
'a.bears=SpaceConsistencyTestBear',
'a.files={}'.format(filename),
'a.use_spaces=True',
'b.bears=SpaceConsistencyTestBear',
'b.files={}'.format(filename),
'b.use_spaces=True',
'-c', os.devnull,
debug=debug)
stdout_list = stdout.splitlines(True)
self.assertEqual('Executing section a...\n', stdout_list[0])
self.assertEqual('Executing section b...\n', stdout_list[1])
示例3: test_caching_multi_results
def test_caching_multi_results(self):
"""
Integration test to assert that results are not dropped when coala is
ran multiple times with caching enabled and one section yields a result
and second one doesn't.
"""
filename = 'tests/misc/test_caching_multi_results/'
with bear_test_module():
with simulate_console_inputs('n'):
retval, stdout, stderr = execute_coala(
coala.main,
'coala',
'-c', filename + '.coafile',
'-f', filename + 'test.py')
self.assertIn('This file has', stdout)
self.assertIn(
'Implicit \'Default\' section inheritance is deprecated',
stderr)
retval, stdout, stderr = execute_coala(
coala.main,
'coala',
'--non-interactive', '--no-color',
'-c', filename + '.coafile',
'-f', filename + 'test.py')
self.assertIn('This file has', stdout)
self.assertEqual(2, len(stderr.splitlines()))
self.assertIn(
'LineCountTestBear: This result has no patch attached.',
stderr)
self.assertIn(
'Implicit \'Default\' section inheritance is deprecated',
stderr)
示例4: test_did_nothing
def test_did_nothing(self):
retval, output = execute_coala(coala.main, 'coala', '-I',
'-S', 'default.enabled=false')
self.assertEqual(retval, 2)
self.assertIn('Did you forget to give the `--files`', output)
retval, output = execute_coala(coala.main, 'coala', '-I',
'-b', 'JavaTestBear', '-f', '*.java',
'-S', 'default.enabled=false')
self.assertEqual(retval, 2)
self.assertIn('Nothing to do.', output)
示例5: test_coala_main_bear_run_raises
def test_coala_main_bear_run_raises(self):
with bear_test_module(), \
prepare_file(['#fixme '], None) as (lines, filename), \
self.assertRaisesRegex(
RuntimeError, r"^That's all the RaiseTestBear can do\.$"):
execute_coala(
coala.main, 'coala',
'-c', os.devnull,
'-f', filename,
'-b', 'RaiseTestBear',
debug=True)
示例6: test_coala_delete_orig
def test_coala_delete_orig(self):
with TemporaryDirectory() as tempdir,\
NamedTemporaryFile(suffix='.orig',
dir=tempdir,
delete=False) as orig_file,\
make_temp(suffix='.coafile', prefix='', dir=tempdir) as coafile,\
make_temp(dir=tempdir) as unrelated_file:
orig_file.close()
execute_coala(coala_ci.main, "coala-ci",
"-c", re.escape(coafile))
self.assertFalse(os.path.isfile(orig_file.name))
self.assertTrue(os.path.isfile(unrelated_file))
示例7: test_coala_main_bear__init__raises
def test_coala_main_bear__init__raises(self):
with bear_test_module(), \
prepare_file(['#fixme '], None) as (lines, filename), \
self.assertRaisesRegex(
RuntimeError,
r'^The bear ErrorTestBear does not fulfill all '
r"requirements\. 'I_do_not_exist' is not installed\.$"):
execute_coala(
coala.main, 'coala',
'-c', os.devnull,
'-f', filename,
'-b', 'ErrorTestBear',
debug=True)
示例8: test_coala_main_mode_json_raises
def test_coala_main_mode_json_raises(self, mocked_mode_json):
mocked_mode_json.side_effect = RuntimeError('Mocked mode_json fails.')
with bear_test_module(), \
prepare_file(['#fixme '], None) as (lines, filename), \
self.assertRaisesRegex(RuntimeError,
r'^Mocked mode_json fails\.$'):
# additionally use RaiseTestBear to verify independency from
# failing bears
execute_coala(
coala.main, 'coala', '--json',
'-c', os.devnull,
'-f', filename,
'-b', 'RaiseTestBear',
debug=True)
示例9: test_caching_results
def test_caching_results(self):
"""
A simple integration test to assert that results are not dropped
when coala is ran multiple times with caching enabled.
"""
with bear_test_module():
with prepare_file(['a=(5,6)'], None) as (lines, filename):
with simulate_console_inputs('n'):
retval, stdout, stderr = execute_coala(
coala.main,
'coala',
'-c', os.devnull,
'--disable-caching',
'--flush-cache',
'-f', filename,
'-b', 'LineCountTestBear',
'-L', 'DEBUG')
self.assertIn('This file has', stdout)
self.assertIn('Running bear LineCountTestBear', stderr)
# Due to the change in configuration from the removal of
# ``--flush-cache`` this run will not be sufficient to
# assert this behavior.
retval, stdout, stderr = execute_coala(
coala.main,
'coala',
'--non-interactive', '--no-color',
'-c', os.devnull,
'-f', filename,
'-b', 'LineCountTestBear')
self.assertIn('This file has', stdout)
self.assertEqual(1, len(stderr.splitlines()))
self.assertIn(
'LineCountTestBear: This result has no patch attached.',
stderr)
retval, stdout, stderr = execute_coala(
coala.main,
'coala',
'--non-interactive', '--no-color',
'-c', os.devnull,
'-f', filename,
'-b', 'LineCountTestBear')
self.assertIn('This file has', stdout)
self.assertEqual(1, len(stderr.splitlines()))
self.assertIn(
'LineCountTestBear: This result has no patch attached.',
stderr)
示例10: test_nonexistent
def test_nonexistent(self):
retval, stdout, stderr = execute_coala(
coala.main, 'coala', '--non-interactive', '-c', 'nonex', 'test')
self.assertFalse(stdout)
self.assertRegex(
stderr,
".*\\[ERROR\\].*The requested coafile '.*' does not exist. .+\n")
示例11: test_version_conflict_in_collecting_bears
def test_version_conflict_in_collecting_bears(self, import_fn, _):
with bear_test_module():
import_fn.side_effect = VersionConflict("msg1", "msg2")
retval, output = execute_coala(coala.main, "coala", "-B")
self.assertEqual(retval, 13)
self.assertIn(("There is a conflict in the version of a " "dependency you have installed"), output)
self.assertIn("pip install msg2", output) # Check recommendation
示例12: test_filter_by_language_c
def test_filter_by_language_c(self):
with bear_test_module():
retval, stdout, stderr = execute_coala(
coala.main, 'coala', '-B', '--filter-by', 'language', 'c')
self.assertEqual(retval, 0)
self.assertEqual(len(stdout.strip().splitlines()),
C_BEARS_COUNT_OUTPUT)
示例13: test_show_language_bears
def test_show_language_bears(self):
with bear_test_module():
retval, output = execute_coala(
coala_json.main, 'coala-json', '-B', '-l', 'java')
self.assertEqual(retval, 0)
output = json.loads(output)
self.assertEqual(len(output["bears"]), 2)
示例14: test_nonexistent
def test_nonexistent(self):
retval, output = execute_coala(
coala_json.main, "coala-json", "-c", 'nonex', "test")
output = json.loads(output)
self.assertRegex(
output["logs"][0]["message"],
"The requested coafile '.*' does not exist. .+")
示例15: test_fail_acquire_settings
def test_fail_acquire_settings(self):
with bear_test_module():
retval, output = execute_coala(coala.main, 'coala',
'--non-interactive',
'-b', 'SpaceConsistencyTestBear',
'-c', os.devnull)
self.assertIn('During execution, we found that some', output)