def createproject(ctx, quiet, projectname): """Creates a new project.""" if not quiet: click.echo(VERSION) path = os.path.abspath(projectname) if os.path.exists(path): raise click.ClickException( u'{0} exists. Remove it and try again or try again with ' u'a different project name.'.format(path) ) # TODO: this kicks up errors. catch the errors and tell the user # something more useful click.echo(u'Creating directory {0}...'.format(path)) os.makedirs(path) conf_name = get_project_config_file_name() click.echo(u'Creating {0}...'.format(conf_name)) create_project_config_file(path) click.echo(u'{0} created.'.format(path)) click.echo(u'') click.echo(u'Now cd into the directory and edit the {0} file.'.format(conf_name)) click.echo(u'After you do that, you should put your project into version ' u'control. Srsly.')
def test_ini_config_creation(self, config): runner = CliRunner() with runner.isolated_filesystem(): path = os.getcwd() with pytest.raises(ConfigNotFound): get_project_config() # Create the project directory create_project_config_file(path, config) cfg = get_project_config() assert os.path.exists(config.file_name) tmp_dir = 'tmp' os.mkdir(tmp_dir) os.chdir(tmp_dir) cfg2 = get_project_config() os.chdir(path) assert cfg.get('project', 'jsonpath') == cfg2.get('project', 'jsonpath') with pytest.raises(NoOptionError): cfg.get('project', 'xmlpath')