Python: Dummy or Stub?

325 Views Asked by At

The question is about the classic topic of different test doubles. I only have some naming problems about this code snippet:

@pytest.fixture(autouse=True)
def setup(self):
    class DummyModel:
        id = "model_id"
        changes = {}

        def has_changed(self):
            return False

        def collect_changes(self, *args, **kwargs):
            return {}

    class DummyModelWithoutChanges:
        id = "model_id"

    class DummyModelWithPartner(DummyModel):
        partner_id = "partner id"

    self.dummy_instance = DummyModel()
    self.dummy_instance_without_changes = DummyModelWithoutChanges()
    self.dummy_instance_with_partner = DummyModelWithPartner()

Is this DummyModel actually a Dummy or more like a StubModel? It has functions that only return burnt in values (could be just attributed at this point), but a test looking for a method on a test double sounds more than just a dummy (Which is supposed to be a placeholder)

Maybe this example is too rudimentary but I'm trying to get a clear picture of the different naming conventions while using Python.

I reckon Stubs are always compared to Mocks (which are smart, behavioral stubs), but not with Dummies or Fakes.

0

There are 0 best solutions below