# Writing tests with pytest!

**URL:** <https://discourse.beets.io/t/writing-tests-with-pytest/1435>\
**Category:** Development\
**Created:** [July 28, 2020, 3:34pm UTC](https://discourse.beets.io/t/writing-tests-with-pytest/1435 "2020-07-28T15:34:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jtpavlock](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/jtpavlock/32/443_2.png) [@jtpavlock](https://discourse.beets.io/u/jtpavlock)\
**Post date:** [July 28, 2020, 3:34pm UTC](https://discourse.beets.io/t/writing-tests-with-pytest/1435/1 "2020-07-28T15:34:33Z")

</div>

So, we now have [pytest](https://docs.pytest.org/en/stable/) as a test runner, but what about using it to write tests too?

I’ve seen the sentiments [presented here](https://github.com/beetbox/beets/issues/1483) that perhaps we don’t want to couple too closely to pytest, however that was now over 5 years ago and in that time pytest has grown to be well established and the often preferred test framework due to it’s simplicity.

[Even python core devs prefer pytest!](https://www.youtube.com/watch?v=ARKbfWk4Xyw&feature=youtu.be&t=797)

[Also, maybe Guido himself](https://twitter.com/gvanrossum/status/1282175743493935104)

Transitions are easy since pytest supports both unittest and pytest (duh) tests. Anyways, are opinions still the same, or is it time to make testing a bit easier?

Quick anecdote: When I first got into testing with python, I also had to make the choice between using unittest and pytest. I tried both, and found pytest immensely more intuitive, so I stuck with that. Even today, I still find myself referring back to the unittest docs about how to do certain things and which assert\* call I need to make.

So, perhaps pytest can also ease the barrier for new guys trying to write tests.

---

<div class="post-metadata">

**Author:** ![adrian](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/adrian/32/4_2.png) [@adrian](https://discourse.beets.io/u/adrian)\
**Post date:** [July 29, 2020, 1:51am UTC](https://discourse.beets.io/t/writing-tests-with-pytest/1435/2 "2020-07-29T01:51:34Z")

</div>

I have no particular objection! I don’t mind using unittest directly personally, but if folks like pytest I don’t see any real downsides. It seems pretty convenient.
