Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make duration_seconds optional #46

Merged
merged 6 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/junit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| Some(t.parse().unwrap()));

let mut t = Testrun {
name,
Expand Down
18 changes: 9 additions & 9 deletions src/testrun.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
#[pyo3(get, set)]
pub classname: String,
#[pyo3(get, set)]
pub duration: f64,
pub duration: Option<f64>,
#[pyo3(get, set)]
pub outcome: Outcome,
#[pyo3(get, set)]
Expand Down Expand Up @@ -139,7 +139,7 @@
fn new(
name: String,
classname: String,
duration: f64,
duration: Option<f64>,
outcome: Outcome,
testsuite: String,
failure_message: Option<String>,
Expand All @@ -162,7 +162,7 @@

fn __repr__(&self) -> String {
format!(
"({}, {}, {}, {}, {}, {:?}, {:?}, {:?})",
"({}, {}, {}, {:?}, {}, {:?}, {:?}, {:?})",

Check warning on line 165 in src/testrun.rs

View check run for this annotation

Codecov Notifications / codecov/patch

src/testrun.rs#L165

Added line #L165 was not covered by tests
self.name,
self.classname,
self.outcome,
Expand Down Expand Up @@ -276,7 +276,7 @@
let t = Testrun {
classname: "".to_string(),
name: "".to_string(),
duration: 0.0,
duration: None,
outcome: Outcome::Pass,
testsuite: "pytest".to_string(),
failure_message: None,
Expand All @@ -292,7 +292,7 @@
let t = Testrun {
classname: "".to_string(),
name: "".to_string(),
duration: 0.0,
duration: None,
outcome: Outcome::Pass,
testsuite: "".to_string(),
failure_message: None,
Expand All @@ -308,7 +308,7 @@
let t = Testrun {
classname: ".py".to_string(),
name: "".to_string(),
duration: 0.0,
duration: None,
outcome: Outcome::Pass,
testsuite: "".to_string(),
failure_message: None,
Expand All @@ -324,7 +324,7 @@
let t = Testrun {
classname: "".to_string(),
name: ".py".to_string(),
duration: 0.0,
duration: None,
outcome: Outcome::Pass,
testsuite: "".to_string(),
failure_message: None,
Expand All @@ -340,7 +340,7 @@
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()),
Expand All @@ -356,7 +356,7 @@
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()),
Expand Down
22 changes: 22 additions & 0 deletions tests/no-time.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="/file1.xml" tests="2"
assertions="2" errors="0" failures="0" skipped="0">
<testsuite name="Thing"
file="/file1.php"
tests="2" assertions="2" errors="0" failures="0" skipped="0">
<testcase
name="test1"
file="/file1.php"
line="1"
classname="class.className" assertions="1"
/>
<testcase
name="test2"
file="/file1.php"
line="2"
assertions="1"
/>
</testsuite>
</testsuite>
</testsuites>
7 changes: 7 additions & 0 deletions tests/test_junit.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,13 @@ def test_junit(self, filename, expected, check):
],
),
),
(
"./tests/testsuites.xml",
ParsingInfo(
None,
[],
),
),
],
)
def test_junit(self, filename, expected):
Expand Down
1 change: 1 addition & 0 deletions tests/testsuites.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<testsuites name="empty_testsuites" tests="0" failures="0" />
Loading