def test_python_image(): eq_('python2', tools.python_image(False)) eq_('python2', tools.python_image('')) eq_('python2', tools.python_image('derp')) eq_('python2', tools.python_image({})) eq_('python2', tools.python_image([])) eq_('python2', tools.python_image({'python': 2})) eq_('python2', tools.python_image({'python': '2'})) eq_('python3', tools.python_image({'python': '3'})) eq_('python3', tools.python_image({'python': 3}))
def test_python_image(self): self.assertEqual('python2', tools.python_image(False)) self.assertEqual('python2', tools.python_image('')) self.assertEqual('python2', tools.python_image('derp')) self.assertEqual('python2', tools.python_image({})) self.assertEqual('python2', tools.python_image([])) self.assertEqual('python2', tools.python_image({'python': 2})) self.assertEqual('python2', tools.python_image({'python': '2'})) self.assertEqual('python3', tools.python_image({'python': '3'})) self.assertEqual('python3', tools.python_image({'python': 3}))
def test_python_image(self): self.assertEqual('python2', tools.python_image(False)) self.assertEqual('python2', tools.python_image('')) self.assertEqual('python2', tools.python_image('derp')) self.assertEqual('python2', tools.python_image({})) self.assertEqual('python2', tools.python_image([])) self.assertEqual('python2', tools.python_image({'python': 2})) self.assertEqual('python2', tools.python_image({'python': '2'})) self.assertEqual('python3', tools.python_image({'python': '3'})) self.assertEqual('python3', tools.python_image({'python': 3}))
def process_files(self, files): """ Run code checks with pep8. Only a single process is made for all files to save resources. """ log.debug('Processing %s files with %s', files, self.name) pep8_options = ['exclude', 'filename', 'select', 'ignore', 'max-line-length'] command = ['pep8', '-r'] for option, value in self.options.items(): if option in pep8_options: command += [u'--{}'.format(option), value] command += files image = python_image(self.options) output = docker.run(image, command, source_dir=self.base_path) if not output: log.debug('No pep8 errors found.') return False output = output.split("\n") process_quickfix(self.problems, output, docker.strip_base)
def get_image_name(self, files): """Get the image name based on options If the `plugin` option is used a custom image will be created. """ image = python_image(self.options) plugins = self.options.get('plugins', None) if not plugins: return image if not isinstance(plugins, list): plugin_type = plugins.__class__.__name__ error = IssueComment( u'The `flake8.plugins` option must be a list got `{}` instead.'.format( plugin_type ) ) self.problems.add(error) return image invalid_plugins = [ p for p in plugins if p not in self.ALLOWED_PLUGINS] if invalid_plugins: error = IssueComment( u'The `flake8.plugins` option contained unsupported plugins {}'.format( u', '.join(invalid_plugins) ) ) self.problems.add(error) return image container_name = docker.generate_container_name('flake8', files) if self.custom_image is None: buildlog.info('Installing flake8 plugins') docker.run( image, ['flake8-install', u','.join(plugins)], source_dir=self.base_path, name=container_name ) docker.commit(container_name) docker.rm_container(container_name) self.custom_image = container_name buildlog.info('Installed flake8 plugins %s', plugins) return container_name
def process_files(self, files): """ Run code checks with flake8. Only a single process is made for all files to save resources. """ log.debug('Processing %s files with %s', len(files), self.name) command = self.make_command(files) image = python_image(self.options) output = docker.run(image, command, source_dir=self.base_path) if not output: log.debug('No flake8 errors found.') return False output = output.split("\n") process_quickfix(self.problems, output, docker.strip_base)
def process_files(self, files): """ Run code checks with flake8. Only a single process is made for all files to save resources. """ log.debug('Processing %s files with %s', len(files), self.name) command = self.make_command(files) image = python_image(self.options) output = docker.run(image, command, source_dir=self.base_path) if not output: log.debug('No flake8 errors found.') return False output = output.split("\n") process_quickfix(self.problems, output, docker.strip_base)
def process_files(self, files): """ Run code checks with pep8. Only a single process is made for all files to save resources. """ pep8_options = [ 'exclude', 'filename', 'select', 'ignore', 'max-line-length' ] command = ['pep8', '-r'] for option, value in self.options.items(): if option in pep8_options: command += [u'--{}'.format(option), value] command += files image = python_image(self.options) output = docker.run(image, command, source_dir=self.base_path) if not output: return False output = output.split("\n") process_quickfix(self.problems, output, docker.strip_base)
def process_fixer(self, files): """Run autopep8, as flake8 has no fixer mode. """ command = self.create_fixer_command(files) image = python_image(self.options) docker.run(image, command, self.base_path)
def process_fixer(self, files): """Run autopep8, as flake8 has no fixer mode. """ command = self.create_fixer_command(files) image = python_image(self.options) docker.run(image, command, self.base_path)