Conditional imports (#11823)

## Summary

Conditionally importing in tests to prevent unused imports warning in
cargo test windows in CI.
This commit is contained in:
Choudhry Abdullah 2025-02-27 03:08:37 -06:00 committed by GitHub
parent 7f4269ed08
commit f9c1684b96
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 6 deletions

View file

@ -1,7 +1,15 @@
#![allow(clippy::disallowed_types)]
#[cfg(feature = "git")]
mod conditional_imports {
pub(crate) use crate::common::{decode_token, READ_ONLY_GITHUB_TOKEN};
pub(crate) use assert_cmd::assert::OutputAssertExt;
}
#[cfg(feature = "git")]
use conditional_imports::*;
use anyhow::Result;
use assert_cmd::assert::OutputAssertExt;
use assert_fs::prelude::*;
use indoc::{formatdoc, indoc};
use insta::assert_snapshot;
@ -10,7 +18,7 @@ use uv_fs::Simplified;
use uv_static::EnvVars;
use crate::common::{self, decode_token, packse_index_url, uv_snapshot, TestContext};
use crate::common::{packse_index_url, uv_snapshot, TestContext};
/// Add a PyPI requirement.
#[test]
@ -322,7 +330,7 @@ fn add_git() -> Result<()> {
#[cfg(feature = "git")]
fn add_git_private_source() -> Result<()> {
let context = TestContext::new("3.12");
let token = decode_token(common::READ_ONLY_GITHUB_TOKEN);
let token = decode_token(READ_ONLY_GITHUB_TOKEN);
let pyproject_toml = context.temp_dir.child("pyproject.toml");
pyproject_toml.write_str(indoc! {r#"
@ -427,7 +435,7 @@ fn add_git_private_source() -> Result<()> {
#[cfg(feature = "git")]
fn add_git_private_raw() -> Result<()> {
let context = TestContext::new("3.12");
let token = decode_token(common::READ_ONLY_GITHUB_TOKEN);
let token = decode_token(READ_ONLY_GITHUB_TOKEN);
let pyproject_toml = context.temp_dir.child("pyproject.toml");
pyproject_toml.write_str(indoc! {r#"

View file

@ -11,9 +11,11 @@ use indoc::indoc;
use predicates::prelude::predicate;
use url::Url;
#[cfg(feature = "git")]
use crate::common::{self, decode_token};
use crate::common::{
self, build_vendor_links_url, decode_token, get_bin, uv_snapshot, venv_bin_path,
venv_to_interpreter, TestContext,
build_vendor_links_url, get_bin, uv_snapshot, venv_bin_path, venv_to_interpreter, TestContext,
};
use uv_fs::Simplified;
use uv_static::EnvVars;