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    if x in {y, z} or y == z:
5        return "Isosceles triangle"
6    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:

[16:49:40] INFO     Start Pynguin Test Generation…                                                        generator.py:113
           INFO     Collecting static constants from module under test                                    generator.py:215
           INFO     No constants found                                                                    generator.py:218
           INFO     Setting up runtime collection of constants                                            generator.py:227
           INFO     Analyzed project to create test cluster                                                  module.py:888
           INFO     Modules:       1                                                                         module.py:889
           INFO     Functions:     1                                                                         module.py:890
           INFO     Classes:       0                                                                         module.py:891
           INFO     Using seed 1659019779632142080                                                        generator.py:201
           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:399
           INFO     Initial Population, Coverage: 1.000000                                            searchobserver.py:66
           INFO     Algorithm stopped before using all resources.                                         generator.py:402
           INFO     Stop generating test cases                                                            generator.py:407
           INFO     Start generating assertions                                                           generator.py:470
           INFO     Setup mutation controller                                                        mutationadapter.py:68
           INFO     Build AST for example                                                            mutationadapter.py:54
           INFO     Mutate module example                                                            mutationadapter.py:56
[16:49:41] INFO     Generated 14 mutants                                                             mutationadapter.py:64
           INFO     Running tests on mutant   1/14                                               assertiongenerator.py:291
           INFO     Running tests on mutant   2/14                                               assertiongenerator.py:291
           INFO     Running tests on mutant   3/14                                               assertiongenerator.py:291
           INFO     Running tests on mutant   4/14                                               assertiongenerator.py:291
           INFO     Running tests on mutant   5/14                                               assertiongenerator.py:291
           INFO     Running tests on mutant   6/14                                               assertiongenerator.py:291
           INFO     Running tests on mutant   7/14                                               assertiongenerator.py:291
           INFO     Running tests on mutant   8/14                                               assertiongenerator.py:291
           INFO     Running tests on mutant   9/14                                               assertiongenerator.py:291
           INFO     Running tests on mutant  10/14                                               assertiongenerator.py:291
           INFO     Running tests on mutant  11/14                                               assertiongenerator.py:291
           INFO     Running tests on mutant  12/14                                               assertiongenerator.py:291
           INFO     Running tests on mutant  13/14                                               assertiongenerator.py:291
           INFO     Running tests on mutant  14/14                                               assertiongenerator.py:291
           INFO     Mutant 0 killed by Test(s): 0, 1, 2, 3, 4                                    assertiongenerator.py:369
           INFO     Mutant 1 killed by Test(s): 1, 2, 3, 4                                       assertiongenerator.py:369
           INFO     Mutant 2 killed by Test(s): 0, 2, 4                                          assertiongenerator.py:369
           INFO     Mutant 3 killed by Test(s): 0, 2, 4                                          assertiongenerator.py:369
           INFO     Mutant 4 killed by Test(s): 2, 3, 4                                          assertiongenerator.py:369
           INFO     Mutant 5 killed by Test(s): 2, 3, 4                                          assertiongenerator.py:369
           INFO     Mutant 6 killed by Test(s): 1, 2, 3, 4                                       assertiongenerator.py:369
           INFO     Mutant 7 killed by Test(s): 1, 2, 3, 4                                       assertiongenerator.py:369
           INFO     Mutant 8 killed by Test(s): 2, 3, 4                                          assertiongenerator.py:369
           INFO     Mutant 9 killed by Test(s): 0, 2, 3, 4                                       assertiongenerator.py:369
           INFO     Mutant 10 killed by Test(s): 0, 2, 4                                         assertiongenerator.py:369
           INFO     Mutant 11 killed by Test(s): 1, 2, 3, 4                                      assertiongenerator.py:369
           INFO     Mutant 12 killed by Test(s): 1, 2, 3, 4                                      assertiongenerator.py:369
           INFO     Mutant 13 killed by Test(s): 1, 2, 3, 4                                      assertiongenerator.py:369
           INFO     Number of Surviving Mutant(s): 0 (Mutants: )                                 assertiongenerator.py:381
           INFO     Written 5 test cases to /tmp/pynguin-results/test_example.py                          generator.py:569
           INFO     Writing statistics                                                                   statistics.py:354
           INFO     Stop Pynguin Test Generation…                                                         generator.py:116

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: Five 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 = 1907
 7    str_0 = module_0.triangle(int_0, int_0, int_0)
 8    assert str_0 == "Equilateral triangle"
 9
10
11def test_case_1():
12    int_0 = 2850
13    int_1 = -1201
14    none_type_0 = None
15    str_0 = module_0.triangle(int_0, int_1, none_type_0)
16    assert str_0 == "Scalene triangle"
17
18
19def test_case_2():
20    int_0 = -1426
21    int_1 = 2540
22    str_0 = module_0.triangle(int_0, int_0, int_1)
23    assert str_0 == "Isosceles triangle"
24    int_2 = -463
25    int_3 = -773
26    int_4 = 50
27    str_1 = module_0.triangle(int_2, int_3, int_4)
28    assert str_1 == "Scalene triangle"
29    str_2 = module_0.triangle(int_2, int_2, int_2)
30    assert str_2 == "Equilateral triangle"
31
32
33def test_case_3():
34    int_0 = -1532
35    int_1 = 1198
36    str_0 = module_0.triangle(int_0, int_1, int_1)
37    assert str_0 == "Isosceles triangle"
38    str_1 = module_0.triangle(int_0, int_1, int_1)
39    assert str_1 == "Isosceles triangle"
40    none_type_0 = None
41    int_2 = 1758
42    int_3 = -649
43    str_2 = module_0.triangle(none_type_0, int_2, int_3)
44    assert str_2 == "Scalene triangle"
45
46
47def test_case_4():
48    int_0 = -954
49    str_0 = module_0.triangle(int_0, int_0, int_0)
50    assert str_0 == "Equilateral triangle"
51    int_1 = -2339
52    int_2 = 1529
53    int_3 = -1878
54    str_1 = module_0.triangle(int_1, int_2, int_3)
55    assert str_1 == "Scalene triangle"
56    int_4 = 672
57    str_2 = module_0.triangle(int_1, int_4, int_1)
58    assert str_2 == "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
 2
 3
 4class Queue:
 5    def __init__(self, size_max: int) -> None:
 6        assert size_max > 0
 7        self.max = size_max
 8        self.head = 0
 9        self.tail = 0
10        self.size = 0
11        self.data = array.array("i", range(size_max))
12
13    def empty(self) -> bool:
14        return self.size != 0
15
16    def full(self) -> bool:
17        return self.size == self.max
18
19    def enqueue(self, x: int) -> bool:
20        if self.size == self.max:
21            return False
22        self.data[self.tail] = x
23        self.size += 1
24        self.tail += 1
25        if self.tail == self.max:
26            self.tail = 0
27        return True
28
29    def dequeue(self) -> int | None:
30        if self.size == 0:
31            return None
32        x = self.data[self.head]
33        self.size -= 1
34        self.head += 1
35        if self.head == self.max:
36            self.head = 0
37        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:

[16:39:14] INFO     Start Pynguin Test Generation…                                                        generator.py:113
           INFO     Collecting static constants from module under test                                    generator.py:215
           INFO     No constants found                                                                    generator.py:218
           INFO     Setting up runtime collection of constants                                            generator.py:227
           INFO     Analyzed project to create test cluster                                                  module.py:888
           INFO     Modules:       2                                                                         module.py:889
           INFO     Functions:     0                                                                         module.py:890
           INFO     Classes:       3                                                                         module.py:891
           INFO     Using seed 1629381673714481067                                                        generator.py:201
           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:399
           INFO     Initial Population, Coverage: 0.785714                                            searchobserver.py:66
           INFO     Iteration:       1, Coverage: 0.785714                                            searchobserver.py:70
           INFO     Iteration:       2, Coverage: 0.928571                                            searchobserver.py:70
           INFO     Iteration:       3, Coverage: 0.928571                                            searchobserver.py:70
[16:39:15] INFO     Iteration:       4, Coverage: 1.000000                                            searchobserver.py:70
           INFO     Algorithm stopped before using all resources.                                         generator.py:402
           INFO     Stop generating test cases                                                            generator.py:407
           INFO     Start generating assertions                                                           generator.py:470
           INFO     Setup mutation controller                                                        mutationadapter.py:68
           INFO     Build AST for queue_example                                                      mutationadapter.py:54
           INFO     Mutate module queue_example                                                      mutationadapter.py:56
[16:39:16] INFO     Generated 31 mutants                                                             mutationadapter.py:64
           INFO     Running tests on mutant   1/31                                               assertiongenerator.py:291
           INFO     Running tests on mutant   2/31                                               assertiongenerator.py:291
           INFO     Running tests on mutant   3/31                                               assertiongenerator.py:291
           INFO     Running tests on mutant   4/31                                               assertiongenerator.py:291
           INFO     Running tests on mutant   5/31                                               assertiongenerator.py:291
           INFO     Running tests on mutant   6/31                                               assertiongenerator.py:291
           INFO     Running tests on mutant   7/31                                               assertiongenerator.py:291
           INFO     Running tests on mutant   8/31                                               assertiongenerator.py:291
           INFO     Running tests on mutant   9/31                                               assertiongenerator.py:291
           INFO     Running tests on mutant  10/31                                               assertiongenerator.py:291
           INFO     Running tests on mutant  11/31                                               assertiongenerator.py:291
           INFO     Running tests on mutant  12/31                                               assertiongenerator.py:291
           INFO     Running tests on mutant  13/31                                               assertiongenerator.py:291
           INFO     Running tests on mutant  14/31                                               assertiongenerator.py:291
           INFO     Running tests on mutant  15/31                                               assertiongenerator.py:291
           INFO     Running tests on mutant  16/31                                               assertiongenerator.py:291
           INFO     Running tests on mutant  17/31                                               assertiongenerator.py:291
           INFO     Running tests on mutant  18/31                                               assertiongenerator.py:291
           INFO     Running tests on mutant  19/31                                               assertiongenerator.py:291
           INFO     Running tests on mutant  20/31                                               assertiongenerator.py:291
           INFO     Running tests on mutant  21/31                                               assertiongenerator.py:291
           INFO     Running tests on mutant  22/31                                               assertiongenerator.py:291
           INFO     Running tests on mutant  23/31                                               assertiongenerator.py:291
           INFO     Running tests on mutant  24/31                                               assertiongenerator.py:291
           INFO     Running tests on mutant  25/31                                               assertiongenerator.py:291
           INFO     Running tests on mutant  26/31                                               assertiongenerator.py:291
           INFO     Running tests on mutant  27/31                                               assertiongenerator.py:291
           INFO     Running tests on mutant  28/31                                               assertiongenerator.py:291
[16:39:17] INFO     Running tests on mutant  29/31                                               assertiongenerator.py:291
           INFO     Running tests on mutant  30/31                                               assertiongenerator.py:291
           INFO     Running tests on mutant  31/31                                               assertiongenerator.py:291
           INFO     Mutant 0 killed by Test(s): 1, 2, 3, 4, 5, 6, 7                              assertiongenerator.py:369
           INFO     Mutant 1 killed by Test(s): 1, 2, 3, 4, 5, 6, 7                              assertiongenerator.py:369
           INFO     Mutant 2 killed by Test(s): 1, 2, 3, 4, 6, 7                                 assertiongenerator.py:369
           INFO     Mutant 3 killed by Test(s): 1, 2, 3, 4, 6, 7                                 assertiongenerator.py:369
           INFO     Mutant 4 killed by Test(s): 1, 2, 3, 4, 5, 6, 7                              assertiongenerator.py:369
           INFO     Mutant 5 killed by Test(s): 1, 2, 3, 4, 5, 6, 7                              assertiongenerator.py:369
           INFO     Mutant 6 killed by Test(s): 1, 2, 3, 4, 6, 7                                 assertiongenerator.py:369
           INFO     Mutant 7 killed by Test(s): 1, 2, 3, 4, 6, 7                                 assertiongenerator.py:369
           INFO     Mutant 8 killed by Test(s): 1, 2, 3, 6, 7                                    assertiongenerator.py:369
           INFO     Mutant 9 killed by Test(s): 0, 1, 2, 3, 4, 5, 6, 7                           assertiongenerator.py:369
           INFO     Mutant 10 killed by Test(s): 0, 1, 2, 3, 4, 5, 6, 7                          assertiongenerator.py:369
           INFO     Mutant 11 killed by Test(s): 0, 1, 2, 3, 4, 5, 6, 7                          assertiongenerator.py:369
           INFO     Mutant 12 killed by Test(s): 0, 1, 2, 3, 4, 5, 6, 7                          assertiongenerator.py:369
           INFO     Mutant 13 killed by Test(s): 0, 1, 2, 3, 4, 5, 6, 7                          assertiongenerator.py:369
           INFO     Mutant 14 killed by Test(s): 1, 2, 3, 5, 6, 7                                assertiongenerator.py:369
           INFO     Mutant 15 killed by Test(s): 1, 2, 3, 4, 5, 6, 7                             assertiongenerator.py:369
           INFO     Mutant 16 killed by Test(s): 1, 2, 3, 4, 5, 6, 7                             assertiongenerator.py:369
           INFO     Mutant 17 killed by Test(s): 1, 2, 3, 7                                      assertiongenerator.py:369
           INFO     Mutant 18 killed by Test(s): 1, 2, 3, 4, 6, 7                                assertiongenerator.py:369
           INFO     Mutant 19 killed by Test(s): 1, 2, 3, 4, 6, 7                                assertiongenerator.py:369
           INFO     Mutant 20 killed by Test(s): 1, 2, 3, 4, 6, 7                                assertiongenerator.py:369
           INFO     Mutant 21 killed by Test(s): 1, 2, 3, 7                                      assertiongenerator.py:369
           INFO     Mutant 22 killed by Test(s): 1, 2, 3, 7                                      assertiongenerator.py:369
           INFO     Mutant 23 killed by Test(s): 0, 1, 2, 3, 4, 5, 6, 7                          assertiongenerator.py:369
           INFO     Mutant 24 killed by Test(s): 1, 2, 3, 7                                      assertiongenerator.py:369
           INFO     Mutant 25 killed by Test(s): 1, 2, 3, 5, 6, 7                                assertiongenerator.py:369
           INFO     Mutant 26 killed by Test(s): 0, 1, 2, 3, 4, 6, 7                             assertiongenerator.py:369
           INFO     Mutant 27 killed by Test(s): 1, 2, 3, 4, 5, 6, 7                             assertiongenerator.py:369
           INFO     Mutant 28 killed by Test(s): 1, 2, 3, 4, 5, 6, 7                             assertiongenerator.py:369
           INFO     Mutant 29 killed by Test(s): 1, 2, 3, 4, 6, 7                                assertiongenerator.py:369
           INFO     Mutant 30 killed by Test(s): 1, 2, 3, 4, 6, 7                                assertiongenerator.py:369
           INFO     Number of Surviving Mutant(s): 0 (Mutants: )                                 assertiongenerator.py:381
           INFO     Written 8 test cases to /tmp/pynguin-results/test_queue_example.py                    generator.py:569
           INFO     Writing statistics                                                                   statistics.py:354
           INFO     Stop Pynguin Test Generation…                                                         generator.py:116

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