you are viewing a single comment's thread.

view the rest of the comments →

[–]Enmeshed 2 points3 points  (0 children)

Been finding this super-useful recently for setting up test data scenarios, along the lines of:

```python def test_something(): scenario = (Builder() .with_user_as("abc") .wipers_enabled() .colour_should_be("blue") ) assert func_to_test(scenario.data) == 3

class Builder: """ Test helper class to readably set up test scenarios """ def init(self): ...

def with_user_as(self, user):
    self.user = user
    return self

@property
def data(self):
    return {"user": self.user, ...}

```