Quickstart

Eager to start? Make sure that Pynguin is installed properly.

Warning

Pynguin actually executes the code of the module under test. That means, if the code you want to generate tests for does something bad, for example wipes your disk, there is nothing that prevents it from doing so! This also includes code that is transitively imported by the module under test.

To mitigate this issue, we recommend running Pynguin in a Docker container with appropriate mounts from the host system’s file system. See the pynguin-docker.sh script in Pynguin’s source repository for documentation on the necessary mounts.

To help prevent harming the system that runs Pynguin, its CLI will immediately abort unless the environment variable PYNGUIN_DANGER_AWARE is set. In setting this variable, you acknowledge that you are aware of the possible dangers of executing code with random inputs. The assigned value can be arbitrary; Pynguin solely checks whether the variable is defined.

We do not provide any support and are not responsible if you break your computer by executing Pynguin on some random code from the internet! Be careful and check the code before actually executing it—which is good advice anyway.

Developers: If you know of a similar technique to Java’s security manager mechanism in Python, which we can use to mitigate this issue, please let us know.

A Simple Example

For a first impression, we use the bundled example file and generate tests for it. Note that this assumes that you have the source code checked out, installed Pynguin properly—as mentioned before, we recommend a virtual environment, which needs to be sourced manually—and that your shell is pointing to the root directory of Pynguin’s source repository. We run all commands on a command-line shell where we assume that the environment variable PYNGUIN_DANGER_AWARE is set.

Note

We don’t use docker in our examples, because we know that our examples do not contain or use code that might harm our system. But for unknown code we highly recommend using some form of isolation.

First, let’s look at the code of the example file (which is located in docs/source/_static/example.py):

1def triangle(x: int, y: int, z: int) -> str:
2    if x == y == z:
3        return "Equilateral triangle"
4    elif x == y or y == z or x == z:
5        return "Isosceles triangle"
6    else:
7        return "Scalene triangle"

The example is the classical triangle example from courses on Software Testing, which yields for three given integers—assumed to be the lengths of the triangle’s edges—what type of triangle it is. Note that we have annotated all parameter and return types, according to PEP 484.

Before we can start, we create a directory for the output (this assumes you are on a Linux or macOS machine, but similar can be done on Windows) using the command line:

$ mkdir -p /tmp/pynguin-results

We will now invoke Pynguin (using its default test-generation algorithm) to let it generate test cases (we use \ and the line breaks for better readability here, you can just omit them and type everything in one line):

$ pynguin \
    --project-path ./docs/source/_static \
    --output-path /tmp/pynguin-results \
    --module-name example

This runs for a moment without showing any output. Thus, to have some more verbose output we add the -v parameter:

$ pynguin \
    --project-path ./docs/source/_static \
    --output-path /tmp/pynguin-results \
    --module-name example \
    -v

The output on the command line might be something like the following:

[13:06:07] INFO     Start Pynguin Test Generation…                                                       generator.py:106
           INFO     Collecting static constants from module under test                                   generator.py:208
           INFO     No constants found                                                                   generator.py:211
           INFO     Setting up runtime collection of constants                                           generator.py:220
           INFO     Analyzed project to create test cluster                                                module.py:1004
           INFO     Modules:       1                                                                       module.py:1005
           INFO     Functions:     1                                                                       module.py:1006
           INFO     Classes:       0                                                                       module.py:1007
           INFO     Using seed 1656500765572043000                                                       generator.py:194
           INFO     Using strategy: Algorithm.DYNAMOSA                                  generationalgorithmfactory.py:267
           INFO     Instantiated 11 fitness functions                                   generationalgorithmfactory.py:353
           INFO     Using CoverageArchive                                               generationalgorithmfactory.py:311
           INFO     Using selection function: Selection.TOURNAMENT_SELECTION            generationalgorithmfactory.py:286
           INFO     No stopping condition configured!                                    generationalgorithmfactory.py:92
           INFO     Using fallback timeout of 600 seconds                                generationalgorithmfactory.py:93
           INFO     Using crossover function: SinglePointRelativeCrossOver              generationalgorithmfactory.py:299
           INFO     Using ranking function: RankBasedPreferenceSorting                  generationalgorithmfactory.py:319
           INFO     Start generating test cases                                                          generator.py:329
           INFO     Initial Population, Coverage: 1.000000                                           searchobserver.py:66
           INFO     Algorithm stopped before using all resources.                                        generator.py:332
           INFO     Stop generating test cases                                                           generator.py:337
           INFO     Start generating assertions                                                          generator.py:358
           INFO     Setup mutation controller                                                       mutationadapter.py:68
           INFO     Build AST for example                                                           mutationadapter.py:54
           INFO     Mutate module example                                                           mutationadapter.py:56
           INFO     Generated 14 mutants                                                            mutationadapter.py:64
[13:06:08] INFO     Running tests on mutant   1/14                                              assertiongenerator.py:223
           INFO     Running tests on mutant   2/14                                              assertiongenerator.py:223
           INFO     Running tests on mutant   3/14                                              assertiongenerator.py:223
           INFO     Running tests on mutant   4/14                                              assertiongenerator.py:223
           INFO     Running tests on mutant   5/14                                              assertiongenerator.py:223
           INFO     Running tests on mutant   6/14                                              assertiongenerator.py:223
           INFO     Running tests on mutant   7/14                                              assertiongenerator.py:223
           INFO     Running tests on mutant   8/14                                              assertiongenerator.py:223
           INFO     Running tests on mutant   9/14                                              assertiongenerator.py:223
           INFO     Running tests on mutant  10/14                                              assertiongenerator.py:223
           INFO     Running tests on mutant  11/14                                              assertiongenerator.py:223
           INFO     Running tests on mutant  12/14                                              assertiongenerator.py:223
           INFO     Running tests on mutant  13/14                                              assertiongenerator.py:223
           INFO     Running tests on mutant  14/14                                              assertiongenerator.py:223
           INFO     Mutant 0 killed by Test(s): 0, 1, 2, 3                                      assertiongenerator.py:267
           INFO     Mutant 1 killed by Test(s): 0, 1, 2, 3                                      assertiongenerator.py:267
           INFO     Mutant 2 killed by Test(s): 0                                               assertiongenerator.py:267
           INFO     Mutant 3 killed by Test(s): 0                                               assertiongenerator.py:267
           INFO     Mutant 4 killed by Test(s): 0, 2, 3                                         assertiongenerator.py:267
           INFO     Mutant 5 killed by Test(s): 0, 2, 3                                         assertiongenerator.py:267
           INFO     Mutant 6 killed by Test(s): 1                                               assertiongenerator.py:267
           INFO     Mutant 7 killed by Test(s): 1                                               assertiongenerator.py:267
           INFO     Mutant 8 killed by Test(s): 0, 2, 3                                         assertiongenerator.py:267
           INFO     Mutant 9 killed by Test(s): 0, 2                                            assertiongenerator.py:267
           INFO     Mutant 10 killed by Test(s): 0, 2                                           assertiongenerator.py:267
           INFO     Mutant 11 killed by Test(s): 0, 1, 2                                        assertiongenerator.py:267
           INFO     Mutant 12 killed by Test(s): 1, 2                                           assertiongenerator.py:267
           INFO     Mutant 13 killed by Test(s): 1, 3                                           assertiongenerator.py:267
           INFO     Surviving Mutant(s): 0 (Nums: )                                             assertiongenerator.py:280
           INFO     Written 4 test cases to /tmp/pynguin-results/test_example.py                         generator.py:483
           INFO     Writing statistics                                                                  statistics.py:354
           INFO     Stop Pynguin Test Generation…                                                        generator.py:109

The first few lines show that Pynguin starts, that it has not gotten any seed for its (pseudo) random-number generator, followed by the configuration options that are used for its DYNAMOSA algorithm. We can also see that it ran zero iterations of that algorithm, i.e., the initial random test cases were sufficient to cover all branches. This was to be expected, since the triangle example can be trivially covered with tests. Pynguin created assertions using Mutation Analysis. The output then concludes with its results: Four test cases were written to /tmp/pynguin/results/test_example.py, which look like the following (the result can differ on your machine):

 1# Automatically generated by Pynguin.
 2import example as module_0
 3
 4
 5def test_case_0():
 6    int_0 = 2649
 7    str_0 = module_0.triangle(int_0, int_0, int_0)
 8    assert str_0 == "Equilateral triangle"
 9    int_1 = -1571
10    str_1 = module_0.triangle(int_0, int_1, int_1)
11    assert str_1 == "Isosceles triangle"
12
13
14def test_case_1():
15    int_0 = 2423
16    int_1 = -3053
17    str_0 = module_0.triangle(int_0, int_0, int_1)
18    assert str_0 == "Isosceles triangle"
19    int_2 = -1391
20    str_1 = module_0.triangle(int_0, int_2, int_2)
21    assert str_1 == "Isosceles triangle"
22    int_3 = -2081
23    str_2 = module_0.triangle(int_3, int_2, int_3)
24    assert str_2 == "Isosceles triangle"
25
26
27def test_case_2():
28    int_0 = -2145
29    str_0 = module_0.triangle(int_0, int_0, int_0)
30    assert str_0 == "Equilateral triangle"
31    int_1 = 1885
32    int_2 = 341
33    str_1 = module_0.triangle(int_1, int_2, int_2)
34    assert str_1 == "Isosceles triangle"
35    int_3 = -912
36    str_2 = module_0.triangle(int_1, int_3, int_1)
37    assert str_2 == "Isosceles triangle"
38
39
40def test_case_3():
41    none_type_0 = None
42    int_0 = 944
43    int_1 = -2515
44    str_0 = module_0.triangle(none_type_0, int_0, int_1)
45    assert str_0 == "Scalene triangle"
46    int_2 = -680
47    int_3 = -3327
48    str_1 = module_0.triangle(int_2, int_2, int_3)
49    assert str_1 == "Isosceles triangle"

We can see that each test case consists of one or more invocations of the triangle function and that there are assertions that check for the correct return value.

Note

As of version 0.6.0, Pynguin is able to generate assertions for simple data types (int, float, str, bytes and bool), as well as checks for None return values.

Note

As of version 0.13.0, Pynguin also provides a better assertion generation based on mutation. This allows to generate assertions also for more complex data types, see assertions for more details.

Note

As of version 0.24.0, Pynguin uses black to format the generated tests.

A more complex example

The above triangle example is really simple and could also be covered by a simple fuzzing tool. Thus, we now look at a more complex example: An implementation of a Queue for int elements. (located in docs/source/_static/queue_example.py):

 1import array
 2from typing import Optional
 3
 4
 5class Queue:
 6    def __init__(self, size_max: int) -> None:
 7        assert size_max > 0
 8        self.max = size_max
 9        self.head = 0
10        self.tail = 0
11        self.size = 0
12        self.data = array.array("i", range(size_max))
13
14    def empty(self) -> bool:
15        return self.size != 0
16
17    def full(self) -> bool:
18        return self.size == self.max
19
20    def enqueue(self, x: int) -> bool:
21        if self.size == self.max:
22            return False
23        self.data[self.tail] = x
24        self.size += 1
25        self.tail += 1
26        if self.tail == self.max:
27            self.tail = 0
28        return True
29
30    def dequeue(self) -> int | None:
31        if self.size == 0:
32            return None
33        x = self.data[self.head]
34        self.size -= 1
35        self.head += 1
36        if self.head == self.max:
37            self.head = 0
38        return x

Testing this queue is more complex. One needs to instantiate it, add items, etc. Similar to the triangle example, we start Pynguin with the following command:

$ pynguin \
    --project-path ./docs/source/_static/ \
    --output-path /tmp/pynguin-results \
    --module-name queue_example \
    -v \
    --seed 1629381673714481067

Note

We used a predefined seed here, because we know that Pynguin requires less iterations with this seed in this specific example and version. This was done to get a clearer log.

The command yields the following output:

[13:06:17] INFO     Start Pynguin Test Generation…                                                       generator.py:106
           INFO     Collecting static constants from module under test                                   generator.py:208
           INFO     No constants found                                                                   generator.py:211
           INFO     Setting up runtime collection of constants                                           generator.py:220
           INFO     Analyzed project to create test cluster                                                module.py:1004
           INFO     Modules:       2                                                                       module.py:1005
           INFO     Functions:     0                                                                       module.py:1006
           INFO     Classes:       3                                                                       module.py:1007
           INFO     Using seed 1629381673714481067                                                       generator.py:194
           INFO     Using strategy: Algorithm.DYNAMOSA                                  generationalgorithmfactory.py:267
           INFO     Instantiated 14 fitness functions                                   generationalgorithmfactory.py:353
           INFO     Using CoverageArchive                                               generationalgorithmfactory.py:311
           INFO     Using selection function: Selection.TOURNAMENT_SELECTION            generationalgorithmfactory.py:286
           INFO     No stopping condition configured!                                    generationalgorithmfactory.py:92
           INFO     Using fallback timeout of 600 seconds                                generationalgorithmfactory.py:93
           INFO     Using crossover function: SinglePointRelativeCrossOver              generationalgorithmfactory.py:299
           INFO     Using ranking function: RankBasedPreferenceSorting                  generationalgorithmfactory.py:319
           INFO     Start generating test cases                                                          generator.py:329
           INFO     Initial Population, Coverage: 0.785714                                           searchobserver.py:66
           INFO     Iteration:       1, Coverage: 0.785714                                           searchobserver.py:70
[13:06:18] INFO     Iteration:       2, Coverage: 0.928571                                           searchobserver.py:70
           INFO     Iteration:       3, Coverage: 0.928571                                           searchobserver.py:70
           INFO     Iteration:       4, Coverage: 1.000000                                           searchobserver.py:70
           INFO     Algorithm stopped before using all resources.                                        generator.py:332
           INFO     Stop generating test cases                                                           generator.py:337
           INFO     Start generating assertions                                                          generator.py:358
           INFO     Setup mutation controller                                                       mutationadapter.py:68
           INFO     Build AST for queue_example                                                     mutationadapter.py:54
           INFO     Mutate module queue_example                                                     mutationadapter.py:56
[13:06:19] INFO     Generated 31 mutants                                                            mutationadapter.py:64
           INFO     Running tests on mutant   1/31                                              assertiongenerator.py:223
           INFO     Running tests on mutant   2/31                                              assertiongenerator.py:223
           INFO     Running tests on mutant   3/31                                              assertiongenerator.py:223
[13:06:20] INFO     Running tests on mutant   4/31                                              assertiongenerator.py:223
           INFO     Running tests on mutant   5/31                                              assertiongenerator.py:223
           INFO     Running tests on mutant   6/31                                              assertiongenerator.py:223
           INFO     Running tests on mutant   7/31                                              assertiongenerator.py:223
           INFO     Running tests on mutant   8/31                                              assertiongenerator.py:223
           INFO     Running tests on mutant   9/31                                              assertiongenerator.py:223
           INFO     Running tests on mutant  10/31                                              assertiongenerator.py:223
           INFO     Running tests on mutant  11/31                                              assertiongenerator.py:223
           INFO     Running tests on mutant  12/31                                              assertiongenerator.py:223
           INFO     Running tests on mutant  13/31                                              assertiongenerator.py:223
           INFO     Running tests on mutant  14/31                                              assertiongenerator.py:223
           INFO     Running tests on mutant  15/31                                              assertiongenerator.py:223
           INFO     Running tests on mutant  16/31                                              assertiongenerator.py:223
           INFO     Running tests on mutant  17/31                                              assertiongenerator.py:223
           INFO     Running tests on mutant  18/31                                              assertiongenerator.py:223
           INFO     Running tests on mutant  19/31                                              assertiongenerator.py:223
           INFO     Running tests on mutant  20/31                                              assertiongenerator.py:223
           INFO     Running tests on mutant  21/31                                              assertiongenerator.py:223
           INFO     Running tests on mutant  22/31                                              assertiongenerator.py:223
           INFO     Running tests on mutant  23/31                                              assertiongenerator.py:223
           INFO     Running tests on mutant  24/31                                              assertiongenerator.py:223
           INFO     Running tests on mutant  25/31                                              assertiongenerator.py:223
           INFO     Running tests on mutant  26/31                                              assertiongenerator.py:223
           INFO     Running tests on mutant  27/31                                              assertiongenerator.py:223
           INFO     Running tests on mutant  28/31                                              assertiongenerator.py:223
           INFO     Running tests on mutant  29/31                                              assertiongenerator.py:223
           INFO     Running tests on mutant  30/31                                              assertiongenerator.py:223
           INFO     Running tests on mutant  31/31                                              assertiongenerator.py:223
           INFO     Mutant 0 killed by Test(s): 2, 4, 5, 6, 7                                   assertiongenerator.py:267
           INFO     Mutant 1 killed by Test(s): 2, 4, 5, 6, 7                                   assertiongenerator.py:267
           INFO     Mutant 2 killed by Test(s): 4, 6, 7                                         assertiongenerator.py:267
           INFO     Mutant 3 killed by Test(s): 4, 6, 7                                         assertiongenerator.py:267
           INFO     Mutant 4 killed by Test(s): 2, 4, 5, 6, 7                                   assertiongenerator.py:267
           INFO     Mutant 5 killed by Test(s): 2, 4, 5, 6, 7                                   assertiongenerator.py:267
           INFO     Mutant 6 killed by Test(s): 3, 4, 6, 7                                      assertiongenerator.py:267
           INFO     Mutant 7 killed by Test(s): 4, 6, 7                                         assertiongenerator.py:267
           INFO     Mutant 8 killed by Test(s): 6, 7                                            assertiongenerator.py:267
           INFO     Mutant 9 killed by Test(s): 0, 2, 3, 4, 5, 6, 7                             assertiongenerator.py:267
           INFO     Mutant 10 killed by Test(s): 0, 2, 3, 4, 5, 6, 7                            assertiongenerator.py:267
           INFO     Mutant 11 killed by Test(s): 0, 2, 3, 4, 5, 6, 7                            assertiongenerator.py:267
           INFO     Mutant 12 killed by Test(s): 0, 2, 3, 4, 5, 6, 7                            assertiongenerator.py:267
           INFO     Mutant 13 killed by Test(s): 0, 2, 3, 4, 5, 6, 7                            assertiongenerator.py:267
           INFO     Mutant 14 killed by Test(s): 5, 6, 7                                        assertiongenerator.py:267
           INFO     Mutant 15 killed by Test(s): 2, 4, 5, 6, 7                                  assertiongenerator.py:267
           INFO     Mutant 16 killed by Test(s): 2, 4, 5, 6, 7                                  assertiongenerator.py:267
           INFO     Mutant 17 killed by Test(s): 6, 7                                           assertiongenerator.py:267
           INFO     Mutant 18 killed by Test(s): 3, 4, 6, 7                                     assertiongenerator.py:267
           INFO     Mutant 19 killed by Test(s): 4, 6, 7                                        assertiongenerator.py:267
           INFO     Mutant 20 killed by Test(s): 4, 6, 7                                        assertiongenerator.py:267
           INFO     Mutant 21 killed by Test(s): 7                                              assertiongenerator.py:267
           INFO     Mutant 23 killed by Test(s): 0, 1, 2, 3, 4, 5, 6, 7                         assertiongenerator.py:267
           INFO     Mutant 24 killed by Test(s): 3                                              assertiongenerator.py:267
           INFO     Mutant 25 killed by Test(s): 5, 6, 7                                        assertiongenerator.py:267
           INFO     Mutant 26 killed by Test(s): 0, 3, 4, 6, 7                                  assertiongenerator.py:267
           INFO     Mutant 27 killed by Test(s): 2, 4, 5, 6, 7                                  assertiongenerator.py:267
           INFO     Mutant 28 killed by Test(s): 2, 4, 5, 6, 7                                  assertiongenerator.py:267
           INFO     Mutant 29 killed by Test(s): 3, 4, 6, 7                                     assertiongenerator.py:267
           INFO     Mutant 30 killed by Test(s): 4, 6, 7                                        assertiongenerator.py:267
           INFO     Surviving Mutant(s): 1 (Nums: 22)                                           assertiongenerator.py:280
[13:06:21] INFO     Written 8 test cases to /tmp/pynguin-results/test_queue_example.py                   generator.py:483
           INFO     Writing statistics                                                                  statistics.py:354
TargetModule: OutputVariable(name='TargetModule', value='queue_example')
Coverage: OutputVariable(name='Coverage', value=1.0)
           INFO     Stop Pynguin Test Generation…                                                        generator.py:109

We can see that the DYNAMOSA algorithm had to perform eight iterations to fully cover the Queue example with the given seed. We can also see that Pynguin generated seven test cases:

  1# Automatically generated by Pynguin.
  2import pytest
  3import queue_example as module_0
  4
  5
  6def test_case_0():
  7    int_0 = 1256
  8    queue_0 = module_0.Queue(int_0)
  9    assert queue_0.max == 1256
 10    assert queue_0.head == 0
 11    assert queue_0.tail == 0
 12    assert queue_0.size == 0
 13    assert len(queue_0.data) == 1256
 14    bool_0 = queue_0.full()
 15    assert bool_0 is False
 16
 17
 18def test_case_1():
 19    int_0 = -2944
 20    with pytest.raises(AssertionError):
 21        module_0.Queue(int_0)
 22
 23
 24def test_case_2():
 25    int_0 = -726
 26    int_1 = 2505
 27    queue_0 = module_0.Queue(int_1)
 28    assert queue_0.max == 2505
 29    assert queue_0.head == 0
 30    assert queue_0.tail == 0
 31    assert queue_0.size == 0
 32    assert len(queue_0.data) == 2505
 33    bool_0 = queue_0.enqueue(int_0)
 34    assert bool_0 is True
 35    assert queue_0.tail == 1
 36    assert queue_0.size == 1
 37    with pytest.raises(AssertionError):
 38        module_0.Queue(int_0)
 39
 40
 41def test_case_3():
 42    int_0 = 2423
 43    queue_0 = module_0.Queue(int_0)
 44    assert queue_0.max == 2423
 45    assert queue_0.head == 0
 46    assert queue_0.tail == 0
 47    assert queue_0.size == 0
 48    assert len(queue_0.data) == 2423
 49    none_type_0 = queue_0.dequeue()
 50    assert none_type_0 is None
 51    bool_0 = queue_0.full()
 52    assert bool_0 is False
 53    with pytest.raises(AssertionError):
 54        module_0.Queue(bool_0)
 55
 56
 57def test_case_4():
 58    int_0 = 1001
 59    queue_0 = module_0.Queue(int_0)
 60    assert queue_0.max == 1001
 61    assert queue_0.head == 0
 62    assert queue_0.tail == 0
 63    assert queue_0.size == 0
 64    assert len(queue_0.data) == 1001
 65    int_1 = 649
 66    queue_1 = module_0.Queue(int_1)
 67    assert queue_1.max == 649
 68    assert queue_1.head == 0
 69    assert queue_1.tail == 0
 70    assert queue_1.size == 0
 71    assert len(queue_1.data) == 649
 72    int_2 = 3263
 73    queue_2 = module_0.Queue(int_2)
 74    assert queue_2.max == 3263
 75    assert queue_2.head == 0
 76    assert queue_2.tail == 0
 77    assert queue_2.size == 0
 78    assert len(queue_2.data) == 3263
 79    bool_0 = queue_2.full()
 80    assert bool_0 is False
 81    int_3 = 2010
 82    bool_1 = queue_1.enqueue(int_3)
 83    assert bool_1 is True
 84    assert queue_1.tail == 1
 85    assert queue_1.size == 1
 86    int_4 = queue_1.dequeue()
 87    assert int_4 == 2010
 88    assert queue_1.head == 1
 89    assert queue_1.size == 0
 90    bool_2 = queue_0.full()
 91    assert bool_2 is False
 92    bool_3 = queue_1.full()
 93    assert bool_3 is False
 94    bool_4 = queue_1.enqueue(int_3)
 95    assert bool_4 is True
 96    assert queue_1.tail == 2
 97    assert queue_1.size == 1
 98    none_type_0 = queue_2.dequeue()
 99    assert none_type_0 is None
100
101
102def test_case_5():
103    int_0 = 1235
104    queue_0 = module_0.Queue(int_0)
105    assert queue_0.max == 1235
106    assert queue_0.head == 0
107    assert queue_0.tail == 0
108    assert queue_0.size == 0
109    assert len(queue_0.data) == 1235
110    queue_1 = module_0.Queue(int_0)
111    assert queue_1.max == 1235
112    assert queue_1.head == 0
113    assert queue_1.tail == 0
114    assert queue_1.size == 0
115    assert len(queue_1.data) == 1235
116    bool_0 = queue_1.empty()
117    assert bool_0 is False
118    int_1 = 4904
119    int_2 = 3504
120    bool_1 = queue_0.empty()
121    assert bool_1 is False
122    queue_2 = module_0.Queue(int_2)
123    assert queue_2.max == 3504
124    assert queue_2.head == 0
125    assert queue_2.tail == 0
126    assert queue_2.size == 0
127    assert len(queue_2.data) == 3504
128    bool_2 = queue_2.enqueue(int_1)
129    assert bool_2 is True
130    assert queue_2.tail == 1
131    assert queue_2.size == 1
132
133
134def test_case_6():
135    int_0 = 1187
136    queue_0 = module_0.Queue(int_0)
137    assert queue_0.max == 1187
138    assert queue_0.head == 0
139    assert queue_0.tail == 0
140    assert queue_0.size == 0
141    assert len(queue_0.data) == 1187
142    bool_0 = queue_0.empty()
143    assert bool_0 is False
144    bool_1 = queue_0.enqueue(int_0)
145    assert bool_1 is True
146    assert queue_0.tail == 1
147    assert queue_0.size == 1
148    queue_1 = module_0.Queue(bool_1)
149    assert queue_1.max is True
150    assert queue_1.head == 0
151    assert queue_1.tail == 0
152    assert queue_1.size == 0
153    assert len(queue_1.data) == 1
154    bool_2 = queue_1.full()
155    assert bool_2 is False
156    int_1 = 1441
157    bool_3 = queue_1.enqueue(int_1)
158    assert bool_3 is True
159    assert queue_1.size == 1
160    bool_4 = queue_1.full()
161    assert bool_4 is True
162    int_2 = 1080
163    queue_2 = module_0.Queue(int_2)
164    assert queue_2.max == 1080
165    assert queue_2.head == 0
166    assert queue_2.tail == 0
167    assert queue_2.size == 0
168    assert len(queue_2.data) == 1080
169    bool_5 = queue_1.full()
170    assert bool_5 is True
171    queue_3 = module_0.Queue(bool_5)
172    assert queue_3.max is True
173    assert queue_3.head == 0
174    assert queue_3.tail == 0
175    assert queue_3.size == 0
176    assert len(queue_3.data) == 1
177    bool_6 = queue_3.empty()
178    assert bool_6 is False
179    bool_7 = queue_1.enqueue(bool_2)
180    assert bool_7 is False
181    bool_8 = queue_1.empty()
182    assert bool_8 is True
183    none_type_0 = queue_2.dequeue()
184    assert none_type_0 is None
185    none_type_1 = queue_3.dequeue()
186    assert none_type_1 is None
187    queue_4 = module_0.Queue(bool_4)
188    assert queue_4.max is True
189    assert queue_4.head == 0
190    assert queue_4.tail == 0
191    assert queue_4.size == 0
192    assert len(queue_4.data) == 1
193    bool_9 = queue_4.empty()
194    assert bool_9 is False
195    int_3 = 2245
196    bool_10 = queue_2.empty()
197    assert bool_10 is False
198    bool_11 = queue_3.empty()
199    assert bool_11 is False
200    bool_12 = queue_0.full()
201    assert bool_12 is False
202    queue_5 = module_0.Queue(int_3)
203    assert queue_5.max == 2245
204    assert queue_5.head == 0
205    assert queue_5.tail == 0
206    assert queue_5.size == 0
207    assert len(queue_5.data) == 2245
208    int_4 = queue_0.dequeue()
209    assert int_4 == 1187
210    assert queue_0.head == 1
211    assert queue_0.size == 0
212    bool_13 = queue_3.empty()
213    assert bool_13 is False
214    none_type_2 = queue_4.dequeue()
215    assert none_type_2 is None
216    int_5 = 481
217    queue_6 = module_0.Queue(int_5)
218    assert queue_6.max == 481
219    assert queue_6.head == 0
220    assert queue_6.tail == 0
221    assert queue_6.size == 0
222    assert len(queue_6.data) == 481
223    none_type_3 = queue_3.dequeue()
224    assert none_type_3 is None
225    bool_14 = queue_6.enqueue(bool_4)
226    assert bool_14 is True
227    assert queue_6.tail == 1
228    assert queue_6.size == 1
229    none_type_4 = queue_3.dequeue()
230    assert none_type_4 is None
231    bool_15 = queue_0.empty()
232    assert bool_15 is False
233    bool_16 = queue_3.full()
234    assert bool_16 is False
235
236
237def test_case_7():
238    int_0 = 1187
239    queue_0 = module_0.Queue(int_0)
240    assert queue_0.max == 1187
241    assert queue_0.head == 0
242    assert queue_0.tail == 0
243    assert queue_0.size == 0
244    assert len(queue_0.data) == 1187
245    bool_0 = queue_0.empty()
246    assert bool_0 is False
247    bool_1 = queue_0.enqueue(int_0)
248    assert bool_1 is True
249    assert queue_0.tail == 1
250    assert queue_0.size == 1
251    queue_1 = module_0.Queue(bool_1)
252    assert queue_1.max is True
253    assert queue_1.head == 0
254    assert queue_1.tail == 0
255    assert queue_1.size == 0
256    assert len(queue_1.data) == 1
257    bool_2 = queue_1.full()
258    assert bool_2 is False
259    int_1 = 1441
260    bool_3 = queue_1.enqueue(int_1)
261    assert bool_3 is True
262    assert queue_1.size == 1
263    bool_4 = queue_1.full()
264    assert bool_4 is True
265    int_2 = 1080
266    queue_2 = module_0.Queue(int_2)
267    assert queue_2.max == 1080
268    assert queue_2.head == 0
269    assert queue_2.tail == 0
270    assert queue_2.size == 0
271    assert len(queue_2.data) == 1080
272    int_3 = queue_1.dequeue()
273    assert int_3 == 1441
274    assert queue_1.size == 0
275    int_4 = queue_0.dequeue()
276    assert int_4 == 1187
277    assert queue_0.head == 1
278    assert queue_0.size == 0
279    bool_5 = queue_2.full()
280    assert bool_5 is False
281    bool_6 = queue_1.enqueue(bool_0)
282    assert bool_6 is True
283    assert queue_1.size == 1
284    int_5 = -30
285    with pytest.raises(AssertionError):
286        module_0.Queue(int_5)

Note

Generated test cases may contain a lot of superfluous statements. Future versions of Pynguin will try minimize test cases as much as possible while retaining their coverage.

Also many generated assertions might be redundant. Minimising these is open for a future release of Pynguin, too.