def test_generate(): cfg = dict(name='mit', year="2015", organization="org", project="project") env = pkg_env(dict(license=cfg)) assert len(env.globals['license'].full_text) > 0
def test_pkg_env_loads_specific_handlers_from_options(): cfg = dict(default_cfg) cfg['base'] = dict(pkgname="toto", namespace="nm", url=None, authors=[("moi", "moi@aussi")]) env = pkg_env(cfg) assert hasattr(env.globals['base'], "pkg_full_name")
def test_install_example_do_not_complain_if_file_already_exists(): cfg = deepcopy(default_cfg) cfg['base'] = dict(pkgname='toto', namespace=None) cfg['test'] = dict() env = pkg_env(cfg) assert install_example_files('test', env, tmp_dir) assert install_example_files('test', env, tmp_dir)
def test_badge(): env = pkg_env( dict( base={"pkgname": "pkg", "namespace": None, "url": "http://toto"}, pysetup={"intended_versions": ["27", "28"], "require": []}, pypi={"classifiers": []}, ) ) assert ".. image:" in env.globals["pypi"].badge
def test_install_example_handles_namespace(): cfg = deepcopy(default_cfg) cfg['base'] = dict(pkgname='toto', namespace='oa') cfg['test'] = dict() env = pkg_env(cfg) install_example_files('test', env, tmp_dir) assert exists(pj(tmp_dir, "test", "test_example.py")) assert not exists(pj(tmp_dir, "src", "toto", "example.py")) assert exists(pj(tmp_dir, "src", "oa", "toto", "example.py"))
def test_install_example_copy_binary_files(): cfg = deepcopy(default_cfg) cfg['base'] = dict(pkgname='toto', namespace=None) cfg['data'] = dict() env = pkg_env(cfg) assert len(listdir(tmp_dir)) == 0 install_example_files('data', env, tmp_dir) assert len(listdir(tmp_dir)) > 0 assert exists(pj(tmp_dir, "src", "toto_data", "ext_data.png"))
def test_auto_classifiers(): env = pkg_env( dict( base={"pkgname": "pkg", "namespace": None, "url": "http://toto"}, pysetup={"intended_versions": ["27", "28"]}, pypi={"classifiers": []}, ) ) assert "Programming Language :: Python" in env.globals["pypi"].auto_classifiers assert "Programming Language :: Python :: 2.7" in env.globals["pypi"].auto_classifiers
def test_install_example_copy_files(): cfg = deepcopy(default_cfg) cfg['base'] = dict(pkgname='toto', namespace=None) cfg['test'] = dict() env = pkg_env(cfg) assert len(listdir(tmp_dir)) == 0 install_example_files('test', env, tmp_dir) assert len(listdir(tmp_dir)) > 0 assert exists(pj(tmp_dir, "src", "toto", "example.py")) assert exists(pj(tmp_dir, "test", "test_example.py"))
def test_pkg_url_look_multiple_places(): cfg = dict(base={'pkgname': 'toto', 'namespace': 'oa', 'url': None}, github={'url': None}, pypi={'classifiers': [], 'url': None}, readthedocs={'project': 'project'}, pysetup={'intended_versions': ["27"]}) for name in ("base", "github", "pypi", "readthedocs"): loc_cfg = deepcopy(cfg) loc_cfg[name]['url'] = name env = pkg_env(loc_cfg) assert env.globals['pysetup'].pkg_url == name
def test_generate_raise_error_if_license_do_not_exists(): cfg = dict(name='tugudu', year="2015", organization="org", project="project") assert_raises(IOError, lambda: pkg_env(dict(license=cfg)))
def test_badge(): env = pkg_env(dict(coveralls={}, github={'owner': "moi", 'project': "project"})) assert ".. image:" in env.globals['coveralls'].badge
def test_badge(): env = pkg_env(dict(readthedocs={"project": "project"})) assert ".. image:" in env.globals["readthedocs"].badge
def test_pkg_env_raise_error_if_option_not_defined(): cfg = dict(default_cfg) cfg['babou'] = dict(a="a", b="b") assert_raises(KeyError, lambda: pkg_env(cfg))
def test_pkg_url_empty_default(): env = pkg_env(dict(pysetup={"intended_versions": ["27"]})) assert env.globals['pysetup'].pkg_url == ""
def test_requirements(): cfg = dict(test={}, pysetup={'intended_versions': ["27"]}) env = pkg_env(cfg) assert len(env.globals['pysetup'].requirements('install')) == 0 assert len(env.globals['pysetup'].requirements('dvlpt')) == 2
def test_badge(): env = pkg_env(dict(landscape={}, github={'owner': "moi", 'project': "project"})) assert ".. image:" in env.globals['landscape'].badge