def test_process_files_with_plugin_list(self): self.tool.options['plugins'] = ['flake8-django', 'flake8-isort'] self.tool.process_files([self.fixtures[1]]) problems = self.problems.all(self.fixtures[1]) self.assertIn('isort', problems[0].body) for image in docker.images(): self.assertNotIn('flake8-', image, 'no flake8 image remains')
def test_process_files_py3_with_plugin_list(self): self.tool.options['python'] = 3 self.tool.options['plugins'] = [ 'flake8-bugbear', ] self.tool.process_files([self.fixtures[1]]) problems = self.problems.all(self.fixtures[1]) assert 'B004' in problems[-1].body for image in docker.images(): self.assertNotIn('flake8-', image, 'no flake8 image remains')
def test_process_files__with_optional_package(self): config = { 'standard': 'CakePHP4' } tool = Phpcs(self.problems, config, root_dir) tool.process_files([self.fixtures[1]]) problems = self.problems.all(self.fixtures[1]) assert 'strict_types' in problems[0].body, 'Should use custom rules' for image in docker.images(): self.assertNotIn('phpcs-', image, 'no phpcs image remains')
def test_execute__install_plugins_cleanup_image_on_failure(self): custom_dir = root_dir + '/tests/fixtures/eslint_custom' tool = Eslint(self.problems, { 'config': 'invalid.json', 'install_plugins': True, 'fixer': True }, custom_dir) target = 'has_errors.js' tool.process_files([target]) problems = self.problems.all() eq_(1, len(problems)) assert_in('Cannot find module', problems[0].body) ok_(docker.image_exists('nodejs'), 'original image is present') assert_not_in('eslint', docker.images(), 'no eslint image remains')
def test_execute__install_plugins(self): custom_dir = root_dir + '/tests/fixtures/eslint_custom' tool = Eslint(self.problems, { 'config': 'config.json', 'install_plugins': True, 'fixer': True }, custom_dir) target = 'has_errors.js' tool.process_files([target]) problems = self.problems.all() eq_(2, len(problems), 'Should find errors') assert_in('Unexpected var', problems[0].body) ok_(docker.image_exists('nodejs'), 'original image is present') assert_not_in('eslint', docker.images(), 'no eslint image remains')
def test_execute__install_plugins_cleanup_image_on_failure(self): custom_dir = root_dir + '/tests/fixtures/eslint_custom' tool = Eslint(self.problems, { 'config': 'invalid.json', 'install_plugins': True, 'fixer': True }, custom_dir) target = 'has_errors.js' tool.process_files([target]) problems = self.problems.all() self.assertEqual(1, len(problems)) self.assertIn('Cannot find module', problems[0].body) self.assertTrue(docker.image_exists('eslint'), 'original image is present') for image in docker.images(): self.assertNotIn('eslint-', image, 'no eslint image remains')
def test_execute_fixer__install_plugins(self): custom_dir = root_dir + '/tests/fixtures/eslint_custom' tool = Eslint(self.problems, { 'config': 'config.json', 'install_plugins': True, 'fixer': True }, custom_dir) target = 'tests/fixtures/eslint_custom/fixer_errors.js' # The fixture file can have all problems fixed by eslint original = read_file(target) tool.execute_fixer(['fixer_errors.js']) tool.process_files(['fixer_errors.js']) read_and_restore_file(target, original) eq_(0, len(self.problems.all()), 'All errors should be autofixed') assert_not_in('eslint', docker.images(), 'no eslint image remains')
def test_execute__install_plugins_cleanup_image_on_failure(self): custom_dir = root_dir + '/tests/fixtures/eslint_custom' tool = Eslint(self.problems, { 'config': 'invalid.json', 'install_plugins': True, 'fixer': True }, custom_dir) target = 'has_errors.js' tool.process_files([target]) problems = self.problems.all() self.assertEqual(1, len(problems)) self.assertIn('invalid-rules', problems[0].body) self.assertIn('output the following error', problems[0].body) self.assertTrue(docker.image_exists('eslint'), 'original image is present') for image in docker.images(): self.assertNotIn('eslint-', image, 'no eslint image remains')
def test_execute__install_plugins(self): custom_dir = root_dir + '/tests/fixtures/eslint_custom' tool = Eslint(self.problems, { 'config': 'config.json', 'install_plugins': True, 'fixer': True }, custom_dir) target = 'has_errors.js' tool.process_files([target]) problems = self.problems.all() self.assertEqual(2, len(problems), 'Should find errors') self.assertIn('Unexpected var', problems[0].body) self.assertTrue(docker.image_exists('nodejs'), 'original image is present') for image in docker.images(): self.assertNotIn('eslint-', image, 'no eslint image remains')
def test_execute_fixer__install_plugins(self): custom_dir = root_dir + '/tests/fixtures/eslint_custom' tool = Eslint(self.problems, { 'config': 'config.json', 'install_plugins': True, 'fixer': True }, custom_dir) target = 'tests/fixtures/eslint_custom/fixer_errors.js' # The fixture file can have all problems fixed by eslint original = read_file(target) tool.execute_fixer(['fixer_errors.js']) tool.process_files(['fixer_errors.js']) read_and_restore_file(target, original) self.assertEqual(0, len(self.problems.all()), 'All errors should be autofixed') for image in docker.images(): self.assertNotIn('eslint-', image, 'no eslint image remains')
def test_images(self): result = docker.images() self.assertIn('python2:latest', result)
def test_images(): result = docker.images() assert_in('python2', result)
def test_images(self): result = docker.images() self.assertIn('python2:latest', result)