🌐
pytest
docs.pytest.org
pytest documentation
The pytest framework makes it easy to write small, readable tests, and can scale to support complex functional testing for applications and libraries.
Helps you write better programs
The pytest framework makes it easy to write small, readable tests, and can scale to support complex functional testing for applications and libraries.
Pytest fixtures
In pytest, “fixtures” are functions you define that serve this purpose. But they don’t have to be limited to just the arrange steps. They can provide the act step, as well, and this can be a powerful technique for designing more complex tests, especially given how pytest’s fixture system ...
How to write and report assertions in tests
You can check that code raises a particular warning using pytest.warns.
How to use fixtures
In this example, test_fruit_salad “requests” fruit_bowl (i.e. def test_fruit_salad(fruit_bowl):), and when pytest sees this, it will execute the fruit_bowl fixture function and pass the object it returns into test_fruit_salad as the fruit_bowl argument.
🌐
PyPI
pypi.org › project › pytest
pytest · PyPI
The pytest framework makes it easy to write small tests, yet scales to support complex functional testing for applications and libraries.
Discussions

What are pytest best practices?
pytest best practices are no different than unit testing best practices. It sounds like that's your actual question. If so, you'll have better results searching for unit testing documentation and tutorials. Some thoughts on what you've posted dry_run=True is a yellow flag for me. You should test your actual methods as they will be run in production. You can mock the dependencies, but having a flag that changes the method's behavior for testing just means you aren't testing the method. Yes, you should be making assertions--that's how you know things work. I don't know what you mean by conditions. You will almost certainly be testing any particular method several if not dozens of times. You need to test all its edge cases, failure cases, error cases, and valid cases. pytest has the ability to parameterize tests to make this easier. More on reddit.com
🌐 r/learnpython
3
6
October 30, 2023
python - Using pytest as test runner while preventing it from modifying test code - Stack Overflow
Is there a way to use pytest as a test runner to collect some unit tests but prevent pytest from modifying the test code itself on selected unit tests? As part of a series of unit tests in Python, ... More on stackoverflow.com
🌐 stackoverflow.com
How many of you use unittest/pytest?
TEST, TEST, TEST and then test again. You will know the value of testing when your pipeline breaks for some simple edge case. Use libraries like faker to easily generate fake data based on your schema(make sure to track your seeds). Many semantic layers such as dbt allow you to test before publishing as well. While it may be a pain to get in the habit, catching bugs in a test is a much better feeling than in production. I promise you More on reddit.com
🌐 r/dataengineering
46
105
September 18, 2024
pytest vs unittest?
I can't imagine going back to unit-test, pytest is so much cleaner and has more flexible fixture configuration. That said, expect to sink a few hours into configuring pytest perfectly, especially if you want to transition and keep your old tests working. It's definitely worth it if you plan on being a django dev longer term and if your projects aren't too small. More on reddit.com
🌐 r/django
32
26
September 3, 2024
Python testing framework
Pytest is a Python testing framework that originated from the PyPy project. It can be used to write various types of software tests, including unit tests, integration tests, end-to-end tests, and functional … Wikipedia
Factsheet
Original author Krekel et al.
Stable release 9.1.1
/ 19 June 2026; 3 months ago
Written in Python
Factsheet
Original author Krekel et al.
Stable release 9.1.1
/ 19 June 2026; 3 months ago
Written in Python
🌐
Wikipedia
en.wikipedia.org › wiki › Pytest
pytest - Wikipedia
June 21, 2026 - Pytest is a Python testing framework that originated from the PyPy project. It can be used to write various types of software tests, including unit tests, integration tests, end-to-end tests, and functional tests. Its features include parametrized testing, fixtures, and assert re-writing.
🌐
Plain English
python.plainenglish.io › 7-advanced-pytest-tricks-every-python-dev-should-know-7362dd4235ca
7 Advanced Pytest Tricks Every Python Dev Should Know | by Jaume Boguñá | Python in Plain English
July 18, 2025 - In this article, I’ll walk through seven powerful pytest features—beyond the basics—that helped me test smarter, catch more bugs, and write cleaner code across my data projects.
🌐
GitHub
github.com › pytest-dev › pytest
GitHub - pytest-dev/pytest: The pytest framework makes it easy to write small tests, yet scales to support complex functional testing · GitHub
1 month ago - The pytest framework makes it easy to write small tests, yet scales to support complex functional testing for applications and libraries.
Author: pytest-dev
🌐
YouTube
youtube.com › watch
A practical introduction to PyTest - YouTube
In this lunch and learn talk, Richard Lane offers a practical introduction to testing, aimed at developers who are unsure about its value. It explains why te...
Published: June 19, 2025
Find elsewhere
🌐
freeCodeCamp
freecodecamp.org › news › how-to-use-pytest-a-guide-to-testing-in-python
How to Use pytest: A Simple Guide to Testing in Python
July 10, 2025 - The general method of running pytest tests is by running the pytest command in your terminal. pytest will automatically look for and run all files of the form test_*.py or *_test.py in the current directory and subdirectories.
🌐
Reddit
reddit.com › r/learnpython › what are pytest best practices?
r/learnpython on Reddit: What are pytest best practices?
October 30, 2023 -

I am fairly new to python, and made a career switch where 99% of my day-to-day involves python in some regard.

After reading through pytest documentation, then seeing how unit tests are implemented at work, I'm not super sure if they're up to par with best practices or not. Would anyone be able to take a look at this code and explain how this works (or doesn't) with pytest/provide resources or code examples on best practices?

Here's the pseudo code, similar to what I work with:

```

from parent_package import some_python_script

some_python_script.main(dry_run=True)

```

Then I'd run pytest via cli....

Should there be an assertion? Conditions? ETC.

🌐
YouTube
youtube.com › watch
Unit Testing with PyTest in Python
To learn more, please visit the YouTube Help Center: https://www.youtube.com/help
🌐
CircleCI
circleci.com › home › blog › pytest: automated testing for python
Pytest: Automated testing for Python - CircleCI
April 7, 2026 - Renowned for its straightforward yet powerful features, pytest makes writing and running tests efficient and effective.
🌐
Paiml
paiml.com › docs › home › books › testing-in-python › chapter03-introduction-to-pytest
Chapter03 Introduction to Pytest | Pragmatic AI Labs and Solutions
Pytest allows you to write test functions, which is a major feature if you are getting started and haven’t worked with classes before. In some cases, I write test functions even though I am very familiar with classes.
🌐
Stack Overflow
stackoverflow.com › questions › 64401095 › using-pytest-as-test-runner-while-preventing-it-from-modifying-test-code
python - Using pytest as test runner while preventing it from modifying test code - Stack Overflow
As part of a series of unit tests in Python, I have some that use functions that rely on frame inspection. If I run these on their own, they produce the expected results. However, if I use pytest to collect the tests and run them, the tests fail as pytest inserts additional frames which end up generating a RuntimeError.
🌐
Automation Panda
automationpanda.com › 2018 › 09 › 27 › book-review-pytest-quick-start-guide
Book Review: pytest Quick Start Guide | Automation Panda
September 27, 2018 - This book is an easy introduction to test automation in Python with pytest. Readers should have intermediate-level Python skills, but they do not need previous testing or automation skills. The progression of chapters makes it easy to start quick and then go deeper.
🌐
YouTube
youtube.com › watch
4 Intro to Python and TDD with Pytest
To learn more, please visit the YouTube Help Center: https://www.youtube.com/help
🌐
Scientific Python Development
learn.scientific-python.org › development › guides › pytest
Testing - Scientific Python Development Guide
Python used to have three major choices for tests; but now pytest is used almost exclusively. Testing is never an install requirement, so there’s no harm in using pytest.
🌐
PyDevTools
pydevtools.com › home › python developer tooling handbook › reference › pytest
pytest: Python Testing Framework | pydevtools
1 month ago - pytest is a Python testing framework with concise syntax, powerful fixtures, parameterized testing, and a rich plugin ecosystem.
🌐
YouTube
youtube.com › watch
Please Learn How To Write Tests in Python… • Pytest Tutorial - YouTube
Get started with the Careerist QA Program today! https://crst.co/TECHWITH-2984FB40In this video, I'm going to teach you how to write unit tests in Python usi...
Published: February 25, 2025