How to use the pyscaffold.structure.create_structure function in PyScaffold

To help you get started, we’ve selected a few PyScaffold examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyscaffold / pyscaffold / tests / test_repo.py View on Github external
def test_get_git_root_with_nogit(tmpfolder, nogit_mock):
    project = "my_project"
    struct = {
        project: {
            "my_file": "Some other content",
            "my_dir": {"my_file": "Some more content"},
        }
    }
    structure.create_structure(struct, {})
    with utils.chdir(project):
        git_root = repo.get_git_root(default=".")
    assert git_root == "."
github pyscaffold / pyscaffold / tests / test_repo.py View on Github external
def test_version_of_subdir(tmpfolder):
    projects = ["main_project", "inner_project"]
    for project in projects:
        opts = cli.parse_args([project])
        opts = cli.process_opts(opts)
        _, opts = api.get_default_options({}, opts)
        struct, _ = structure.define_structure({}, opts)
        struct, _ = update.apply_update_rules(struct, opts)
        structure.create_structure(struct, {})
        repo.init_commit_repo(project, struct)
    utils.rm_rf(os.path.join("inner_project", ".git"))
    shutil.move("inner_project", "main_project/inner_project")
    with utils.chdir("main_project"):
        main_version = (
            subprocess.check_output([sys.executable, "setup.py", "--version"])
            .strip()
            .splitlines()[-1]
        )
        with utils.chdir("inner_project"):
            inner_version = (
                subprocess.check_output([sys.executable, "setup.py", "--version"])
                .strip()
                .splitlines()[-1]
            )
    assert main_version.strip() == inner_version.strip()
github pyscaffold / pyscaffold / tests / test_structure.py View on Github external
def test_create_structure(tmpfolder):
    struct = {
        "my_file": "Some content",
        "my_folder": {
            "my_dir_file": "Some other content",
            "empty_file": "",
            "file_not_created": None,
        },
        "empty_folder": {},
    }
    expected = {
        "my_file": "Some content",
        "my_folder": {"my_dir_file": "Some other content", "empty_file": ""},
        "empty_folder": {},
    }
    changed, _ = structure.create_structure(struct, {})

    assert changed == expected
    assert isdir("my_folder")
    assert isdir("empty_folder")
    assert isfile("my_folder/my_dir_file")
    assert isfile("my_folder/empty_file")
    assert not isfile("my_folder/file_not_created")
    assert isfile("my_file")
    assert open("my_file").read() == "Some content"
    assert open("my_folder/my_dir_file").read() == "Some other content"
    assert open("my_folder/empty_file").read() == ""
github pyscaffold / pyscaffold / tests / test_repo.py View on Github external
def test_get_git_root(tmpfolder):
    project = "my_project"
    struct = {
        project: {
            "my_file": "Some other content",
            "my_dir": {"my_file": "Some more content"},
        }
    }
    structure.create_structure(struct, {})
    repo.init_commit_repo(project, struct)
    with utils.chdir(project):
        git_root = repo.get_git_root()
    assert os.path.basename(git_root) == project
github pyscaffold / pyscaffold / tests / test_structure.py View on Github external
def test_create_structure_when_dir_exists(tmpfolder):
    struct = {"my_folder": {"my_dir_file": "Some other content"}}
    os.mkdir("my_folder")
    with pytest.raises(OSError):
        structure.create_structure(struct, dict(update=False))
github pyscaffold / pyscaffold / tests / test_info.py View on Github external
def test_dirty_workspace(tmpfolder):
    project = "my_project"
    struct = {project: {"dummyfile": "NO CONTENT"}}
    structure.create_structure(struct, {})
    repo.init_commit_repo(project, struct)
    path = tmpfolder / project
    assert info.is_git_workspace_clean(path)
    with open(str(path / "dummyfile"), "w") as fh:
        fh.write("CHANGED\n")
    assert not info.is_git_workspace_clean(path)
github pyscaffold / pyscaffold / tests / test_structure.py View on Github external
def test_create_structure_with_wrong_type(tmpfolder):
    with pytest.raises(RuntimeError):
        struct = {"strange_thing": 1}
        structure.create_structure(struct, {})
github pyscaffold / pyscaffold / tests / test_repo.py View on Github external
def test_pretend_init_commit_repo(tmpfolder):
    project = "my_project"
    struct = {
        project: {
            "my_file": "Some other content",
            "my_dir": {"my_file": "Some more content"},
            "dummy": None,
        }
    }
    structure.create_structure(struct, {})
    dummy_file = os.path.join(project, "dummy")
    with open(dummy_file, "w"):
        os.utime(dummy_file, None)
    repo.init_commit_repo(project, struct, pretend=True)
    assert not os.path.exists(os.path.join(project, ".git"))
github pyscaffold / pyscaffold / tests / test_repo.py View on Github external
def test_add_tag(tmpfolder):
    project = "my_project"
    struct = {
        project: {
            "my_file": "Some other content",
            "my_dir": {"my_file": "Some more content"},
        }
    }
    structure.create_structure(struct, {})
    repo.init_commit_repo(project, struct)
    repo.add_tag(project, "v0.0")
    repo.add_tag(project, "v0.1", "Message with whitespace")