- 1. Testing in Python
- 1.1. The software testing equasion
- 1.2. The software testing equasion (fixed)
- 1.3. Manual testing
- 1.4. Traditional Organizations
- 1.5. Quality Assurance
- 1.6. Web age Organizations
- 1.7. TDD vs Testing as an Afterthought
- 1.8. Why test?
- 1.9. Testing Modes
- 1.10. Testing Applications
- 1.11. Testing What to test?
- 1.12. Testing in Python
- 1.13. Testing Environment
- 1.14. Testing Setup - Fixture
- 1.15. Testing Resources
- 1.16. The plan of this course
- 1.17. The pieces of your software?
- 1.18. Continuous Integration (CI)
- 1.19. pre-commit
- 2. AUT - Application Under Test
- 2.1. mymath module
- 2.2. Fibonacci module
- 2.3. Use the mymath module
- 2.4. Manually test the mymath module
- 2.5. Use the Fibonacci module
- 3. Testing with doctest
- 3.1. Doctest for good module
- 3.2. Doctest for bad module
- 3.3. Doctest for bad module with failure
- 4. Testing with unittest
- 4.1. Test the mymath module
- 4.2. Each test case in its own method
- 4.3. Test the Fibonacci
- 4.4. Test the Fibonacci failure
- 4.5. Test the Fibonacci separated
- 4.6. Test the Fibonacci failure separated
- 4.7. TODO Testing - skeleton
- 4.8. TODO Testing
- 4.9. TODO Test examples
- 5. Testing with PyTest
- 5.1. Pytest features
- 5.2. Pytest setup
- 5.3. Testing good module with functions
- 5.4. Testing good module with class and methods
- 5.5. Pytest - passing test for the Fibonacci function
- 5.6. Pytest - failing test for the Fibonacci in one function
- 5.7. Pytest - failing test separated
- 5.8. Pytest run all the good test files
- 5.9. Pytest run all the bad test files
- 5.10. Exercise: test simple module (math)
- 5.11. Solution: test simple module (math)
- 6. Pytest basic command line options
- 6.1. Getting help for pytest
- 6.2. Verbose mode
- 6.3. Quiet mode
- 6.4. Print STDOUT and STDERR using -s
- 6.5. Pytest: show extra test summmary info with -r
- 7. Pytest expected exception
- 7.1. Pytest a nice Fibonacci example
- 7.2. Pytest testing Fibonacci
- 7.3. Using Fibonacci
- 7.4. Pytest expected exception
- 7.5. Pytest testing expected exception
- 7.6. Pytest Change the text of the exception
- 7.7. Pytest Missing exception
- 7.8. Pytest Other exception is raised
- 7.9. Pytest No exception is raised
- 7.10. Exercise: test more exceptions
- 7.11. Solution: test more exceptions
- 7.12. Another Solution: test more exceptions
- 7.13. Exercise: test exeptions in the math functions
- 7.14. Solution: test exeptions in the math functions
- 8. Handling failing tests (bugs)
- 8.1. Anagram
- 8.2. Pytest simple tests - success
- 8.3. Pytest simple tests - success output
- 8.4. Pytest simple tests - failure
- 8.5. Pytest simple tests - failure output
- 8.6. Pytest: expect a test to fail (xfail or TODO tests)
- 8.7. Pytest: expect a test to fail (xfail or TODO tests)
- 8.8. PyTest: show xfailed tests with -rx
- 8.9. Fixed Anagram
- 9. Multiple test functions - selection
- 9.1. PyTest: Multiple Failures
- 9.2. PyTest: Multiple Failures output
- 9.3. PyTest: stop on first failure
- 9.4. PyTest Selective running of test functions
- 10. Pytest: skipping tests
- 10.1. Pytest: Operating System specific test
- 10.2. Pytest: show skipped tests with -rs
- 10.3. Pytest: skipping tests output in verbose mode
- 11. Parametrize tests
- 11.1. Parametrize PyTest with pytest.mark.parametrize (len)
- 11.2. Test len without parametrization
- 11.3. Test len with 1 parameter
- 11.4. Test len with 2 parameters
- 11.5. mymath
- 11.6. One test function
- 11.7. Separate test functions
- 11.8. Test cases of mymath
- 11.9. Pytest parameters
- 11.10. Pytest parameters variable
- 11.11. Pytest parameters external data file
- 11.12. Pramatrization matrix
- 11.13. Testing the isalnum method
- 11.14. Parametrize PyTest with multiple parameters
- 11.15. Exercise: parametrize the tests of the math functions
- 11.16. Solution: parametrize the tests of the math functions
- 12. Pytest assert
- 12.1. PyTest: failure reports
- 12.2. PyTest: compare numbers
- 12.3. PyTest: compare numbers relatively
- 12.4. PyTest: compare strings
- 12.5. PyTest: compare long strings
- 12.6. PyTest: is one string in another strings?
- 12.7. PyTest: test any expression
- 12.8. PyTest: element in list
- 12.9. PyTest: compare short lists
- 12.10. PyTest: compare short lists - verbose output
- 12.11. PyTest: compare lists
- 12.12. PyTest: compare dictionaries - different values
- 12.13. PyTest: compare dictionaries - missing-keys
- 13. PyTest Fixtures
- 13.1. PyTest: What are Fixtures?
- 13.2. Fixtures in Pytest
- 13.3. PyTest: test with functions
- 13.4. PyTest: test with functions outpus
- 13.5. PyTest Fixture setup and teardown xUnit style
- 13.6. PyTest Fixture setup and teardown output
- 13.7. PyTest: Fixture Class setup and teardown
- 13.8. PyTest: Fixture Class setup and teardown output
- 13.9. What is Dependency injection?
- 13.10. Pytest fixture - tmpdir
- 13.11. Pytest and tempdir
- 13.12. Pytest CLI key-value store
- 13.13. Pytest testing key-value store - environment variable
- 13.14. Pytest testing key-value store - environment variable (outside)
- 13.15. Application that prints to STDOUT and STDERR
- 13.16. Pytest capture STDOUT and STDERR with capsys
- 13.17. PyTest - write your own fixture
- 13.18. Pytest Fixture - autouse fixtures
- 13.19. Share fixtures among test files: conftest.py
- 13.20. Manual fixtures (using dependency injection)
- 13.21. Pytest Fixture providing value
- 13.22. Pytest Fixture providing value with teardown
- 13.23. Pytest create fixture with file(s) - app and test
- 13.24. Pytest create fixture with file(s) - helper function
- 13.25. Pytest create fixture with file(s) - fixture
- 13.26. Pytest fixture inject data
- 13.27. Pytest fixture for MongoDB
- 13.28. Pytest parametrized fixture
- 13.29. Pytest parametrized fixture with dependency injection
- 13.30. Pytest parametrized fixture to use Docker
- 14. Pytest Mocking
- 14.1. Pytest: Mocking - why?
- 14.2. Pytest: Mocking - what?
- 14.3. Pytest: What is Mocking? - Test Doubles
- 14.4. Pytest: Monkey Patching
- 15. Pytest Mocking Hard-coded path
- 15.1. Pytest: Hard-coded path - testing
- 15.2. Pytest: Hard-coded path - manually replace attribute
- 15.3. Pytest: Hard-coded path - monkeypatch attribute
- 15.4. Pytest: Hard-coded path - monkeypatch attribute - tempdir
- 16. Pytest: Mocking external API call
- 16.1. Pytest: Mocking external API call - manually replace function
- 16.2. Pytest: Mocking external API call - monkeypatch
- 16.3. Pytest: Mocking broken external API response
- 17. Pytest: Mocking STDIN
- 17.1. Pytest: Mocking STDIN manually mocking
- 17.2. Pytest: Mocking STDIN - monkeypatch
- 18. Pytest: Mocking random numbes - the application
- 18.1. Pytest: Mocking random numbes
- 18.2. Pytest: Mocking multiple random numbers
- 19. Pytest: Mocking time
- 19.1. Pytest: Mocking time (test expiration)
- 19.2. Pytest: mocking specific timestamp with datetime
- 19.3. Pytest: mocking specific timestamp with datetime
- 19.4. Pytest: mocking datetime.date.today
- 19.5. Pytest: mocking datetime date
- 20. Pytest: Mocking environment variables
- 20.1. Pytest: Mocking The PATH environment variable
- 21. Pytest: One dimensional spacefight
- 21.1. Pytest: Mocking input and output in the game
- 21.2. Pytest: Mocking input and output in the game - no tools
- 21.3. Pytest: Mocking random in the game
- 21.4. Pytest: Mocking random in the game - no tools
- 22. Pytest: Mocking - collecting stats example
- 23. Flask
- 23.1. Pytest: Flask echo GET
- 23.2. Pytest: testing Flask echo GET
- 23.3. Pytest: Flask echo POST
- 23.4. Pytest: testing Flask echo POST
- 23.5. Pytest: Flask app sending mail
- 23.6. Pytest: Mocking Flask app sending mail
- 24. Testing Flask in Docker
- 24.1. Pytest with Docker - application
- 24.2. Pytest with Docker - test internally
- 24.3. Docker to run the Flask app
- 24.4. Pytest with Docker - test
- 24.5. Pytest with Docker - improved
- 25. Pytest command line options
- 25.1. PyTest: Run tests in parallel with xdist
- 25.2. PyTest: Order of tests
- 25.3. PyTest: Randomize Order of tests
- 25.4. PyTest: Force default order
- 25.5. PyTest test discovery
- 25.6. Pytest dry-run --collect-only
- 25.7. PyTest test discovery - ignore some tests
- 25.8. PyTest select tests by name
- 25.9. Pytest use markers and select tests using -m
- 25.10. No test selected
- 25.11. Pytest reporting in JUnit, XML, or JSON format
- 25.12. Pytest reporting in JUnit XML format
- 25.13. Pytest reporting in JSON format
- 25.14. Pytest JSON report
- 25.15. Add extra command line parameters to Pytest - conftest - getoption
- 25.16. Add extra command line parameters to Pytest - as a fixture
- 25.17. Add extra command line parameters to Pytest - used in the autouse fixtures
- 25.18. PyTest: Test Coverage
- 25.19. Test coverage with uv
- 26. Static Analyzers (Linters)
- 26.1. Pytest and flake8
- 26.2. Pytest and pylint
- 26.3. Pytest and ruff
- 26.4. Pytest and mypy
- 26.5. Black code formatter
- 27. Pytest - other
- 27.1. Testing Master Mind
- 27.2. Module Fibonacci
- 27.3. PyTest - assertion
- 27.4. PyTest - failure
- 27.5. PyTest - list
- 27.6. Pytest: monkeypatching time
- 27.7. PyTest: no random order
- 28. Another exception example: bank deposit
- 28.1. PyTest expected exceptions (bank deposit)
- 28.2. PyTest expected exceptions (bank deposit) - no exception happens
- 28.3. PyTest expected exceptions (bank deposit) - different exception is raised
- 28.4. PyTest expected exceptions - divide
- 28.5. PyTest expected exceptions output
- 28.6. PyTest expected exceptions (text changed)
- 28.7. PyTest expected exceptions (text changed) output
- 28.8. PyTest expected exceptions (other exception)
- 28.9. PyTest expected exceptions (other exception) output
- 28.10. PyTest expected exceptions (no exception)
- 28.11. PyTest expected exceptions (no exception) output
- 29. Other
- 29.1. Exercise: test this app
- 29.2. Exercise: test the csv module
- 29.3. Solution: Pytest test this app
- 29.4. Solution: test the csv module
- 29.5. PyTest using classes
- 29.6. Exercise: module
- 29.7. Exercise: Open Source
- 29.8. Pytest and forking
- 29.9. Exercise: Write tests for script combining files
- 29.10. Solution: Write tests for script combining files
- 29.11. Pytest resources
- 29.12. PyTest compare short lists - output
- 29.13. Anagram on the command line
- 29.14. PyTest testing CLI
- 30. Old pages
- 30.1. How to use the module?
- 30.2. Pytest - simple passing test
- 30.3. Pytest failing test in one function - old
- 30.4. Pytest failing test separated - old