You will need a recent version of Python 3 and pip (the package installer for Python).
All code examples in this book have been tested using Python 3.7, 3.8, and 3.9 on Linux. However, they should work on other systems too. PyTest 6.0.2 was used by the examples that rely on PyTest.
Software/hardware covered in the book |
OS requirements |
Python 3.7, 3.8, or 3.9 |
Windows, MacOSX, or Linux (any) |
pip 18+ |
|
PyTest 6.0.2+ |
Additional packages and libraries will be installed from the Python Package Index (PyPI) using pip over the course of the chapters.
If you are using the digital version of this book, we advise you to type the code yourself or access the code via the GitHub repository (link available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.
Download the example code files
You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/Crafting-Test-Driven-Software-with-Python. In case there's an update to the code, it will be updated on the existing GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
Conventions used
There are a number of text conventions used throughout this book.
CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "The test prepares a dbpath object for the sole purpose of checking that dbmanager is asked to load that specific path."
A block of code is set as follows:
def test_load(self):
dbpath = Path(tempfile.gettempdir(), "something")
dbmanager = Mock(
load=Mock(return_value=["buy milk", "buy water"])
)
app = TODOApp(io=(Mock(return_value="quit"), Mock()),
dbpath=dbpath, dbmanager=dbmanager)
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
def run(self):
self._quit = False
while not self._quit:
self._out(self.prompt(self.items_list()))
command = self._in()
self._dispatch(command)
self._out("bye!\n")
def items_list(self):
enumerated_items = enumerate(self._entries, start=1)
return "\n".join(
"{}. {}".format(idx, entry) for idx, entry in enumerated_items
)
Any command-line input or output is written as follows:
$ pip install pytest pytest-bdd
Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Select System info from the Administration panel."