tests.test_fuzz
Module Contents
Classes
A test suite that uses Hypothesis to perform fuzz testing on the multicast sender and receiver. |
Functions
Conditionally enable a class based on the availability of the hypothesis library. |
Data
Hypothesis is not compatible with this project’s license, however for users that accept the relevant terms and conditions of the Hypothesis module and have installed it, the following optional tests extend coverage to leverage hypothesis. |
API
- tests.test_fuzz.__module__[source]
‘tests’
- tests.test_fuzz._has_hypothesis[source]
False
Hypothesis is not compatible with this project’s license, however for users that accept the relevant terms and conditions of the Hypothesis module and have installed it, the following optional tests extend coverage to leverage hypothesis.
Otherwise this file is effectively omitted from testing.
Disclaimer: For clarity this file (as python sourcecode) is Licensed under MIT (the “License”); The resulting python tests (as software) are only provided “AS IS” and WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. The dependencies of the resulting python tests (as software), are NOT covered by the same Licensed. Assembly may be required.
- tests.test_fuzz.onlyIfHasHypothesis(has_hypothesis)[source][source]
Conditionally enable a class based on the availability of the hypothesis library.
If the provided flag is False, returns a dummy class with a placeholder method that does nothing, allowing tests dependent on hypothesis to be safely bypassed. If True, the original class is returned unchanged.
Arguments: has_hypothesis (bool): Flag indicating whether the hypothesis library is available.
Returns: callable: A decorator function that returns either the original class or a dummy class with a placeholder method, depending on the has_hypothesis flag.
- class tests.test_fuzz.HypothesisTestSuite(methodName='runTest')[source][source]
Bases:
context.BasicUsageTestSuiteA test suite that uses Hypothesis to perform fuzz testing on the multicast sender and receiver.
This class extends
context.BasicUsageTestSuiteand 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
hypothesislibrary 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