Writing tests in Rust for a python extension #2733
-
Hi, Apologies for what may be a reposted question. although I had a cursory look and could not find anything. I am sure that when I was reading the docs.rs, I saw an example of how to write rust tests for your python extension, using something loosely along the lines of Python::with_GIL(py || {
_example test_
}) However I cannot for the life of me find it again. I was wondering if there was any standard way of writing these tests? Thanks for the brilliant crate! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, sorry for the slow reply. You can indeed write tests from Rust, you should make sure to disable the For some examples, see our tests we have internally for string conversions: pyo3/src/conversions/std/string.rs Lines 149 to 164 in 23fcdf9 |
Beta Was this translation helpful? Give feedback.
Hi, sorry for the slow reply.
You can indeed write tests from Rust, you should make sure to disable the
extension-module
feature and instead enable theauto-initialize
feature while running tests.For some examples, see our tests we have internally for string conversions:
pyo3/src/conversions/std/string.rs
Lines 149 to 164 in 23fcdf9