def test_execute_fixer(self): tool = Puppet(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.' eq_(0, len(self.problems.all()), 'No errors should be recorded')
def test_execute_fixer(self): tool = Puppet(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__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) eq_(1, len(self.problems.all()), 'Most errors should be fixed') assert_in('autoload module layout', 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__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) eq_(2, len(self.problems.all()), 'Most errors should be fixed') problems = sorted(self.problems.all(), key=attrgetter('line')) assert_in('ERROR:foo not in autoload module layout', problems[0].body) assert_in('WARNING:quoted boolean value', problems[1].body)
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)