def info_command(): """Scan for project data.""" info = find_project_data() info['python'] = utils.find_python() info['sphinx-quickstart'] = utils.find_sphinx_quickstart() info['sphinx-build'] = utils.find_sphinx_build() def echo_warning(title, key): value = info.get(key, 'NOT FOUND') if value is None: value = 'NOT FOUND' if value == 'NOT FOUND': click.echo(title + value, nl=False) click.secho(' [!]', fg='red') else: click.echo(title + value) echo_warning('Project name: ', 'name') echo_warning('Package: ', 'package') echo_warning('Test directory: ', 'tests') echo_warning('Version: ', 'version') echo_warning('Author: ', 'author') echo_warning('Email: ', 'email') echo_warning('URL: ', 'url') echo_warning('Python: ', 'python') echo_warning('sphinx-quickstart: ', 'sphinx-quickstart') echo_warning('sphinx-build: ', 'sphinx-build')
def _test_find_project_data_author_from_env(self, mock_env, mock_shell): mock_shell.return_value = subprocess.run('blabla1234', shell=True) # This test runs into an exception on Windows. # Manual testing works. Fix it later. if platform.system() == 'Windows': self.assertTrue(True) runner = CliRunner() with runner.isolated_filesystem(): mock_env.return_value = 'test_user' info = find_project_data() assert info.get('author') == 'test_user'
def run_flake8_command(dirs): """Run PEP8 style enforcement. But in contrast to PEP8, by default 120 characters per line are ok. """ # If user forgets to give directories to scan, make a guess. if len(dirs) == 0: guess = find_project_data().get('package') if guess: if click.confirm( 'No directory to scan was given. Did you mean "%s"?' % guess, default=True): run_flake8([guess]) return raise click.BadParameter('No directories to scan.') run_flake8(dirs)
deploy_github(url, main) @cli.group('run') def run(*args, **kwargs): """Run tests or analyze test coverage""" pass @run.command('tests') @click.option('-t', 'directory', required=True, prompt='Test folder', help='Directory with tests.', default=lambda: find_project_data().get('tests', None)) @click.option('-r', '--runner', 'runner', required=True, default='unittest', type=click.Choice(['unittest', 'pytest'], case_sensitive=False), help='Test runner', prompt='Test runner') def run_tests_command(directory, runner): """Run tests in a test folder.""" run_tests(directory, runner) @run.command('coverage') @click.option('-s',