Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Testing in Python

 
David DeCesare
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Coming from the Java world, I've grown used to having solid testing frameworks such as JUnit and TestNG. Does Python have similar testing frameworks? I just starting taking a Python course at Coursera and I didn't see any mentions of testing frameworks in that class. I'm starting to learn Python to help with scripting Linux deployments. Another popular language for that work is Ruby which has a very strong testing background.

Thank you,
David
 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Python has a unittest module: http://docs.python.org/library/unittest.html
 
David DeCesare
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Steve! Reading through that site, it looks very similar to the Java testing tools (which is great). Just out of curiosity, based on your experience is testing in Python viewed as important as it is in the Ruby community? I apologize for the newbie questions but I just started with Python :-).

Thanks again,
Dave
 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My experience is probably not the best in this case. I use Python as a scripting add-in to another application. Scripts tend to be short and targeted, and not well tested (but really not have many failure points either). I have used the unittest module a bit but I think of those I work with I am in the minority.

If you are writing a large project or stand-alone application then I think the need to unit test your application is the same as any other language.
 
Palak Mathur
Ranch Hand
Posts: 342
IntelliJ IDE Java Spring
 
Allen Downey
Author
Greenhorn
Posts: 28
Java Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use PyUnit and I think it is very good, but I have to admit that testing and test-driven design might not be as ingrained in the Python programmer culture as it is in others.

But as Python is applied to bigger projects, and used in environments with better software engineering practices, I would expect that to change (maybe it already is).

Allen
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic