tests.providers.test_python

Module Contents

Classes

TestPyint

A class whose instances are single test cases.

TestPyfloat

A class whose instances are single test cases.

TestPydecimal

A class whose instances are single test cases.

TestPystr

A class whose instances are single test cases.

TestPystrFormat

A class whose instances are single test cases.

TestPython

Tests python generators

Functions

test_pyobject(object_type)

test_pyobject_with_unknown_object_type(object_type)

test_pyfloat_right_and_left_digits_positive(...)

test_pyfloat_right_or_left_digit_overflow()

tests.providers.test_python.test_pyobject(object_type: Optional[Union[bool, str, float, int, tuple, set, list, Iterable, dict]])
tests.providers.test_python.test_pyobject_with_unknown_object_type(object_type)
tests.providers.test_python.test_pyfloat_right_and_left_digits_positive(mock_random_number_source, right_digits, expected_decimal_part)
tests.providers.test_python.test_pyfloat_right_or_left_digit_overflow()
class tests.providers.test_python.TestPyint(methodName='runTest')

Bases: unittest.TestCase

A class whose instances are single test cases.

By default, the test code itself should be placed in a method named ‘runTest’.

If the fixture may be used for many test cases, create as many test methods as are needed. When instantiating such a TestCase subclass, specify in the constructor arguments the name of the test method that the instance is to execute.

Test authors should subclass TestCase for their own tests. Construction and deconstruction of the test’s environment (‘fixture’) can be implemented by overriding the ‘setUp’ and ‘tearDown’ methods respectively.

If it is necessary to override the __init__ method, the base class __init__ method must always be called. It is important that subclasses should not change the signature of their __init__ method, since instances of the classes are instantiated automatically by parts of the framework in order to be run.

When subclassing TestCase, you can set these attributes: * failureException: determines which exception will be raised when

the instance’s assertion methods fail; test methods raising this exception will be deemed to have ‘failed’ rather than ‘errored’.

  • longMessage: determines whether long messages (including repr of

    objects used in assert methods) will be printed on failure in addition to any explicit message passed.

  • maxDiff: sets the maximum length of a diff in failure messages

    by assert methods using difflib. It is looked up as an instance attribute so can be configured by individual tests if required.

setUp()

Hook method for setting up the test fixture before exercising it.

test_pyint()
test_pyint_bounds()
test_pyint_step()
test_pyint_bound_0()
test_pyint_bound_positive()
test_pyint_bound_negative()
test_pyint_range()
class tests.providers.test_python.TestPyfloat(methodName='runTest')

Bases: unittest.TestCase

A class whose instances are single test cases.

By default, the test code itself should be placed in a method named ‘runTest’.

If the fixture may be used for many test cases, create as many test methods as are needed. When instantiating such a TestCase subclass, specify in the constructor arguments the name of the test method that the instance is to execute.

Test authors should subclass TestCase for their own tests. Construction and deconstruction of the test’s environment (‘fixture’) can be implemented by overriding the ‘setUp’ and ‘tearDown’ methods respectively.

If it is necessary to override the __init__ method, the base class __init__ method must always be called. It is important that subclasses should not change the signature of their __init__ method, since instances of the classes are instantiated automatically by parts of the framework in order to be run.

When subclassing TestCase, you can set these attributes: * failureException: determines which exception will be raised when

the instance’s assertion methods fail; test methods raising this exception will be deemed to have ‘failed’ rather than ‘errored’.

  • longMessage: determines whether long messages (including repr of

    objects used in assert methods) will be printed on failure in addition to any explicit message passed.

  • maxDiff: sets the maximum length of a diff in failure messages

    by assert methods using difflib. It is looked up as an instance attribute so can be configured by individual tests if required.

setUp()

Hook method for setting up the test fixture before exercising it.

test_pyfloat()
test_left_digits()
test_right_digits()
test_positive()
test_min_value()
test_min_value_and_left_digits()

Combining the min_value and left_digits keyword arguments produces numbers that obey both of those constraints.

test_max_value()
test_max_value_zero_and_left_digits()

Combining the max_value and left_digits keyword arguments produces numbers that obey both of those constraints.

test_max_value_should_be_greater_than_min_value()

An exception should be raised if min_value is greater than max_value

test_max_value_and_positive()

Combining the max_value and positive keyword arguments produces numbers that obey both of those constraints.

test_max_and_min_value_positive_with_decimals()

Combining the max_value and min_value keyword arguments with positive values for each produces numbers that obey both of those constraints.

test_max_none_and_min_value_with_decimals()

Combining the max_value and min_value keyword arguments with positive value for min and None for max produces numbers with left and right digits specified produced numbers greater than the supplied min_value.

test_min_none_and_max_value_with_decimals()

Combining the max_value and min_value keyword arguments with positive value for max and None for min produces numbers with left and right digits specified produced numbers greater than the supplied min_value.

test_max_and_min_value_negative()

Combining the max_value and min_value keyword arguments with negative values for each produces numbers that obey both of those constraints.

test_max_and_min_value_negative_with_decimals()

Combining the max_value and min_value keyword arguments with negative values for each produces numbers that obey both of those constraints.

test_positive_and_min_value_incompatible()

An exception should be raised if positive=True is set, but a negative min_value is provided.

test_positive_doesnt_return_zero()

Choose the right_digits and max_value so it’s guaranteed to return zero, then watch as it doesn’t because positive=True

test_float_min_and_max_value_does_not_warn()

Float arguments to randrange are deprecated from Python 3.10. This is a regression test to check that pyfloat does not cause a deprecation warning.

test_float_min_and_max_value_with_same_whole()
class tests.providers.test_python.TestPydecimal(methodName='runTest')

Bases: unittest.TestCase

A class whose instances are single test cases.

By default, the test code itself should be placed in a method named ‘runTest’.

If the fixture may be used for many test cases, create as many test methods as are needed. When instantiating such a TestCase subclass, specify in the constructor arguments the name of the test method that the instance is to execute.

Test authors should subclass TestCase for their own tests. Construction and deconstruction of the test’s environment (‘fixture’) can be implemented by overriding the ‘setUp’ and ‘tearDown’ methods respectively.

If it is necessary to override the __init__ method, the base class __init__ method must always be called. It is important that subclasses should not change the signature of their __init__ method, since instances of the classes are instantiated automatically by parts of the framework in order to be run.

When subclassing TestCase, you can set these attributes: * failureException: determines which exception will be raised when

the instance’s assertion methods fail; test methods raising this exception will be deemed to have ‘failed’ rather than ‘errored’.

  • longMessage: determines whether long messages (including repr of

    objects used in assert methods) will be printed on failure in addition to any explicit message passed.

  • maxDiff: sets the maximum length of a diff in failure messages

    by assert methods using difflib. It is looked up as an instance attribute so can be configured by individual tests if required.

setUp()

Hook method for setting up the test fixture before exercising it.

test_pydecimal()
test_left_digits()
test_left_digits_can_be_zero()
test_right_digits()
test_positive()
test_min_value()
test_min_value_always_returns_a_decimal()
test_min_value_and_left_digits()

Combining the min_value and left_digits keyword arguments produces numbers that obey both of those constraints.

test_max_value()
test_max_value_always_returns_a_decimal()
test_max_value_zero_and_left_digits()

Combining the max_value and left_digits keyword arguments produces numbers that obey both of those constraints.

test_max_value_should_be_greater_than_min_value()

An exception should be raised if min_value is greater than max_value

test_max_value_and_positive()

Combining the max_value and positive keyword arguments produces numbers that obey both of those constraints.

test_max_and_min_value_negative()

Combining the max_value and min_value keyword arguments with negative values for each produces numbers that obey both of those constraints.

test_positive_and_min_value_incompatible()

An exception should be raised if positive=True is set, but a negative min_value is provided.

test_positive_doesnt_return_zero()

Choose the right_digits and max_value so it’s guaranteed to return zero, then watch as it doesn’t because positive=True

test_min_value_zero_doesnt_return_negative()
test_min_value_one_hundred_doesnt_return_negative()
test_min_value_minus_one_doesnt_return_positive()
test_min_value_minus_one_hundred_doesnt_return_positive()
test_min_value_10_pow_1000_return_greater_number()
class tests.providers.test_python.TestPystr(methodName='runTest')

Bases: unittest.TestCase

A class whose instances are single test cases.

By default, the test code itself should be placed in a method named ‘runTest’.

If the fixture may be used for many test cases, create as many test methods as are needed. When instantiating such a TestCase subclass, specify in the constructor arguments the name of the test method that the instance is to execute.

Test authors should subclass TestCase for their own tests. Construction and deconstruction of the test’s environment (‘fixture’) can be implemented by overriding the ‘setUp’ and ‘tearDown’ methods respectively.

If it is necessary to override the __init__ method, the base class __init__ method must always be called. It is important that subclasses should not change the signature of their __init__ method, since instances of the classes are instantiated automatically by parts of the framework in order to be run.

When subclassing TestCase, you can set these attributes: * failureException: determines which exception will be raised when

the instance’s assertion methods fail; test methods raising this exception will be deemed to have ‘failed’ rather than ‘errored’.

  • longMessage: determines whether long messages (including repr of

    objects used in assert methods) will be printed on failure in addition to any explicit message passed.

  • maxDiff: sets the maximum length of a diff in failure messages

    by assert methods using difflib. It is looked up as an instance attribute so can be configured by individual tests if required.

setUp()

Hook method for setting up the test fixture before exercising it.

test_no_parameters()
test_lower_length_limit()
test_upper_length_limit()
test_invalid_length_limits()
test_exact_length()
test_prefix()
test_suffix()
test_prefix_and_suffix()
class tests.providers.test_python.TestPystrFormat(methodName='runTest')

Bases: unittest.TestCase

A class whose instances are single test cases.

By default, the test code itself should be placed in a method named ‘runTest’.

If the fixture may be used for many test cases, create as many test methods as are needed. When instantiating such a TestCase subclass, specify in the constructor arguments the name of the test method that the instance is to execute.

Test authors should subclass TestCase for their own tests. Construction and deconstruction of the test’s environment (‘fixture’) can be implemented by overriding the ‘setUp’ and ‘tearDown’ methods respectively.

If it is necessary to override the __init__ method, the base class __init__ method must always be called. It is important that subclasses should not change the signature of their __init__ method, since instances of the classes are instantiated automatically by parts of the framework in order to be run.

When subclassing TestCase, you can set these attributes: * failureException: determines which exception will be raised when

the instance’s assertion methods fail; test methods raising this exception will be deemed to have ‘failed’ rather than ‘errored’.

  • longMessage: determines whether long messages (including repr of

    objects used in assert methods) will be printed on failure in addition to any explicit message passed.

  • maxDiff: sets the maximum length of a diff in failure messages

    by assert methods using difflib. It is looked up as an instance attribute so can be configured by individual tests if required.

setUp()

Hook method for setting up the test fixture before exercising it.

test_formatter_invocation()
class tests.providers.test_python.TestPython(methodName='runTest')

Bases: unittest.TestCase

Tests python generators

setUp()

Hook method for setting up the test fixture before exercising it.

test_pybool_return_type()
__test_pybool_truth_probability(truth_probability: int, deviation_threshold: int = 5, iterations: int = 999)
test_pybool_truth_probability_zero()
test_pybool_truth_probability_twenty_five()
test_pybool_truth_probability_fifty()
test_pybool_truth_probability_seventy_five()
test_pybool_truth_probability_hundred()
__test_pybool_invalid_truth_probability(truth_probability: int)
test_pybool_truth_probability_less_than_zero()
test_pybool_truth_probability_more_than_hundred()
test_pytuple()
test_pytuple_size()
test_pylist()
test_pylist_types()