testing package

Submodules

testing.conftest module

This file has fixtures for the tests included in this directory

testing.conftest.fixture_product_1()

Example of a fixture of one product

testing.conftest.fixture_product_2()

Example of a fixture of another product

testing.conftest.product_fixture_list(fixture_product_1, fixture_product_2)

Example of a fixture composed of two other fixtures

testing.conftest.time_calculator()

Example of an autouse fixture

testing.mocking module

This module has supporting code to demonstrate testing

testing.mocking.run_dice() str

Simulate a dice roll :returns: ‘Lucky’ or ‘Unlucky’

testing.mocking_test module

Tests to demonstrate testing.

class testing.mocking_test.TestRunDice(methodName='runTest')

Bases: TestCase

Tests for the run_dice function isolating it from random library

test_mock_function_with_dice(mock_random)

Testing run_dice function

testing.mocking_test.test_mock_function()

Test that a mock function is called

testing.pytesting module

Example code to show Pytest features

class testing.pytesting.Product(id: UUID, price: float, name: str)

Bases: object

Class Product example

id: UUID
name: str
price: float
testing.pytesting.add(number_1: int, number_2: int) int

Add two numbers.

Parameters:
  • number_1 – First number.

  • number_2 – Second number.

Returns:

Sum of two numbers.

testing.pytesting_test module

Tests restated to Pytest

testing.pytesting_test.test_add()

Doing simple tests

testing.pytesting_test.test_add_parametrize(parameter_1, parameter_2, expected_result)

Test example using parametrize feature of Pytest

testing.pytesting_test.test_product_list(product_fixture_list)

Test example using fixture

Module contents