mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 19:08:04 +00:00
55 lines
1.4 KiB
Rust
55 lines
1.4 KiB
Rust
#![cfg(feature = "python")]
|
|
|
|
use std::process::Command;
|
|
|
|
use anyhow::Result;
|
|
use assert_fs::prelude::*;
|
|
use insta_cmd::_macro_support::insta;
|
|
use insta_cmd::{assert_cmd_snapshot, get_cargo_bin};
|
|
|
|
use common::BIN_NAME;
|
|
|
|
mod common;
|
|
|
|
#[test]
|
|
fn create_venv() -> 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")
|
|
.arg(venv.as_os_str())
|
|
.current_dir(&tempdir));
|
|
});
|
|
|
|
venv.assert(predicates::path::is_dir());
|
|
|
|
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(())
|
|
}
|