Python for Testing 102 (PT102)

Understand the fundamentals of software testing, learn how different testing techniques fit into the development process, and prepare for the PCAT™ – Certified Associate Tester with Python certification.

Python for Testing 102 (PT102) takes you beyond the fundamentals and into the practical world of building clean, maintainable, and scalable test suites using Python. You’ll learn how professional testers structure their code, manage resources, design robust assertions, apply mocking and fixtures, work with both unittest and pytest, and use TDD/BDD workflows to drive development with clarity and confidence.

By completing this course, you’ll build a strong foundation in software testing and be prepared for the PCAT™ – Certified Associate Tester with Python certification.


Key skills you will learn

Enroll in Python for Testing 102 (PT102) and gain practical skills in:

  • Clean test infrastructure using context managers, decorators, and method patterns.
  • Unit testing with unittest and advanced assertion techniques.
  • Project-driven test development with refactoring, error handling, and edge-case design.
  • Fixtures, parameterization, test doubles, and mocks for reliable and maintainable tests.
  • Effective use of pytest for scalable, expressive testing workflows.
  • Test-Driven Development (TDD) and Behavior-Driven Development (BDD) using Gherkin and step definitions.

INTERMEDIATE


Python for Testing Track

--

Python Institute logo

Python for Testing 102 (PT102)

  Intermediate

  30-40 hours

  English

  Free

Python for Testing 102 (PT102)

This course is the second in the Testing Essentials series, designed to prepare you for the PCAT™ – Certified Associate Tester with Python certification exam.

The Python for Testing 102 (PT102) is a hands-on, project-driven continuation of PT101. Across this course you’ll deepen your testing practice with both unittest and pytest, level up your use of fixtures and parameterization, mock external dependencies cleanly, and round it out with TDD and BDD.

For more details about the course or to sign up, click the button. You will be redirected to our e-learning platform, Edube.


Target Audience


Python for Testing 102 (PT102) is ideal for:


Prerequisites

To get the most out of PT102, you should have:

You should already be comfortable with basic Python programming. We recommend completing Python for Testing 101 (PT101), holding the PCEP™ – Certified Entry-Level Python Programmer certification, or having equivalent experience.


What You Will Learn

By the end of this course, you will be able to:

  • Grow a single project end-to-end – continue the Crossword Helper and evolve it (palindromes → ROT shifts → anagrams → pattern matching) with tests that guide the design.
  • Strengthen your unittest toolkit – apply test anatomy and F.I.R.S.T., write precise assertions (assertEqual, assertAlmostEqual, assertRaises, assertCountEqual), remove duplication with setUp/tearDown and class/module hooks, use subTest(), and control runs with @skip/@expectedFailure.
  • Adopt pytest for speed and clarity – native assert with rich introspection, reusable fixtures (including yield cleanup) and scopes (function → session), parameterization with @pytest.mark.parametrize, markers (skip/xfail/importorskip), targeted selection (-k/-m), verbosity and reports (-v, -r), and centralized config in pytest.ini.
  • Mock with confidence – replace slow/fragile I/O using unittest.mock (stubs/fakes/spies, Mock/MagicMock, patch with spec/create_autospec) and the pytest-mock mocker fixture ("mock where it’s used").
  • Measure and report – generate coverage with pytest-cov and share results via pytest-html (including self-contained reports).
  • TDD & BDD – practice Red → Green → Refactor on small slices (and refactor safely with Pythonic improvements like zip()), then describe behavior with Gherkin (Feature/Scenario, Given/When/Then) and bind to Python step definitions (e.g., behave).

Course Syllabus

  1. Context managers for safe setup and teardown,
  2. Decorators for logging, timing, and instrumentation,
  3. Instance, class, and static methods for flexible test utilities.

  1. Why unit testing matters
  2. Test structure and naming conventions
  3. The F.I.R.S.T. principles of effective tests
  4. Writing and running tests with unittest

  1. Common assertion patterns and best practices
  2. Error handling and exceptional cases
  3. Numeric comparisons and tolerance with floats
  4. Anagram and string-manipulation tests
  5. AAA pattern and clean test design

  1. Using setUp, tearDown, and class-level fixtures
  2. Parameterizing tests with subTest()
  3. Test filtering and markers
  4. Mocking external services with unittest.mock

  1. Introduction and project layout
  2. Pytest assertions and introspection
  3. Pytest fixtures and scopes
  4. Parameterization with @pytest.mark.parametrize
  5. Markers, configuration, and plugins (HTML reports, coverage)

  1. The TDD cycle and practical examples
  2. Refactoring safely with tests
  3. BDD basics and Gherkin
  4. Step definitions with behave