Skip to content

Commit

Permalink
more testing
Browse files Browse the repository at this point in the history
  • Loading branch information
rhayes777 committed Mar 6, 2023
1 parent ad4f0eb commit 2f0d3da
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions test_autofit/mapper/model/test_model_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,20 +170,36 @@ class Child(af.Gaussian):
pass


@pytest.fixture(name="instance")
def make_instance():
return af.ModelInstance({"child": Child(), "gaussian": af.Gaussian()})
class Child2(af.Gaussian):
pass


@pytest.fixture(name="exclude_instance")
def make_excluded_instance():
return af.ModelInstance(
{"child": Child(), "gaussian": af.Gaussian(), "child2": Child2(),}
)

def test_single_argument(instance):
model = instance.as_model(af.Gaussian)

def test_single_argument(exclude_instance):
model = exclude_instance.as_model(af.Gaussian)

assert isinstance(model.gaussian, af.Model)
assert isinstance(model.child, af.Model)
assert isinstance(model.child2, af.Model)


def test_filter_child(exclude_instance):
model = exclude_instance.as_model(af.Gaussian, excluded_classes=Child)

assert isinstance(model.gaussian, af.Model)
assert not isinstance(model.child, af.Model)
assert isinstance(model.child2, af.Model)


def test_filter_child(instance):
model = instance.as_model(af.Gaussian, excluded_classes=Child)
def test_filter_multiple(exclude_instance):
model = exclude_instance.as_model(af.Gaussian, excluded_classes=(Child, Child2),)

assert isinstance(model.gaussian, af.Model)
assert not isinstance(model.child, af.Model)
assert not isinstance(model.child2, af.Model)

0 comments on commit 2f0d3da

Please sign in to comment.