Testing Python®
after payment (24/7)
(for all gadgets)
(including for Apple and Android)
IF YOU HAVE picked up this book, you clearly have some interest in the world of Python.Perhaps you have just started to learn the language. Maybe you have some Python experience and are looking to learn more about the world of testing. You also could have many years of Python under your belt and want to refresh your testing skills. Whatever your reasons, you will pick up some new skills.The book covers testing right through from its history looking at how testing in Python has evolved over the years to where it is now, and a brief look at the different practices used. You also look at reasons for testing and why it can be so important in both large enterprise class projects and in small personal projects.The book lets you get your hands dirty with the basic building blocks in testing, which are unit tests. Here you will be taken through what a unit test is, the basic syntax, and examples of a simple unit test. Then, you take a comprehensive look at the methods available to use in unit testing and the various tools available to help in running and debugging your tests.Wrapping up the unit test section, you look into the pivotal use of mocks and patching, which allow you to isolate the code you are interested in testing (your “units”), and simulate responses from other parts of the system or libraries.Testing in your documentation is one of the more interesting parts of Python testing. This section shows you how to effectively embed unit tests in your doc strings and have them run as tests. Here you look at why this might be useful to you and go through some examples on writing these yourself.Your attention then turns to the more recent hot topic of test driven development (TDD), a practice which if followed correctly can ensure you deliver great code that does exactly what you need it to the first time. The TDD section introduces the concepts and ethos of the practice and covers steps required to adopt it. I provide great use cases using TDD in pair programming and show how you can make the development process more fun. Wrapping up the section are examples of test-driving the creation of a part of a real application that you can try yourself.One of the more recent aspects of testing and something the development community as a whole has moved toward is the concept of behavior driven development (BDD) and acceptance testing. This builds on the TDD approach, helping you to construct tests that ensure features of your application meet the acceptance criteria of your stakeholders. Put another way, BDD ensures that you have a testable way of proving the different parts of your application work together to deliver the behavior that you want. BDD and acceptance testing are fantastic ways of testing and providing documentation supporting your application as the tests are being written—all in a human readable feature file, with code executing underneath.If you have never written this style of test, you’ll certainly want to give Chapters 6 and 7 a read.A key aspect of an application’s lifestyle is testing how it will perform under real-life conditions.Your application might be really responsive when running locally on your development machine, but what if your application is going to be accessed by hundreds or thousands of people a minute? Will it respond to requests quickly enough? Will the user experience be affected at all? Performance testing ensures you find the answers to these questions before your customers do, and that can only be a good thing!The book also covers keeping your code in check. In the development cycle, you write a lot of code and in the majority of cases this code needs to be read by someone other than you. This means effective, actionable standards need to be applied across the Python community. This is where PEP-8 came in and tools have evolved around this to help maintain the standards.You look at effective ways to use tools such as PyLint and code coverage to ensure your code is maintainable, and your tests cover the parts of your application that matter.A key feature of many teams is having some form of build process. If you have never heard of Jenkins or continuous integration, this section will guide you through why having a build is so important. Continuous integration or “CI” (Jenkins being a tool that helps you manage and run CI) is essentially a process where upon check in of your code to some source control system, that code is put through a series of repeatable tests, profiling, and other metrics to give the team a status of their code at any time. Should tests fail or your code start responding more slowly, then the team is made aware of it quickly and can deal with any issue during the development process. Implementing the build process can make your development processes easier, making use of automation for the things you need to do every day.You wrap up with incorporating useful plug-ins, which can keep track of those PyLint issues and code coverage.After applying all these techniques and processes to your application, you should then be nearing release of your product! This is where you take a look into smoke testing (a type of testing which shows different components of an application are working together correctly) and how you can have tests in place to ensure every time you release, the wider application stack can work as it did previously with your new code. By taking a look at some of this book’s examples and ideas, you should be able to get a smoke-testing suite in place to give you confidence every time you release. Hopefully, this has whetted your appetite for more on all these Python testing topics. Whether a novice or a Python expert, you should gain something from this book that can help you make your testing better, give you more confidence in your code, and get your whole team involved and engaged in delivering quality every time.
Data sheet
- Language
- English