Skip to content

Commit 744a283

Browse files
committed
fix pytests for abi3 feature
1 parent 9d1a057 commit 744a283

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pytests/src/pyclasses.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,11 @@ impl AssertingBaseClass {
6666
#[pyclass]
6767
struct ClassWithoutConstructor;
6868

69+
#[cfg(any(Py_3_10, not(Py_LIMITED_API)))]
6970
#[pyclass(dict)]
7071
struct ClassWithDict;
7172

73+
#[cfg(any(Py_3_10, not(Py_LIMITED_API)))]
7274
#[pymethods]
7375
impl ClassWithDict {
7476
#[new]
@@ -83,6 +85,7 @@ pub fn pyclasses(m: &Bound<'_, PyModule>) -> PyResult<()> {
8385
m.add_class::<PyClassIter>()?;
8486
m.add_class::<AssertingBaseClass>()?;
8587
m.add_class::<ClassWithoutConstructor>()?;
88+
#[cfg(any(Py_3_10, not(Py_LIMITED_API)))]
8689
m.add_class::<ClassWithDict>()?;
8790

8891
Ok(())

pytests/tests/test_pyclasses.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,12 @@ def test_no_constructor_defined_propagates_cause(cls: Type):
8989

9090

9191
def test_dict():
92-
d = pyclasses.ClassWithDict()
92+
try:
93+
ClassWithDict = pyclasses.ClassWithDict
94+
except AttributeError:
95+
pytest.skip("not defined using abi3 < 3.9")
96+
97+
d = ClassWithDict()
9398
assert d.__dict__ == {}
9499

95100
d.foo = 42

0 commit comments

Comments
 (0)