Tuesday, July 20, 2021

Go's "defer" in pytest (and Python)

 I'm writing a lot of Go & Python these days, and both affect the way I write code.

One feature I really like in Go is defer. Lately, after writing some complicated pytest fixtures, I tried to make simpler and use a "defer" like fixture. Here's what I came with:

Out of the context of pytest, the same idea can become a context manager:


Update: I've published pytest-defer to PyPI.

3 comments:

  1. Thanks for sharing this blog. It was impressive and knowledgeable. Keep sharing more with us.
    Python Course with Placements in Hyderabad

    ReplyDelete
  2. I appreciate you sharing this blog. It was skillful and amazing. Oracle Fusion Financials Online Training

    ReplyDelete

  3. Thank you for sharing such a nice and interesting blog and really very helpful article. If you want to become Oracle Fusion SCM Certified Consultant, attend this Best Oracle Fusion SCM Online Training Course offered by the Unogeeks

    ReplyDelete