From 382db5b2e750acac62de0f707fe36d952461b074 Mon Sep 17 00:00:00 2001 From: Dean Moldovan Date: Sat, 13 Aug 2016 00:37:50 +0200 Subject: [PATCH] Move inheritance tests into the proper file --- tests/test_callbacks.py | 26 -------------------------- tests/test_inheritance.py | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/tests/test_callbacks.py b/tests/test_callbacks.py index 83bc01635..d6e72f333 100644 --- a/tests/test_callbacks.py +++ b/tests/test_callbacks.py @@ -1,32 +1,6 @@ import pytest -def test_inheritance(msg): - from pybind11_tests import Pet, Dog, Rabbit, dog_bark, pet_name_species - - roger = Rabbit('Rabbit') - assert roger.name() + " is a " + roger.species() == "Rabbit is a parrot" - assert pet_name_species(roger) == "Rabbit is a parrot" - - polly = Pet('Polly', 'parrot') - assert polly.name() + " is a " + polly.species() == "Polly is a parrot" - assert pet_name_species(polly) == "Polly is a parrot" - - molly = Dog('Molly') - assert molly.name() + " is a " + molly.species() == "Molly is a dog" - assert pet_name_species(molly) == "Molly is a dog" - - assert dog_bark(molly) == "Woof!" - - with pytest.raises(TypeError) as excinfo: - dog_bark(polly) - assert msg(excinfo.value) == """ - Incompatible function arguments. The following argument types are supported: - 1. (arg0: m.Dog) -> str - Invoked with: - """ - - def test_callbacks(): from functools import partial from pybind11_tests import (test_callback1, test_callback2, test_callback3, diff --git a/tests/test_inheritance.py b/tests/test_inheritance.py index a7a9778ca..b55490cf6 100644 --- a/tests/test_inheritance.py +++ b/tests/test_inheritance.py @@ -1,3 +1,30 @@ +import pytest + + +def test_inheritance(msg): + from pybind11_tests import Pet, Dog, Rabbit, dog_bark, pet_name_species + + roger = Rabbit('Rabbit') + assert roger.name() + " is a " + roger.species() == "Rabbit is a parrot" + assert pet_name_species(roger) == "Rabbit is a parrot" + + polly = Pet('Polly', 'parrot') + assert polly.name() + " is a " + polly.species() == "Polly is a parrot" + assert pet_name_species(polly) == "Polly is a parrot" + + molly = Dog('Molly') + assert molly.name() + " is a " + molly.species() == "Molly is a dog" + assert pet_name_species(molly) == "Molly is a dog" + + assert dog_bark(molly) == "Woof!" + + with pytest.raises(TypeError) as excinfo: + dog_bark(polly) + assert msg(excinfo.value) == """ + Incompatible function arguments. The following argument types are supported: + 1. (arg0: m.Dog) -> str + Invoked with: + """ def test_automatic_upcasting():