Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
The Python Apprentice

You're reading from   The Python Apprentice Introduction to the Python Programming Language

Arrow left icon
Product type Paperback
Published in Jun 2017
Publisher Packt
ISBN-13 9781788293181
Length 352 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Austin Bingham Austin Bingham
Author Profile Icon Austin Bingham
Austin Bingham
Robert Smallshire Robert Smallshire
Author Profile Icon Robert Smallshire
Robert Smallshire
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Preface 1. Getting started FREE CHAPTER 2. Strings and Collections 3. Modularity 4. Built-in types and the object model 5. Exploring Built-in Collection types 6. Exceptions 7. Comprehensions, iterables, and generators 8. Defining new types with classes 9. Files and Resource Management 10. Unit testing with the Python standard library 11. Debugging with PDB 12. Afterword – Just the Beginning
13. Virtual Environments 14. Packaging and Distribution 15. Installing Third-Party Packages

Summary

  • The unittest module is a framework for developing reliable automated tests.
  • You define test cases by subclassing from unittest.TestCase.
  • The unittest.main() function is useful for running all of the
    tests in a module.
  • The setUp() and tearDown() fixtures are used to run code before and after each test method.
  • Test methods are defined by creating method names that start with test_ on test case objects.
  • The various TestCase.assert... methods can be used to make a test method fail when the right conditions aren't met.
  • Use TestCase.assertRaises() in a with-statement to check that the right exceptions are thrown in a test.
  1. Test-driven development, or simply TDD, is a form of software development where tests are written first, That is, before you write the actual functionality to be tested. This may seem backwards at first, but it can be a surprisingly powerful technique...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime