Skip to main content

Identifies duplicate unit tests

Project description

pytest_deduplicate

The pytest_deduplicate is designed to identify duplicate or superseeding unit tests that have the same or bigger code coverage. It can be particularly useful when unit tests are automatically generated based on input/output information for a function, using a large amount of available input data (for example, with the help of the auger library).

This tool groups each test together based on the coverage set. By invoking unit testing with this tool, it will collect code coverage for each test and generate a list of duplicate tests. However, it is important to note that false-positives may occur if, for example, there are regular expressions involved, as the code coverage in such cases may appear the same.

To use simply call:

cd <working_directory>
pytest_deduplicate [pytest_parameters]

Result example:

def function(x):
    if x % 2 == 0:
        for i in range(1, 3):
            print("even")
        return True
    else:
        print("odd")
        return False


    def test_even0(self):
        self.assertEqual(function(0), True)

    def test_even2(self):
        self.assertEqual(function(2), True)

    def test_odd(self):
        self.assertEqual(function(3), False)

    def test_evenodd(self):
        self.assertEqual(function(2), True)
        self.assertEqual(function(3), False)


Superseeded:
tests/test_simple.py:25:1: I002 test TestSimple.test_evenodd covers more code when test(s) below (bigger-coverage)
tests/test_simple.py:16:1: W003 test TestSimple.test_even0 covers less code when TestSimple.test_evenodd test (smaller-coverage)
tests/test_simple.py:19:1: W003 test TestSimple.test_even2 covers less code when TestSimple.test_evenodd test (smaller-coverage)
tests/test_simple.py:22:1: W003 test TestSimple.test_odd covers less code when TestSimple.test_evenodd test (smaller-coverage)


Duplicates:
tests/test_simple.py:16:1: W001 tests with same coverage: TestSimple.test_even0 (duplicate-test)
tests/test_simple.py:19:1: W001 tests with same coverage: TestSimple.test_even2 (duplicate-test)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_deduplicate-0.1.6.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

pytest_deduplicate-0.1.6-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file pytest_deduplicate-0.1.6.tar.gz.

File metadata

  • Download URL: pytest_deduplicate-0.1.6.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for pytest_deduplicate-0.1.6.tar.gz
Algorithm Hash digest
SHA256 581691c6a25918c558f0918e9f17d583b4f88f961b1304acf30d12b672dc73fb
MD5 996ea027487b241fc86335c50341abc7
BLAKE2b-256 f62a66f7f131895df3e599897e65fa32fb7fcd17c2f10f3cad614eed8b59c472

See more details on using hashes here.

File details

Details for the file pytest_deduplicate-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_deduplicate-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 1b1e2f0fc143b814f5cc9d0827454002f498395f9c473cda667359c0edf32546
MD5 1aa9b4b2b433fcf67744b93c74b44faf
BLAKE2b-256 2a536a7874c2603233494f80adf820905614c1a00974b88b46748df0f0bdac19

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page