From 653def05f0c9c40b0ab07fecdb178ec8a075a61c Mon Sep 17 00:00:00 2001 From: Thomas O'Donnell Date: Sun, 15 Sep 2019 18:21:40 +0200 Subject: [PATCH] Enable the python module for tox files (#369) Enable the python module if the current directory contains a `tox.ini` file. --- docs/config/README.md | 1 + src/modules/python.rs | 2 ++ tests/testsuite/python.rs | 17 +++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/docs/config/README.md b/docs/config/README.md index 0928779c..08ee6d44 100644 --- a/docs/config/README.md +++ b/docs/config/README.md @@ -568,6 +568,7 @@ The module will be shown if any of the following conditions are met: - The current directory contains a `pyproject.toml` file - The current directory contains a file with the `.py` extension - The current directory contains a `Pipfile` file +- The current directory contains a `tox.ini` file ### Options diff --git a/src/modules/python.rs b/src/modules/python.rs index 84ca0e7e..b871ef80 100644 --- a/src/modules/python.rs +++ b/src/modules/python.rs @@ -14,6 +14,7 @@ use super::{Context, Module}; /// - Current directory contains a `pyproject.toml` file /// - Current directory contains a file with the `.py` extension /// - Current directory contains a `Pipfile` file +/// - Current directory contains a `tox.ini` file pub fn module<'a>(context: &'a Context) -> Option> { let is_py_project = context .try_begin_scan()? @@ -22,6 +23,7 @@ pub fn module<'a>(context: &'a Context) -> Option> { ".python-version", "pyproject.toml", "Pipfile", + "tox.ini", ]) .set_extensions(&["py"]) .is_match(); diff --git a/tests/testsuite/python.rs b/tests/testsuite/python.rs index e978baba..eba959ce 100644 --- a/tests/testsuite/python.rs +++ b/tests/testsuite/python.rs @@ -73,6 +73,23 @@ fn folder_with_pipfile() -> io::Result<()> { Ok(()) } +#[test] +#[ignore] +fn folder_with_tox() -> io::Result<()> { + let dir = common::new_tempdir()?; + File::create(dir.path().join("tox.ini"))?; + + 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.6.9")); + assert_eq!(expected, actual); + Ok(()) +} + #[test] #[ignore] fn folder_with_py_file() -> io::Result<()> {