-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathutils.rs
38 lines (33 loc) · 799 Bytes
/
utils.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use anyhow::Result;
pub fn is_python_312_or_greater(version: &str) -> Result<bool> {
let mut split_version = version.split('.');
if let Some(v) = split_version.nth(1) {
let min = v.parse::<i32>()?;
if min >= 12 {
Ok(true)
} else {
Ok(false)
}
} else {
Ok(false)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_python_312() {
let result = is_python_312_or_greater("3.12").unwrap();
assert!(result);
}
#[test]
fn test_python_313() {
let result = is_python_312_or_greater("3.13").unwrap();
assert!(result);
}
#[test]
fn test_python_311() {
let result = is_python_312_or_greater("3.11").unwrap();
assert!(!result);
}
}