diff --git a/src/junit.rs b/src/junit.rs index 38935dd..1610d8b 100644 --- a/src/junit.rs +++ b/src/junit.rs @@ -63,8 +63,7 @@ fn populate( .time .as_deref() .or(testsuite_time) - .ok_or_else(|| ParserError::new_err("No time/duration found"))? - .parse()?; + .and_then(|t| t.parse().ok()); let mut t = Testrun { name, diff --git a/src/testrun.rs b/src/testrun.rs index f7c2a7b..14a74db 100644 --- a/src/testrun.rs +++ b/src/testrun.rs @@ -85,7 +85,7 @@ pub struct Testrun { #[pyo3(get, set)] pub classname: String, #[pyo3(get, set)] - pub duration: f64, + pub duration: Option, #[pyo3(get, set)] pub outcome: Outcome, #[pyo3(get, set)] @@ -139,7 +139,7 @@ impl Testrun { fn new( name: String, classname: String, - duration: f64, + duration: Option, outcome: Outcome, testsuite: String, failure_message: Option, @@ -162,7 +162,7 @@ impl Testrun { fn __repr__(&self) -> String { format!( - "({}, {}, {}, {}, {}, {:?}, {:?}, {:?})", + "({}, {}, {}, {:?}, {}, {:?}, {:?}, {:?})", self.name, self.classname, self.outcome, @@ -276,7 +276,7 @@ mod tests { let t = Testrun { classname: "".to_string(), name: "".to_string(), - duration: 0.0, + duration: None, outcome: Outcome::Pass, testsuite: "pytest".to_string(), failure_message: None, @@ -292,7 +292,7 @@ mod tests { let t = Testrun { classname: "".to_string(), name: "".to_string(), - duration: 0.0, + duration: None, outcome: Outcome::Pass, testsuite: "".to_string(), failure_message: None, @@ -308,7 +308,7 @@ mod tests { let t = Testrun { classname: ".py".to_string(), name: "".to_string(), - duration: 0.0, + duration: None, outcome: Outcome::Pass, testsuite: "".to_string(), failure_message: None, @@ -324,7 +324,7 @@ mod tests { let t = Testrun { classname: "".to_string(), name: ".py".to_string(), - duration: 0.0, + duration: None, outcome: Outcome::Pass, testsuite: "".to_string(), failure_message: None, @@ -340,7 +340,7 @@ mod tests { let t = Testrun { classname: "".to_string(), name: "".to_string(), - duration: 0.0, + duration: None, outcome: Outcome::Pass, testsuite: "".to_string(), failure_message: Some(".py".to_string()), @@ -356,7 +356,7 @@ mod tests { let t = Testrun { classname: "".to_string(), name: "".to_string(), - duration: 0.0, + duration: None, outcome: Outcome::Pass, testsuite: "".to_string(), failure_message: Some(".py".to_string()), diff --git a/tests/no-time.xml b/tests/no-time.xml new file mode 100644 index 0000000..1d9f332 --- /dev/null +++ b/tests/no-time.xml @@ -0,0 +1,22 @@ + + + + + + + + + \ No newline at end of file diff --git a/tests/test_junit.py b/tests/test_junit.py index 63a9de3..64152cd 100644 --- a/tests/test_junit.py +++ b/tests/test_junit.py @@ -276,6 +276,13 @@ def test_junit(self, filename, expected, check): ], ), ), + ( + "./tests/testsuites.xml", + ParsingInfo( + None, + [], + ), + ), ], ) def test_junit(self, filename, expected): diff --git a/tests/testsuites.xml b/tests/testsuites.xml new file mode 100644 index 0000000..2823732 --- /dev/null +++ b/tests/testsuites.xml @@ -0,0 +1 @@ + \ No newline at end of file