# Path: pywr/core.py



from pywr.core import Component, Model, ModelStructureError
from collections import defaultdict
from fixtures import simple_linear_model
import pytest
    for c in m.components:
        assert c.func_counts["setup"] == 1
        assert c.func_counts["reset"] == 1
        assert c.func_counts["before"] == nt
        assert c.func_counts["after"] == nt
        assert c.func_counts["finish"] == 1

    # Simulate a change and re-run.
    m.setup()
    m.run()

    assert len(m.components) == 3

    for c in m.components:
        assert c.func_counts["setup"] == 2
        assert c.func_counts["reset"] == 3
        assert c.func_counts["before"] == 2 * nt
        assert c.func_counts["after"] == 2 * nt
        assert c.func_counts["finish"] == 2


def test_circular_components_error(simple_linear_model):
    """Test that circular components raise an error"""
    m = simple_linear_model
    c1 = DummyComponent(m)
    c2 = DummyComponent(m)

    c1.parents.add(c2)
    c2.parents.add(c1)


# Path: pywr/core.py



# Path: tests/test_components.py
from pywr.core import Component, Model, ModelStructureError
from collections import defaultdict
from fixtures import simple_linear_model
import pytest

    for c in m.components:
        assert c.func_counts["setup"] == 1
        assert c.func_counts["reset"] == 1
        assert c.func_counts["before"] == nt
        assert c.func_counts["after"] == nt
        assert c.func_counts["finish"] == 1

    # Simulate a change and re-run.
    m.setup()
    m.run()

    assert len(m.components) == 3

    for c in m.components:
        assert c.func_counts["setup"] == 2
        assert c.func_counts["reset"] == 3
        assert c.func_counts["before"] == 2 * nt
        assert c.func_counts["after"] == 2 * nt
        assert c.func_counts["finish"] == 2


def test_circular_components_error(simple_linear_model):
    """Test that circular components raise an error"""
    m = simple_linear_model
    c1 = DummyComponent(m)
    c2 = DummyComponent(m)

    c1.parents.add(c2)
    c2.parents.add(c1)


    with pytest.raises(ModelStructureError):