- Hands-On Docker for Microservices with Python
- Jaime Buelta
- 196字
- 2021-06-24 12:35:52
Testing the code
To test our application, we use the excellent pytest framework, which is the gold standard in test runners for Python applications.
Basically, pytest has a lot of plugins and add-ons to deal with a lot of situations. We will be using pytest-flask, which helps with running tests for Flask applications.
To run all the tests, just call pytest in the command line:
$ pytest
============== test session starts ==============
....
==== 17 passed, 177 warnings in 1.50 seconds =====
Note that pytest has a lot of features available to deal with a lot of situations while testing. Things running a subset of matched tests (the -k option), running the last failed tests ( --lf), or stopping after the first failure ( -x) are incredibly useful when working with tests. I highly recommend checking its full documentation ( https://docs.pytest.org/en/latest/) and discovering all its possibilities.
There are also a lot of plugins and extensions for using databases or frameworks, reporting code coverage, profiling, BDD, and many others. It is worth finding out about them.
There are also a lot of plugins and extensions for using databases or frameworks, reporting code coverage, profiling, BDD, and many others. It is worth finding out about them.
We configure the basic usage, including always enabling flags in the pytest.ini file and the fixtures in conftest.py.
推薦閱讀
- 6G潛在關鍵技術(下冊)
- 重新定義Spring Cloud實戰(zhàn)
- 信息通信網(wǎng)絡建設安全管理概要2
- Drush User’s Guide
- Building RESTful Web Services with Spring 5(Second Edition)
- Metasploit Penetration Testing Cookbook
- Kong網(wǎng)關:入門、實戰(zhàn)與進階
- 網(wǎng)管第一課:網(wǎng)絡操作系統(tǒng)與配置管理
- 物聯(lián)網(wǎng)的機遇與利用
- 計算機通信網(wǎng)絡安全
- INSTANT Social Media Marketing with HootSuite
- OSPF協(xié)議原理與功能拓展
- ReasonML Quick Start Guide
- Hands-On Cloud:Native Microservices with Jakarta EE
- Learning Dart