diff --git a/Cargo.toml b/Cargo.toml index 1dde61d..0f74e5d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "epyxid" +version = "0.3.2" edition = "2021" -version = "0.3.1" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] diff --git a/epyxid.pyi b/epyxid.pyi index 148638f..d2e513c 100644 --- a/epyxid.pyi +++ b/epyxid.pyi @@ -4,6 +4,10 @@ from typing import Optional, Union __version__: str +class XIDError(ValueError): + pass + + class XID: """ Globally unique sortable id. diff --git a/pyproject.toml b/pyproject.toml index d7cb4aa..635efbe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ requires-python = ">=3.8" authors = [ {name = "Aleksandr Shpak", email = "shpaker@gmail.com"}, ] -version = "0.3.1" +version = "0.3.2" readme = "README.md" license = { file = "LICENSE.txt" } keywords = [ diff --git a/src/errors.rs b/src/errors.rs index 7f74308..4646a81 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -1,4 +1,4 @@ use pyo3::create_exception; use pyo3::exceptions::PyValueError; -create_exception!(mymodule, XIDError, PyValueError); +create_exception!(epyxid, XIDError, PyValueError); diff --git a/src/lib.rs b/src/lib.rs index 90cc8be..c5ee560 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,7 +8,7 @@ use crate::errors::XIDError; use crate::utils::{xid_create, xid_from_bytes, xid_from_str}; use crate::wrapper::XID; -const PY_MODULE_VERSION: &str = "0.3.0"; +const PY_MODULE_VERSION: &str = "0.3.2"; mod errors; mod utils; diff --git a/test_xid.py b/test_xid.py index 40c8f49..3cd1ca3 100644 --- a/test_xid.py +++ b/test_xid.py @@ -1,6 +1,7 @@ from typing import Union, Optional -from epyxid import xid_from_bytes, xid_from_str, xid_create, XID +from epyxid import xid_from_bytes, xid_create, XID, XIDError, xid_from_str + from pytest import raises, param, mark XID_STR = '9m4e2mr0ui3e8a215n4g' @@ -30,11 +31,16 @@ def test_create_cls_param(value: Optional[Union[str, bytes]], ) -> None: assert xid is not None -def test_create_cls_error() -> None: +def test_create_cls_type_error() -> None: with raises(TypeError): xid = XID(42) +def test_create_cls_xid_error() -> None: + with raises(XIDError): + xid = XID('42') + + def test_from_str_valid() -> None: xid = xid_from_str(XID_STR) assert bytes(xid) == XID_BYTES