February 2020

January 2020

  • Testing with pendulum

    My usual way of modifying the behaviour of pendulum.now() when testing has been to mock it:

    with mock.patch(
        "pendulum.now", return_value=pendulum.parse("2020-01-01 00:00:00")
    ):
      ...
    

    However, I did something mad today, and delved into the docs and found a neater way:

    with pendulum.test(pendulum.parse("2020-01-01 00:00:00")):