mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35:00 +00:00
Use isolated Poetry editables for pip_uninstall
tests
This commit is contained in:
parent
8352560b98
commit
eefe7df1bf
1 changed files with 24 additions and 18 deletions
|
@ -5,6 +5,8 @@ use assert_cmd::prelude::*;
|
||||||
use assert_fs::fixture::ChildPath;
|
use assert_fs::fixture::ChildPath;
|
||||||
use assert_fs::prelude::*;
|
use assert_fs::prelude::*;
|
||||||
|
|
||||||
|
use uv_fs::copy_dir_all;
|
||||||
|
|
||||||
use crate::common::{TestContext, get_bin, uv_snapshot};
|
use crate::common::{TestContext, get_bin, uv_snapshot};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -211,17 +213,19 @@ fn uninstall_editable_by_name() -> Result<()> {
|
||||||
#[cfg(feature = "pypi")]
|
#[cfg(feature = "pypi")]
|
||||||
fn uninstall_by_path() -> Result<()> {
|
fn uninstall_by_path() -> Result<()> {
|
||||||
let context = TestContext::new("3.12");
|
let context = TestContext::new("3.12");
|
||||||
|
let poetry_editable = context.temp_dir.child("packages").child("poetry_editable");
|
||||||
|
|
||||||
let requirements_txt = context.temp_dir.child("requirements.txt");
|
// Copy into the temporary directory.
|
||||||
requirements_txt.write_str(
|
copy_dir_all(
|
||||||
context
|
context
|
||||||
.workspace_root
|
.workspace_root
|
||||||
.join("scripts/packages/poetry_editable")
|
.join("scripts/packages/poetry_editable"),
|
||||||
.as_os_str()
|
&poetry_editable,
|
||||||
.to_str()
|
|
||||||
.expect("Path is valid unicode"),
|
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
let requirements_txt = context.temp_dir.child("requirements.txt");
|
||||||
|
requirements_txt.write_str(poetry_editable.as_os_str().to_str().unwrap())?;
|
||||||
|
|
||||||
context
|
context
|
||||||
.pip_sync()
|
.pip_sync()
|
||||||
.arg(requirements_txt.path())
|
.arg(requirements_txt.path())
|
||||||
|
@ -232,15 +236,15 @@ fn uninstall_by_path() -> Result<()> {
|
||||||
|
|
||||||
// Uninstall the editable by path.
|
// Uninstall the editable by path.
|
||||||
uv_snapshot!(context.filters(), context.pip_uninstall()
|
uv_snapshot!(context.filters(), context.pip_uninstall()
|
||||||
.arg(context.workspace_root.join("scripts/packages/poetry_editable")), @r###"
|
.arg(poetry_editable.as_os_str()), @r"
|
||||||
success: true
|
success: true
|
||||||
exit_code: 0
|
exit_code: 0
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
|
||||||
----- stderr -----
|
----- stderr -----
|
||||||
Uninstalled 1 package in [TIME]
|
Uninstalled 1 package in [TIME]
|
||||||
- poetry-editable==0.1.0 (from file://[WORKSPACE]/scripts/packages/poetry_editable)
|
- poetry-editable==0.1.0 (from file://[TEMP_DIR]/poetry_editable)
|
||||||
"###
|
"
|
||||||
);
|
);
|
||||||
|
|
||||||
context.assert_command("import poetry_editable").failure();
|
context.assert_command("import poetry_editable").failure();
|
||||||
|
@ -252,17 +256,19 @@ fn uninstall_by_path() -> Result<()> {
|
||||||
#[cfg(feature = "pypi")]
|
#[cfg(feature = "pypi")]
|
||||||
fn uninstall_duplicate_by_path() -> Result<()> {
|
fn uninstall_duplicate_by_path() -> Result<()> {
|
||||||
let context = TestContext::new("3.12");
|
let context = TestContext::new("3.12");
|
||||||
|
let poetry_editable = context.temp_dir.child("packages").child("poetry_editable");
|
||||||
|
|
||||||
let requirements_txt = context.temp_dir.child("requirements.txt");
|
// Copy into the temporary directory.
|
||||||
requirements_txt.write_str(
|
copy_dir_all(
|
||||||
context
|
context
|
||||||
.workspace_root
|
.workspace_root
|
||||||
.join("scripts/packages/poetry_editable")
|
.join("scripts/packages/poetry_editable"),
|
||||||
.as_os_str()
|
&poetry_editable,
|
||||||
.to_str()
|
|
||||||
.expect("Path is valid unicode"),
|
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
let requirements_txt = context.temp_dir.child("requirements.txt");
|
||||||
|
requirements_txt.write_str(poetry_editable.as_os_str().to_str().unwrap())?;
|
||||||
|
|
||||||
context
|
context
|
||||||
.pip_sync()
|
.pip_sync()
|
||||||
.arg(requirements_txt.path())
|
.arg(requirements_txt.path())
|
||||||
|
@ -274,15 +280,15 @@ fn uninstall_duplicate_by_path() -> Result<()> {
|
||||||
// Uninstall the editable by both path and name.
|
// Uninstall the editable by both path and name.
|
||||||
uv_snapshot!(context.filters(), context.pip_uninstall()
|
uv_snapshot!(context.filters(), context.pip_uninstall()
|
||||||
.arg("poetry-editable")
|
.arg("poetry-editable")
|
||||||
.arg(context.workspace_root.join("scripts/packages/poetry_editable")), @r###"
|
.arg(poetry_editable.as_os_str()), @r"
|
||||||
success: true
|
success: true
|
||||||
exit_code: 0
|
exit_code: 0
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
|
||||||
----- stderr -----
|
----- stderr -----
|
||||||
Uninstalled 1 package in [TIME]
|
Uninstalled 1 package in [TIME]
|
||||||
- poetry-editable==0.1.0 (from file://[WORKSPACE]/scripts/packages/poetry_editable)
|
- poetry-editable==0.1.0 (from file://[TEMP_DIR]/poetry_editable)
|
||||||
"###
|
"
|
||||||
);
|
);
|
||||||
|
|
||||||
context.assert_command("import poetry_editable").failure();
|
context.assert_command("import poetry_editable").failure();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue