def test_execute_fixer__no_problems_remain(self): tool = Phpcs(self.problems, {'fixer': True}) # The fixture file can have all problems fixed by phpcs original = read_file(self.fixtures[1]) tool.execute_fixer(self.fixtures) tool.process_files(self.fixtures) read_and_restore_file(self.fixtures[1], original) eq_(0, len(self.problems.all()), 'All errors should be autofixed')
def test_execute_fixer__fewer_problems_remain(self): tool = Pep8(self.problems, {'fixer': True}, root_dir) # The fixture file can have all problems fixed by autopep8 original = read_file(self.fixtures[1]) tool.execute_fixer(self.fixtures) tool.process_files(self.fixtures) read_and_restore_file(self.fixtures[1], original) self.assertGreaterEqual(len(self.problems.all()), 0, 'Most errors should be fixed')
def test_execute_fixer__fewer_problems_remain(self): tool = Rubocop(self.problems, {'fixer': True}, root_dir) # The fixture file can have all problems fixed by rubocop original = read_file(self.fixtures[1]) tool.execute_fixer(self.fixtures) tool.process_files(self.fixtures) read_and_restore_file(self.fixtures[1], original) self.assertEqual(1, len(self.problems.all()), 'Most errors should be fixed') self.assertIn('too long', self.problems.all()[0].body)
def test_execute_fixer__fewer_problems_remain(self): tool = Puppet(self.problems, {'fixer': True}, root_dir) # The fixture file should have fixable problems fixed original = read_file(self.fixtures[1]) tool.execute_fixer(self.fixtures) tool.process_files(self.fixtures) read_and_restore_file(self.fixtures[1], original) self.assertEqual(1, len(self.problems.all()), 'Most errors should be fixed') self.assertIn('autoload module layout', self.problems.all()[0].body)
def test_execute_fixer__no_problems_remain(self): tool = Eslint(self.problems, { 'config': 'tests/fixtures/eslint/recommended_config.json', 'fixer': True }, root_dir) # The fixture file can have all problems fixed by eslint original = read_file(FILE_WITH_FIXER_ERRORS) tool.execute_fixer([FILE_WITH_FIXER_ERRORS]) tool.process_files([FILE_WITH_FIXER_ERRORS]) read_and_restore_file(FILE_WITH_FIXER_ERRORS, original) self.assertEqual(0, len(self.problems.all()), 'All errors should be autofixed')
def test_execute_fixer__fewer_problems_remain__python3(self): options = {'fixer': True, 'python': 3} tool = Pep8(self.problems, options, root_dir) # The fixture file can have all problems fixed by autopep8 original = read_file(self.fixtures[1]) tool.execute_fixer(self.fixtures) tool.process_files(self.fixtures) read_and_restore_file(self.fixtures[1], original) self.assertLessEqual(1, len(self.problems.all()), 'Most errors should be fixed') text = [c.body for c in self.problems.all()] self.assertIn("'<>' is deprecated", ' '.join(text))
def test_execute_fixer(self): tool = Phpcs(self.problems, {'fixer': True}) original = read_file(self.fixtures[1]) tool.execute_fixer(self.fixtures) updated = read_and_restore_file(self.fixtures[1], original) assert original != updated, 'File content should change.' eq_(0, len(self.problems.all()), 'No errors should be recorded')
def test_run_fixer(self): tool = Pytype(self.problems, {'fixer': True}, root_dir) original = read_file(self.fixtures[1]) tool.execute_fixer(self.fixtures) updated = read_and_restore_file(self.fixtures[1], original) assert original != updated, 'File content should change.' self.assertEqual(0, len(self.problems.all()), 'No errors should be recorded')
def test_execute_fixer__fixer_ignore(self): puppet_config = { 'fixer': True, 'fixer_ignore': 'quoted_booleans, variable_is_lowercase', } tool = Puppet(self.problems, puppet_config, root_dir) original = read_file(self.fixtures[1]) tool.execute_fixer(self.fixtures) tool.process_files(self.fixtures) read_and_restore_file(self.fixtures[1], original) self.assertEqual(2, len(self.problems.all()), 'Most errors should be fixed') problems = sorted(self.problems.all(), key=attrgetter('line')) self.assertIn('ERROR:foo not in autoload module layout', problems[0].body) self.assertIn('WARNING:quoted boolean value', problems[1].body)
def test_execute_fixer(self): tool = Golint(self.problems, {'fixer': True}, root_dir) original = read_file(self.fixtures[1]) tool.execute_fixer(self.fixtures) updated = read_and_restore_file(self.fixtures[1], original) assert original != updated, 'File content should change.' self.assertEqual(0, len(self.problems.all()), 'No errors should be recorded')
def test_execute_fixer(self): tool = Remarklint(self.problems, {'fixer': True}, root_dir) original = read_file(self.fixtures[1]) tool.execute_fixer(self.fixtures) tool.process_files(self.fixtures) updated = read_and_restore_file(self.fixtures[1], original) assert original != updated, 'File content should change.' eq_(1, len(self.problems.all()), 'Fewer errors should be recorded')
def test_execute_fixer__python3(self): options = {'fixer': True, 'python': 3} tool = Flake8(self.problems, options, root_dir) original = read_file(self.fixtures[1]) tool.execute_fixer(self.fixtures) updated = read_and_restore_file(self.fixtures[1], original) assert original != updated, 'File content should change.' eq_(0, len(self.problems.all()), 'No errors should be recorded')
def test_execute_fixer(self): tool = Ktlint(self.problems, {'fixer': True}, root_dir) target = root_dir + '/' + self.fixtures[1] original = read_file(target) tool.execute_fixer(self.fixtures) updated = read_and_restore_file(target, original) assert original != updated, 'File content should change.' self.assertEqual(0, len(self.problems.all()), 'No errors should be recorded')
def test_execute_fixer__python3(self): options = {'fixer': True, 'python': 3} tool = Pep8(self.problems, options, root_dir) original = read_file(self.fixtures[1]) tool.execute_fixer(self.fixtures) updated = read_and_restore_file(self.fixtures[1], original) assert original != updated, 'File content should change.' self.assertEqual(0, len(self.problems.all()), 'No errors should be recorded')
def test_execute_fixer(self): fixture = self.fixtures[1] tool = Stylelint(self.problems, { 'config': 'tests/fixtures/stylelint/stylelintrc.json', 'fixer': True, }, root_dir) original = read_file(fixture) tool.execute_fixer([fixture]) updated = read_and_restore_file(fixture, original) assert original != updated, 'File content should change.'
def test_execute_fixer(self): tool = Remarklint(self.problems, {'fixer': True}, root_dir) original = read_file(self.fixtures[1]) tool.execute_fixer(self.fixtures) tool.process_files(self.fixtures) updated = read_and_restore_file(self.fixtures[1], original) assert original != updated, 'File content should change.' self.assertEqual(1, len(self.problems.all()), 'Fewer errors should be recorded')
def test_execute_fixer(self): tool = Eslint(self.problems, { 'config': 'tests/fixtures/eslint/recommended_config.json', 'fixer': True, }, root_dir) original = read_file(FILE_WITH_FIXER_ERRORS) tool.execute_fixer([FILE_WITH_FIXER_ERRORS]) updated = read_and_restore_file(FILE_WITH_FIXER_ERRORS, original) assert original != updated, 'File content should change.' eq_(0, len(self.problems.all()), 'No errors should be recorded')
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_execute_fixer(self): tool = Eslint(self.problems, { 'config': 'tests/fixtures/eslint/recommended_config.json', 'fixer': True, }, root_dir) original = read_file(FILE_WITH_FIXER_ERRORS) tool.execute_fixer([FILE_WITH_FIXER_ERRORS]) updated = read_and_restore_file(FILE_WITH_FIXER_ERRORS, original) assert original != updated, 'File content should change.' self.assertEqual(0, len(self.problems.all()), 'No errors should be recorded')
def test_execute_fixer__options(self): tool = Pep8(self.problems, { 'fixer': True, 'max-line-length': 120, 'exclude': 'W201' }, root_dir) original = read_file(self.fixtures[1]) tool.execute_fixer(self.fixtures) updated = read_and_restore_file(self.fixtures[1], original) assert original != updated, 'File content should change.' eq_(0, len(self.problems.all()), 'No errors should be recorded')
def test_execute_fixer__options(self): tool = Pep8(self.problems, { 'fixer': True, 'max-line-length': 120, 'exclude': 'W201' }, root_dir) original = read_file(self.fixtures[1]) tool.execute_fixer(self.fixtures) updated = read_and_restore_file(self.fixtures[1], original) assert original != updated, 'File content should change.' self.assertEqual(0, len(self.problems.all()), 'No errors should be recorded')