Default to puffin venv path to .venv (#261)

Closes https://github.com/astral-sh/puffin/issues/236
This commit is contained in:
Zanie Blue 2023-10-31 15:24:19 -05:00 committed by GitHub
parent e00d208318
commit 0dc7e6335e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 0 deletions

View file

@ -147,6 +147,7 @@ struct VenvArgs {
python: Option<PathBuf>,
/// The path to the virtual environment to create.
#[clap(default_value = ".venv")]
name: PathBuf,
}

View file

@ -0,0 +1,15 @@
---
source: crates/puffin-cli/tests/venv.rs
info:
program: puffin
args:
- venv
---
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Using Python interpreter: /usr/bin/python3
Creating virtual environment at: .venv

View file

@ -30,3 +30,24 @@ fn create_venv() -> Result<()> {
Ok(())
}
#[test]
fn create_venv_defaults_to_cwd() -> Result<()> {
let tempdir = assert_fs::TempDir::new()?;
let venv = tempdir.child(".venv");
insta::with_settings!({
filters => vec![
(r"Using Python interpreter: .+", "Using Python interpreter: /usr/bin/python3"),
(tempdir.to_str().unwrap(), "/home/ferris/project"),
]
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.arg("venv")
.current_dir(&tempdir));
});
venv.assert(predicates::path::is_dir());
Ok(())
}