Test- Driven Python Development by Siddharta Govindaraj

By Siddharta Govindaraj

Develop fine quality and maintainable Python functions utilizing the foundations of test-driven development

About This Book

  • Write strong and simply maintainable code utilizing the rules of attempt pushed development
  • Get options to real-world difficulties confronted via Python developers
  • Go from a unit trying out newbie to a grasp via a chain of step by step tutorials which are effortless to follow

Who This publication Is For

This publication is meant for Python builders who are looking to use the foundations of test-driven improvement (TDD) to create effective and powerful functions. which will get the simplest out of this publication, you'll have improvement adventure with Python.

What you'll Learn

  • Implement the test-driven improvement method in Python applications
  • Fully leverage Python's strong integrated unittest and doctest modules
  • Effectively upload positive factors to current code bases that don't have any tests
  • Safely unravel issues of the code and layout, with no breaking any functionality
  • Utilize Python's strong mock and patch performance to check complicated interactions
  • Integrate unit checking out into the general software program supply process
  • Use doctest to check code with examples
  • Enhance TDD with the nose2 try runner

In Detail

This ebook begins with a glance on the test-driven improvement strategy, and the way it truly is varied from the conventional means of writing code. the entire ideas are awarded within the context of a true program that's constructed in a step by step demeanour over the process the ebook. whereas exploring the typical different types of stinky code, we are going to return into our instance venture and freshen up the smells that we find.

Additionally, we are going to use mocking to enforce the elements of our instance undertaking that rely on different structures. in the direction of the tip of the e-book, we will look at the commonest styles and anti-patterns linked to test-driven improvement, together with integration of try effects into the improvement process.

Show description

Read Online or Download Test- Driven Python Development PDF

Best python books

Fundamentals of Python: From First Programs through Data Structures

In basics OF PYTHON: FROM FIRST courses via information buildings, Washington and Lee college professor Kenneth A. Lambert provides the entire vital subject matters in CS1 and CS2 in a single quantity. This low-cost layout offers teachers with a constant method of educating introductory programming and knowledge buildings over a typical two-term path series.

Python for Data Analysis: Data Wrangling with Pandas, NumPy, and IPython

Python for info research is worried with the nuts and bolts of manipulating, processing, cleansing, and crunching facts in Python. it's also a pragmatic, glossy creation to medical computing in Python, adapted for data-intensive functions. this can be a booklet in regards to the elements of the Python language and libraries you'll have to successfully clear up a vast set of knowledge research difficulties.

Python and AWS

For those who intend to take advantage of Amazon net prone (AWS) for distant computing and garage, Python is a perfect programming language for constructing functions and controlling your cloud-based infrastructure. This cookbook will get you begun with greater than dozen recipes for utilizing Python with AWS, in keeping with the author’s boto library.

Artificial Intelligence with Python

Construct real-world synthetic Intelligence functions with Python to intelligently engage with the area round you approximately This ebook Step into the superb international of clever apps utilizing this entire advisor input the realm of synthetic Intelligence, discover it, and create your personal purposes paintings via easy but insightful examples that might get you up and working with synthetic Intelligence very quickly Who This booklet Is For This ebook is for Python builders who are looking to construct real-world synthetic Intelligence functions.

Additional resources for Test- Driven Python Development

Sample text

There is no right answer and it is a subjective decision that needs to be taken, weighing up the pros and cons of each specific situation. Refactoring the design In the previous section, we talked about the new requirement of having to check if a stock has an increasing trend. is_increasing_trend()) The test takes three timestamps and prices and performs an update for each one. Since all three prices are increasing, the is_increasing_trend method should return True. To make this test pass, we need to first add support for storing price history.

38 ] Chapter 2 Try your hand at implementing this requirement. Do not make any changes to the existing interfaces for these methods, but feel free to make any changes to the implementation as you require. Here are some things to think about: • Does our existing design support this new feature? Do we need to make any changes to the current design? • What kind of tests would we write for this requirement? • After we get everything working, is there any clean up we can do to make the code more readable or maintainable?

The only way to test the caching functionality would be to verify if the calculated value is stored in the cache. If we later change the caching method (for example, moving from a file cache to memcache), then we will have to change the test as well. Brittle tests can be worse than no tests, as the maintenance overhead of having to fix ten or twenty tests with every change in the implementation can turn developers away from TDD, increase the amount of frustration, and lead to teams disabling or skipping testing.

Download PDF sample

Rated 4.71 of 5 – based on 4 votes