diff options
author | Peter Bull <pjbull@gmail.com> | 2020-01-21 08:14:40 -0800 |
---|---|---|
committer | Matan Kushner <hello@matchai.dev> | 2020-01-21 11:14:40 -0500 |
commit | b723a7d562474a890ef235cc04722b3ebbe516a6 (patch) | |
tree | 5d7996daa95ad17e26968bd88246e8da75690644 /src/modules/python.rs | |
parent | 57427b5d7aab995c8de2ddca9ec4bcea418b5dbc (diff) |
fix(python): Trim "Anaconda, Inc." from version (#861)
Diffstat (limited to 'src/modules/python.rs')
-rw-r--r-- | src/modules/python.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/modules/python.rs b/src/modules/python.rs index 366fd68b5..2668589b7 100644 --- a/src/modules/python.rs +++ b/src/modules/python.rs @@ -73,7 +73,13 @@ fn get_python_version() -> Option<String> { } fn format_python_version(python_stdout: &str) -> String { - format!("v{}", python_stdout.trim_start_matches("Python ").trim()) + format!( + "v{}", + python_stdout + .trim_start_matches("Python ") + .trim_end_matches(":: Anaconda, Inc.") + .trim() + ) } fn get_python_virtual_env() -> Option<String> { @@ -93,4 +99,10 @@ mod tests { let input = "Python 3.7.2"; assert_eq!(format_python_version(input), "v3.7.2"); } + + #[test] + fn test_format_python_version_anaconda() { + let input = "Python 3.6.10 :: Anaconda, Inc."; + assert_eq!(format_python_version(input), "v3.6.10"); + } } |