diff --git a/pcontract/data.py b/pcontract/data.py index d0bbf94..309ecd6 100644 --- a/pcontract/data.py +++ b/pcontract/data.py @@ -111,7 +111,7 @@ def __getitem__(self, item: int) -> Branch: def init( cls, *, - start_at: datetime | None, + start_at: datetime | None = None, end_at: datetime, data: dict[str, Any], meta: dict[str, Any] | None = None, diff --git a/tests.py b/tests.py index deb2c27..3ede373 100644 --- a/tests.py +++ b/tests.py @@ -241,3 +241,14 @@ def test_contract_init_spans_nothing(self): end_at=self.start - datetime.timedelta(days=1), data={"key": "venus"}, ) + + def test_contract_init_without_start_date(self): + delta = datetime.timedelta(hours=1) + contract = Contract.init(data={}, end_at=datetime.datetime.now(tz=utc) + delta) + (branch,) = contract.items + # get away from adding freezegun + self.assertAlmostEqual( + delta.total_seconds(), + branch.span.total_seconds(), + places=5, + )