mirror of
https://github.com/starship/starship.git
synced 2026-06-23 02:05:51 +07:00
feat(python): Add scan_for_pyfiles option (#692)
Also adds two new entries to the list of hardcoded files to check: setup.py and __init__.py.
This commit is contained in:
@@ -4,7 +4,7 @@ use std::io;
|
||||
use ansi_term::Color;
|
||||
use tempfile;
|
||||
|
||||
use crate::common;
|
||||
use crate::common::{self, TestCommand};
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
@@ -91,6 +91,40 @@ fn folder_with_tox() -> io::Result<()> {
|
||||
dir.close()
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn folder_with_setup_py() -> io::Result<()> {
|
||||
let dir = tempfile::tempdir()?;
|
||||
File::create(dir.path().join("setup.py"))?.sync_all()?;
|
||||
|
||||
let output = common::render_module("python")
|
||||
.arg("--path")
|
||||
.arg(dir.path())
|
||||
.output()?;
|
||||
let actual = String::from_utf8(output.stdout).unwrap();
|
||||
|
||||
let expected = format!("via {} ", Color::Yellow.bold().paint("🐍 v3.7.5"));
|
||||
assert_eq!(expected, actual);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn folder_with_init_py() -> io::Result<()> {
|
||||
let dir = tempfile::tempdir()?;
|
||||
File::create(dir.path().join("__init__.py"))?.sync_all()?;
|
||||
|
||||
let output = common::render_module("python")
|
||||
.arg("--path")
|
||||
.arg(dir.path())
|
||||
.output()?;
|
||||
let actual = String::from_utf8(output.stdout).unwrap();
|
||||
|
||||
let expected = format!("via {} ", Color::Yellow.bold().paint("🐍 v3.7.5"));
|
||||
assert_eq!(expected, actual);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn folder_with_py_file() -> io::Result<()> {
|
||||
@@ -141,3 +175,44 @@ fn with_active_venv() -> io::Result<()> {
|
||||
assert_eq!(expected, actual);
|
||||
dir.close()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn disabled_scan_for_pyfiles_and_folder_with_ignored_py_file() -> io::Result<()> {
|
||||
let dir = tempfile::tempdir()?;
|
||||
File::create(dir.path().join("foo.py"))?.sync_all()?;
|
||||
|
||||
let output = common::render_module("python")
|
||||
.use_config(toml::toml! {
|
||||
[python]
|
||||
scan_for_pyfiles = false
|
||||
})
|
||||
.arg("--path")
|
||||
.arg(dir.path())
|
||||
.output()?;
|
||||
let actual = String::from_utf8(output.stdout).unwrap();
|
||||
|
||||
let expected = "";
|
||||
assert_eq!(expected, actual);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn disabled_scan_for_pyfiles_and_folder_with_setup_py() -> io::Result<()> {
|
||||
let dir = tempfile::tempdir()?;
|
||||
File::create(dir.path().join("setup.py"))?.sync_all()?;
|
||||
|
||||
let output = common::render_module("python")
|
||||
.use_config(toml::toml! {
|
||||
[python]
|
||||
scan_for_pyfiles = false
|
||||
})
|
||||
.arg("--path")
|
||||
.arg(dir.path())
|
||||
.output()?;
|
||||
let actual = String::from_utf8(output.stdout).unwrap();
|
||||
|
||||
let expected = format!("via {} ", Color::Yellow.bold().paint("🐍 v3.7.5"));
|
||||
assert_eq!(expected, actual);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user