def test_clean_remove_dist_build_directories(tmp_dir): for name in ("dist", "build"): ensure_created(tmp_dir / name) clean(tmp_dir) assert len(tuple(tmp_dir.iterdir())) == 0
def tmp_dir(): pth = Path("nb_test_config") ensure_created(pth) yield pth rmdir(pth)
def tmp_dir(): pth = Path("tmp_cfgex") ensure_created(pth) yield pth rmdir(pth)
def tmp_dir(): pth = Path('toto_manage_clean') ensure_created(pth) yield pth rmdir(pth)
def tmp_dir(): pth = Path('toto_manage_cfg') ensure_created(pth) init_pkg(pth) yield pth rmdir(pth)
def tmp_dir(): pth = Path("toto_mg_ver") ensure_created(pth) ensure_created(pth / pkglts_dir) yield pth rmdir(pth)
def tmp_dir(): pth = Path("tagadareqs") ensure_created(pth) yield pth rmdir(pth)
def tmp_dir(): pth = Path("toto_mg_cfg") ensure_created(pth) ensure_created(pth / pkglts_dir) yield pth if pth.exists(): rmdir(pth)
def test_clean_do_not_explore_hidden_directories(tmp_dir): hidden = tmp_dir / ".test" ensure_created(hidden) pth = hidden / "toto.py" pth.write_text("toto") clean(tmp_dir) assert hidden.exists() assert pth.exists()
def test_clean_remove_pycache_directories(tmp_dir): pycache = tmp_dir / "__pycache__" ensure_created(pycache) pth = pycache / "toto.py" pth.write_text("toto") clean(tmp_dir) assert not pycache.exists() assert not pth.exists()
def test_find_templates_walk_all_files_in_src_dir(tmp_dir): ensure_created(tmp_dir / "src/sub") fnames = ('toto.txt', 'titi.txt', 'sub/toto.txt') for fname in fnames: pth = tmp_dir / "src" / fname pth.write_text("lorem ipsum") cfg = Config(DEFAULT_CFG) rg_tree = {} find_templates(tmp_dir / 'src', tmp_dir / 'tgt', cfg, rg_tree) for fname in fnames: assert pth_as_key(tmp_dir / 'tgt' / fname) in rg_tree
def test_find_templates_renders_path_names(tmp_dir): ensure_created(tmp_dir / "src/{{ custom_name }}") fnames = ('{{ custom_name }}.txt', 'titi.txt', '{{ custom_name }}/{{ custom_name }}.txt') for fname in fnames: pth = tmp_dir / "src" / fname pth.write_text("lorem ipsum") cfg = Config(DEFAULT_CFG) cfg._env.globals['custom_name'] = 'toto' rg_tree = {} find_templates(tmp_dir / 'src', tmp_dir / 'tgt', cfg, rg_tree) fnames = ('toto.txt', 'titi.txt', 'toto/toto.txt') for fname in fnames: assert pth_as_key(tmp_dir / 'tgt' / fname) in rg_tree
def test_find_templates_ignores_specific_names(tmp_dir): ensure_created(tmp_dir / "src/{{ custom_name }}") fnames = ('{{ custom_name }}.txt', 'titi.txt', '{{ custom_name }}/{{ custom_name }}.txt') for fname in fnames: pth = tmp_dir / "src" / fname pth.write_text("lorem ipsum") cfg = Config(DEFAULT_CFG) cfg._env.globals['custom_name'] = '_' rg_tree = {} find_templates(tmp_dir / 'src', tmp_dir / 'tgt', cfg, rg_tree) assert pth_as_key(tmp_dir / 'tgt/titi.txt') in rg_tree fnames = ('_.txt', '_/_.txt') for fname in fnames: assert pth_as_key(tmp_dir / 'tgt' / fname) not in rg_tree
def tmp_pths(): pth = Path('toto_mg_rg') ensure_created(pth) init_pkg(pth) with open((pth / pkglts_dir / pkg_cfg_file), 'r') as fhr: pkg_cfg = json.load(fhr) pkg_cfg['base'] = dict(pkgname='toto', namespace=None, authors=[('moi', '*****@*****.**')], url=None) pkg_cfg['src'] = dict(namespace_method="pkg_util") cfg = Config(pkg_cfg) write_pkg_config(cfg, pth) regenerate_package(cfg, pth) init_file = pth / "src/toto/__init__.py" yield pth, init_file rmdir(pth)
def tmp_dir(): pth = Path("takapouet") ensure_created(pth) ensure_created(pth / "src") ensure_created(pth / "tgt") yield pth rmdir(pth)