Skip to content

Commit

Permalink
tests/subclass: Add pickling test
Browse files Browse the repository at this point in the history
See #147
  • Loading branch information
nbraud committed Apr 15, 2019
1 parent b82c907 commit d72cc51
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/test_subclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ def test_subclass_copy(v: Vector2, label_v: str):
assert w.label == label_v


@given(v=vectors(), label_v=st.text())
def test_ctor_pickle(v: Vector2, label_v: str):
"""Round-trip instances of the subclass through `pickle.{dumps,loads}`."""
import pickle
v = LabeledVector(*v, label_v) # type: ignore
w = pickle.loads(pickle.dumps(v))

assert v == w
assert isinstance(w, LabeledVector)


@pytest.mark.parametrize("op", BINARY_OPS)
@given(v=vectors(), label_v=st.text(), w=units(), label_w=st.text())
def test_subclass_binops_both(op, v: Vector2, label_v: str, w: Vector2, label_w: str):
Expand Down

0 comments on commit d72cc51

Please sign in to comment.