tests.test_fuzz

Module Contents

Classes

HypothesisTestSuite

A test suite that uses Hypothesis to perform fuzz testing on the multicast sender and receiver.

Data

__module__

API

tests.test_fuzz.__module__[source]

‘tests’

class tests.test_fuzz.HypothesisTestSuite(methodName='runTest')[source][source]

Bases: context.BasicUsageTestSuite

A test suite that uses Hypothesis to perform fuzz testing on the multicast sender and receiver.

This class extends context.BasicUsageTestSuite and provides a test case to verify the robustness of the multicast implementation when handling random binary data of varying sizes.

Methods:

  • test_multicast_sender_with_random_data(self, data): Tests sending and receiving random binary data using the multicast sender and receiver.

Note: This test ensures that the multicast sender and receiver can handle binary data up to 1472 bytes, which is the typical maximum size for UDP packets without fragmentation.

Initialization

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

__module__[source]

‘tests.test_fuzz’

__name__[source]

‘tests.test_fuzz.HypothesisTestSuite’

test_multicast_sender_with_random_data(data)[source][source]

Tests the multicast sender and receiver with random binary data.

This test uses the hypothesis library to generate random binary data between 1 and 1472 bytes, sends it using the multicast sender, and verifies that the multicast receiver successfully receives the data.

Args: data (bytes): Random binary data generated by Hypothesis.

Notes:

  • A random port number is used for each test run to prevent port collisions.

  • The test sets up a receiver process and sends the data multiple times.

  • If the receiver process encounters an error, the test is skipped.

test_invalid_Error_WHEN_cli_called_GIVEN_invalid_fuzz_input(text)[source][source]

Test the multicast CLI’s response to invalid fuzzed input.

This test case uses Hypothesis to generate random strings of ASCII letters and digits, then passes them as arguments to the multicast CLI. It verifies that the CLI correctly identifies and reports these as invalid inputs.

Args: text (str): A randomly generated string of ASCII letters and digits, with length between 3 and 15 characters.

Assertions: - The CLI output contains “invalid choice:” message - The CLI output includes the invalid input text

test_say_works_WHEN_using_stdin_GIVEN_alnum_of_any_size_fuzz_input(text)[source][source]

Test the multicast send response to valid alnum input.

Args: text (str): A randomly generated string of ASCII letters and digits, with length between 56 and 2048 characters.

Assertions: - Verifies that the multicast sender can handle input from stdin - Confirms the process exits successfully after sending the message - Validates the receiver process terminates cleanly