-
Notifications
You must be signed in to change notification settings - Fork 783
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2145 from davidhewitt/merge-pytests
pytests: merge benchmark and test crates
- Loading branch information
Showing
44 changed files
with
132 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,34 @@ | ||
# PyO3 Python tests | ||
# pyo3-pytests | ||
|
||
These crates are a collection of test extension modules built with PyO3. They are all tested using `nox` in PyO3's CI. | ||
An extension module built using PyO3, used to test and benchmark PyO3 from Python. | ||
|
||
Below is a brief description of each of these: | ||
## Testing | ||
|
||
| Example | Description | | ||
| ------- | ----------- | | ||
| `pyo3-benchmarks` | A project containing some benchmarks of PyO3 functionality called from Python. | | ||
| `pyo3-pytests` | A project containing some tests of PyO3 functionality called from Python. | | ||
This package is intended to be built using `maturin`. Once built, you can run the tests using `pytest`: | ||
|
||
```shell | ||
pip install maturin | ||
maturin develop | ||
pytest | ||
``` | ||
|
||
Alternatively, install nox and run the tests inside an isolated environment: | ||
|
||
```shell | ||
nox | ||
``` | ||
|
||
## Running benchmarks | ||
|
||
You can install the module in your Python environment and then run the benchmarks with pytest: | ||
|
||
```shell | ||
pip install . | ||
pytest --benchmark-enable | ||
``` | ||
|
||
Or with nox: | ||
|
||
```shell | ||
nox -s bench | ||
``` |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
hypothesis>=3.55 | ||
pytest>=6.0 | ||
pytest-benchmark>=3.4 | ||
psutil>=5.6 |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use pyo3::iter::IterNextOutput; | ||
use pyo3::prelude::*; | ||
|
||
#[pyclass] | ||
struct EmptyClass {} | ||
|
||
#[pymethods] | ||
impl EmptyClass { | ||
#[new] | ||
fn new() -> Self { | ||
EmptyClass {} | ||
} | ||
} | ||
|
||
/// This is for demonstrating how to return a value from __next__ | ||
#[pyclass] | ||
struct PyClassIter { | ||
count: usize, | ||
} | ||
|
||
#[pymethods] | ||
impl PyClassIter { | ||
#[new] | ||
pub fn new() -> Self { | ||
PyClassIter { count: 0 } | ||
} | ||
|
||
fn __next__(&mut self) -> IterNextOutput<usize, &'static str> { | ||
if self.count < 5 { | ||
self.count += 1; | ||
IterNextOutput::Yield(self.count) | ||
} else { | ||
IterNextOutput::Return("Ended") | ||
} | ||
} | ||
} | ||
|
||
#[pymodule] | ||
pub fn pyclasses(_py: Python<'_>, m: &PyModule) -> PyResult<()> { | ||
m.add_class::<EmptyClass>()?; | ||
m.add_class::<PyClassIter>()?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.