How to use the pyscaffold.utils.chdir 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_install.py View on Github external
def _generate(self):
        putup([self.name])
        with chdir(self.name):
            demoapp_src_dir = path_join(__location__, self.name)
            demoapp_dst_root = self.pkg_path
            demoapp_dst_pkg = path_join(demoapp_dst_root, "src", self.name)
            copyfile(
                path_join(demoapp_src_dir, "runner.py"),
                path_join(demoapp_dst_pkg, "runner.py"),
            )
            git("add", path_join(demoapp_dst_pkg, "runner.py"))
            copyfile(
                path_join(demoapp_src_dir, "setup.cfg"),
                path_join(demoapp_dst_root, "setup.cfg"),
            )
            copyfile(
                path_join(demoapp_src_dir, "setup.py"),
                path_join(demoapp_dst_root, "setup.py"),
            )
github pyscaffold / pyscaffold / tests / test_install.py View on Github external
def make_commit(self):
        with chdir(self.pkg_path):
            git("commit", "-a", "-m", "message")
        return self
github pyscaffold / pyscaffold / tests / test_install.py View on Github external
def tag(self, name, message):
        with chdir(self.pkg_path):
            git("tag", "-a", name, "-m", message)
        return self
github pyscaffold / pyscaffold / tests / test_repo.py View on Github external
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_utils.py View on Github external
def test_chdir(caplog, tmpdir, isolated_logger):
    caplog.set_level(logging.INFO)
    curr_dir = os.getcwd()
    dname = uniqstr()  # Use a unique name to get easily identifiable logs
    temp_dir = str(tmpdir.mkdir(dname))
    with utils.chdir(temp_dir, log=True):
        new_dir = os.getcwd()
    assert new_dir == os.path.realpath(temp_dir)
    assert curr_dir == os.getcwd()
    assert curr_dir != new_dir
    logs = caplog.text
    assert re.search("chdir.+" + dname, logs)
github pyscaffold / pyscaffold / tests / test_install.py View on Github external
def _install_bdist(self):
        with chdir("/"):
            # Because of the way bdist works, the tar.gz will contain
            # the whole path to the current venv, starting from the
            # / directory ...
            untar(self.dist_file, "--force-local")
            # ^  --force-local is required to deal with Windows paths
github pyscaffold / pyscaffoldext-markdown / tests / test_custom_extension.py View on Github external
def test_generated_extension_flake8(tmpfolder, venv_run):
    args = [EXT_FLAG, "my_project"]
    opts = parse_args(args)
    opts = process_opts(opts)
    create_project(opts)

    with chdir("my_project"):
        assert "" == venv_run("flake8")
        venv_run("python setup.py install")

    venv_run("putup {ext_flag} the_actual_project".format(ext_flag=EXT_FLAG))
    assert path_exists("the_actual_project/setup.cfg")

    with chdir("the_actual_project"):
        assert "" == venv_run("flake8")
github pyscaffold / pyscaffold / tests / test_install.py View on Github external
def build(self, dist="bdist", cli_opts=()):
        with self.guard("built"), chdir(self.pkg_path):
            if "wheel" in dist:
                self.run("pip", "install", "wheel")
            else:
                cli_opts = cli_opts or ["--format", "gztar"]
                # ^  force tar.gz (Windows defaults to zip)
            self.run("python", "setup.py", dist, *cli_opts)
        self.dist = dist
        return self
github pyscaffold / pyscaffold / tests / test_utils.py View on Github external
def test_pretend_chdir(caplog, tmpdir):
    caplog.set_level(logging.INFO)
    curr_dir = os.getcwd()
    dname = uniqstr()  # Use a unique name to get easily identifiable logs
    temp_dir = str(tmpdir.mkdir(dname))
    with utils.chdir(temp_dir, pretend=True):
        new_dir = os.getcwd()
    assert new_dir == curr_dir  # the directory is not changed
    assert curr_dir == os.getcwd()
    logs = caplog.text
    assert re.search("chdir.+" + dname, logs)
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