- This tutorial will show you how to automate testing for python projects using
tox
. - If you’ve ever worked on a python package, chances are you have seen files like:
setup.cfg
,setup.py
,pyproject.toml
,tox.ini
, etc. -
This tutorial explains what they are as well as walks you through how you can use them to your benefit.
-
Table Of Contents
- Chapter 1: The Need For Test Automation
- 1.1 – Testing Without A library
- 1.2 – Using an Existing Testing Library
- 1.3 – Understanding the TOX Use Case in the Eco System
Chapter 1: The Need For Test Automation
Namah Shrestha ・ Oct 21 ・ 3 min read
#python #tox #testing #pytest
- Chapter 2 – The Need of A project Structure in Python Testing
- 2.1 – Understanding the problem with import statements
- 2.2 – Solution to the problem with import statements
- 2.3 – Making our application installable
- 2.3.1 – Understanding the
pyproject.toml
file - 2.3.2 – Understanding the
setup.py
file - 2.3.3 – Understanding the
setup.cfg
file
Chapter 2: The Need Of A Project Structure In Python Testing
Namah Shrestha ・ Oct 21 ・ 6 min read
#python #tox #testing #pytest
- 2.3.1 – Understanding the
- Chapter 3 – Using
pytest
,mypy
andflake8
- 3.1 – Adding new dependencies to requirements
- 3.2 – Adding to our metadata in
setup.cfg
- 3.3 – Adding python configurations to
pyproject.toml
Chapter 3: Using PyTest, MyPy and flake8 for testing
Namah Shrestha ・ Oct 21 ・ 3 min read
#python #testing #pytest #flake8
- Chapter 4 – A Quick Tour of
Pytest
- 4.1 – Test Discovery
- 4.2 – Working with parameterising
- 4.3 – Skipping Tests
- 4.4 – Handling Failing Tests without breaking the build
- 4.5 – Handling Tests that raise errors
- 4.6 – Working with fixtures
- 4.6.1 – Understanding
fixture scopes
- 4.6.1 – Understanding
- 4.7 – Working with monkey patching
- 4.7.1 – Understanding the need to mock
- 4.7.2 – Monkeypatch syntax overview
- 4.8 – Understanding test coverage
Chapter 4: A Quick tour of PyTest
Namah Shrestha ・ Oct 21 ・ 10 min read
#python #pytest #testing #unittesting
- Chapter 5 – Test multiple environments with
Tox
- 5.1 – The Need for Tox and the Tox configuration file
- 5.2 – Understanding the Tox variables
- 5.3 – Understanding the flow of tox environments
- 5.4 – Executing Tox
Chapter 5: Testing Multiple Environments with TOX.
Namah Shrestha ・ Oct 21 ・ 5 min read
#python #pytest #tox #testing
- Chapter 6 – Test on commit with Github Actions
- 6.1 – The Need for Github Actions
- 6.2 – Configuring Github Actions
- 6.3 – Understanding Tox GH Actions
- 6.4 – Adding Build Results to README
Chapter 6: Test on Commit With Github Actions
Namah Shrestha ・ Oct 21 ・ 4 min read
#github #testing #python #git
- Chapter 1: The Need For Test Automation
-
Credits – Study Material
- This article is based on the following youtube video: https://www.youtube.com/watch?v=DhUpxWjOhME
- Please check it out. This video offers a visual counterpart to this article. It is the original video this article is based out of.
- Other articles used throughout the article to understand various concepts better:
- SetupTools Documentation – https://setuptools.pypa.io/en/latest/index.html
- Type Checking with MyPy – https://realpython.com/lessons/type-checking-mypy/#:~:text=%E2%80%9CMypy%20is%20an%20optional%20static,background%20on%20the%20Mypy%20project
- Test Discover in PyPy – https://docs.pytest.org/en/stable/explanation/goodpractices.html#test-discovery
- Grouping multiple tests in a class – https://docs.pytest.org/en/stable/getting-started.html#group-multiple-tests-in-a-class
- Understanding grouping of tests in a class – https://stackoverflow.com/questions/20277058/py-test-does-not-find-tests-under-a-class#:~:text=test%20does%20not%20find%20tests%20under%20a%20class,-Ask%20Question
- Testing unittest based classes – https://docs.pytest.org/en/7.1.x/how-to/unittest.html
- Change the standard in Test Discovery – https://docs.pytest.org/en/7.1.x/example/pythoncollection.html
- Fixture Scopes – https://betterprogramming.pub/understand-5-scopes-of-pytest-fixtures-1b607b5c19ed
- Understanding the structure of tox configuration file: https://tox.wiki/en/latest/config.html
- Finally my
TDD In Python
course: https://www.youtube.com/watch?v=NAjCDSqxrQ&list=PLVWk3kKbCAAuPPr_eh4KNKdL2hDSNFH3H
© 版权声明
THE END
暂无评论内容