Skip to content

Commit

Permalink
Merge pull request #8 from sirosen/add-regresserr
Browse files Browse the repository at this point in the history
Add "RegressError" to the "regress" module
  • Loading branch information
Julian authored Aug 16, 2023
2 parents 844099e + 384c27e commit 2f7eeb4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ impl MatchPy {

#[pymodule]
#[pyo3(name = "regress")]
fn regress_py(_py: Python, m: &PyModule) -> PyResult<()> {
fn regress_py(py: Python, m: &PyModule) -> PyResult<()> {
m.add_class::<MatchPy>()?;
m.add_class::<RegexPy>()?;
m.add("RegressError", py.get_type::<RegressError>())?;
Ok(())
}

Expand Down
9 changes: 9 additions & 0 deletions tests/test_regress.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,12 @@ def test_named_group():
assert group

assert text[group] == "fox"


def test_error_handling():
try:
regress.Regex(r"(")
except regress.RegressError:
pass
else:
assert False, "error not reached"

0 comments on commit 2f7eeb4

Please sign in to comment.