def test_analysis_should_return_true_if_invalid_file_is_excluded(self): filename = 'invalid.py' self.given_a_file_in_test_dir(filename, INVALID_CODE) self.options['flake8-exclude'] = '{0:s}/{1:s}'.format( self.test_dir, filename, ) with OutputCapture(): self.assertTrue(Flake8(self.options).run())
def test_get_flake8_options_on_deactivated_multiprocessing(self): self.options.update({ 'multiprocessing': 'True', }) options = Flake8(self.options).get_flake8_options() self.assertEqual( len(options), len(self.flake8_default_options), # just default options )
def test_analysis_file_should_exist_when_jenkins_is_true(self): parts_dir = mkdtemp() self.given_a_file_in_test_dir('correct.py', VALID_CODE) self.options['location'] = parts_dir self.options['jenkins'] = 'True' # need to activate jenkins. with OutputCapture(): Flake8(self.options).run() file_exist = os.path.isfile(os.path.join(parts_dir, 'flake8.log')) rmtree(parts_dir) self.assertTrue(file_exist)
def test_get_flake8_options(self): self.options.update({ 'flake8-one': 'something', 'flake8-two': 'else', }) options = Flake8(self.options).get_flake8_options() self.assertEqual( len(options), # --one=something --two=else --jobs=1 + default options 2 + 1 + len(self.flake8_default_options), )
def test_get_flake8_options_ignored(self): self.options.update({ 'flake8-one': 'something', 'flake8-filesystem': 'ignored', 'flake8-extensions': 'ignored', }) options = Flake8(self.options).get_flake8_options() self.assertEqual( len(options), # --one=something --jobs=1 + default options 1 + 1 + len(self.flake8_default_options), )
def test_analysis_should_return_true(self): self.given_a_file_in_test_dir('correct.py', VALID_CODE) with OutputCapture(): self.assertTrue(Flake8(self.options).run())
def test_analysis_should_return_true_when_oserror(self): # The options are fake, so the function should raise an OSError # but return True. self.options['bin-directory'] = 'FAKE_DIR' with OutputCapture(): self.assertTrue(Flake8(self.options).run())
def test_analysis_should_return_false_when_error_found(self): self.given_a_file_in_test_dir('incorrect.py', INVALID_CODE) with OutputCapture(): self.assertFalse(Flake8(self.options).run())