The biggest Python topics of 2023 ›
Python Testing Tools and Techniques
Testing in Python encompasses a wide range of practices and tools, including using pytest for automated testing, property-based testing with tools like Hypothesis, mocking in tests, and testing across multiple Python versions. This diverse topic covers everything from optimizing test performance with pytest fixtures to exploring new libraries like Grasshopper for load testing in Python.
Generating Meaningful Tests for Busy Devs Article
With CodiumAI’s TestGPT, you can ensure that your code works exactly as you meant it to. TestGPT analyzes your code, docstring, comments, and interacts with you to suggest tests while you code. You only need to accept and commit to these tests to ensure the quality of your code →
https://www.codium.ai
Don’t Mock Python’s HTTPX Article
HTTPX is a popular alternative to the requests library. James writes how using mock to test it can be problematic, and suggests an alternative approach.
https://www.b-list.org/weblog/2023/dec/08/mock-python-httpx/
Using pytest to Test PySpark Code Article
This article shows you how to run automated tests on your PySpark code using the pytest. It delves into some of the pitfalls and how to make your tests performant.
https://garybake.com/pyspark_pytest.html
Testing With Hypothesis Article
Hypothesis is a property-based testing library. This style of testing uses ranges of scenarios rather than a single value, and then the tool explores the results. See also the intro article to strategy based testing.
https://hypothesis.readthedocs.io/en/latest/
Python Testing Tools Taxonomy Article
This entry in the Python wiki is an exhaustive list of testing tools and libraries. Content includes unit testing, mocking, fuzz testing, web testing, coverage tools, and much more.
https://wiki.python.org/moin/PythonTestingToolsTaxonomy
Pytest Daemon: 10X Local Test Iteration Speed Article
Discord has a large Python monolith with lots of imports, which now takes 13 seconds to start up. On the server that’s not a problem but to run a test it is. Ruby’s solution is to have a daemon that hot loads a test on a process that already has the imports completed.
https://discord.com/blog/pytest-daemon-10x-local-test-iteration-speed
100% Test Coverage Is Not Enough Article
This post describes why Property-Based Testing is superior to simply achieving 100% code coverage and how it can catch more bugs.
https://blog.robertroskam.com/p/100-test-coverage-is-not-enough
How to Test Jupyter Notebooks With Pytest and Nbmake Article
Tutorial on how to use the pytest plugin nbmake to automate end-to-end testing of notebooks.
https://semaphoreci.com/blog/test-jupyter-notebooks-with-pytest-and-nbmake
pytest Fixtures Are Magic! Article
Fixtures are building blocks for good tests and can increase development speed. The main issue with writing tests is setting up necessary data before the test, but pytest fixtures make it easier by injecting necessary data into your tests.
https://www.revsys.com/tidbits/pytest-fixtures-are-magic/
Introducing Grasshopper: A Python Load Testing Library Article
This article introduces you to Grasshopper, an open source load testing library for Python. It is built on top of Locust and PyTest providing additional ways of checking and timing your tests.
https://innovation.alteryx.com/introducing-grasshopper-an-open-source-python-library-for-load-testing/
Testing Multiple Python Versions With nox and pyenv Article
Quick instructions on using nox with parameters to test multiple versions of Python against your test suite.
https://sethmlarson.dev/nox-pyenv-all-python-versions
End-to-End Testing With Python and Playwright Article
This post shows you how to get started with Playwright, add end-to-end tests to an existing project, and automate running it using GitHub Actions.
https://sixfeetup.com/blog/end-to-end-testing-python-playwright
Property-Based Testing With Hypothesis and Pytest Article
This tutorial is a gentle guide to property-based testing. Property-based testing is a testing philosophy; a way of approaching testing that will bring you many benefits that other types of testing don’t give you.
http://semaphoreci.com/blog/property-based-testing-python-hypothesis-pytest
AB Testing 101 Article
A comprehensive deep dive on AB Testing including the math behind knowing whether your tests are significant.
https://medium.com/jonathans-musings/ab-testing-101-5576de6466b
Building a Bloom Filter Article
Bloom filters are a data structure used to test whether an element is a member of a set. They’re commonly used in data science and are often part of interview questions. Learn how to build one and where you might use them.
https://luminousmen.com/post/building-a-bloom-filter