Skip to content

Commit 7df7a63

Browse files
committed
fix: from py obj impl for framework and outcome
1 parent f4f44a3 commit 7df7a63

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "test_results_parser"
3-
version = "0.5.4" # 0.5.4 release is a copy of 0.5.1 and diverges from main
3+
version = "0.5.4" # 0.5.4 release is a copy of 0.5.1 and diverges from main
44
edition = "2021"
55

66
[lib]
@@ -11,7 +11,7 @@ crate-type = ["cdylib", "rlib"]
1111
anyhow = "1.0.94"
1212
base16ct = { version = "0.2.0", features = ["std"] }
1313
indexmap = "2.6.0"
14-
pyo3 = { version = "0.24.1", features = ["abi3-py310", "anyhow"] }
14+
pyo3 = { version = "0.24.1", features = ["abi3-py39", "anyhow"] }
1515
quick-xml = "0.37.1"
1616
regex = "1.11.1"
1717
serde = { version = "1.0.215", features = ["derive"] }

src/testrun.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::borrow::Cow;
2+
13
use pyo3::prelude::*;
24
use pyo3::types::PyString;
35
use pyo3::{PyAny, PyResult};
@@ -59,8 +61,8 @@ impl<'py> IntoPyObject<'py> for Outcome {
5961

6062
impl<'py> FromPyObject<'py> for Outcome {
6163
fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult<Self> {
62-
let s = ob.extract::<&str>()?;
63-
match s {
64+
let s: String = ob.extract()?;
65+
match s.as_str() {
6466
"pass" => Ok(Outcome::Pass),
6567
"failure" => Ok(Outcome::Failure),
6668
"skip" => Ok(Outcome::Skip),
@@ -98,14 +100,14 @@ impl<'py> IntoPyObject<'py> for Framework {
98100

99101
impl<'py> FromPyObject<'py> for Framework {
100102
fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult<Self> {
101-
let s = ob.extract::<&str>()?;
102-
match s {
103+
let s: String = ob.extract()?;
104+
match s.as_str() {
103105
"Pytest" => Ok(Framework::Pytest),
104106
"Vitest" => Ok(Framework::Vitest),
105107
"Jest" => Ok(Framework::Jest),
106108
"PHPUnit" => Ok(Framework::PHPUnit),
107109
_ => Err(PyErr::new::<pyo3::exceptions::PyValueError, _>(format!(
108-
"Invalid outcome: {}",
110+
"Invalid framework: {}",
109111
s
110112
))),
111113
}

0 commit comments

Comments
 (0)