• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Bear Bibeault
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Jj Roberts

Tiny Python Projects: PyTest testing framework, why not others?

 
Ranch Hand
Posts: 66
1
Redhat Notepad Fedora Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ken,

I like the idea that your book Tiny Python Projects isn't for absolute beginning programmer - but it's targeting people who’s been trying to learn to code well, but aren't quite sure how to level up and that you must work sequentially through your material while adding more and more complexity. It almost feels like the Learn X in month of lunches series from Manning for slightly advanced Python 3 developers.

My question is - what was the reasoning behind choosing PyTest testing framework and not for example:

Many thanks!
 
Author
Posts: 9
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pytest was most similar to testing frameworks I knew from Perl. I simply found it to be the most immediately useful and easy to learn. I also avoid object-oriented programming, and unittest seemed more amenable to OOP libraries. I used pytest in the classroom with beginner students, and they seemed to have no problem picking up the basic ideas. The output from pytest when tests fail is pretty great, so it just seemed like the easiest path. There certainly are many other great testing libraries, and pytest can integrate with them (such as unittest). TL;DR: pytest is pretty simple and effective.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We are using pytest at work.

We first used it to test a software developer kit we sell. We looked at both pytest and unittest. I liked how pytest got things done without extra code you had to type (or probably mostly copy and paste) that essentially did nothing but make what you wrote into a class in unittest.

Pytest is powerful and felt more like you were writing Python code and not porting C++ code over to Python.

I didn't evaluate any other unit test frameworks, although I did Google a few others, but none seemed as popular as pytest, and I wanted to be able to find plenty of examples and tutorials to make learning Python + pytest easy.

I'd be interested in comments from anyone about why they picked a different testing framework.
 
Lucian Maly
Ranch Hand
Posts: 66
1
Redhat Notepad Fedora Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ken Youens-Clark wrote:Pytest was most similar to testing frameworks I knew from Perl. I simply found it to be the most immediately useful and easy to learn. I also avoid object-oriented programming, and unittest seemed more amenable to OOP libraries. I used pytest in the classroom with beginner students, and they seemed to have no problem picking up the basic ideas. The output from pytest when tests fail is pretty great, so it just seemed like the easiest path. There certainly are many other great testing libraries, and pytest can integrate with them (such as unittest). TL;DR: pytest is pretty simple and effective.



I very much agree with you - PyTest is also my go to framework for most use cases, and I understand why you as a teacher decided to introduce it to the beginner students and in the book. However, I think for web-related use cases (mock requests), PyTest does not play well with function decorators that add positional arguments to the test functions and I would probably use something else in that case (nose2 + requests).

Thank you very much for the response.
 
reply
    Bookmark Topic Watch Topic
  • New Topic