Skip to main content

Compare For Testing Overview

Installation

Install from PyPi:

pip install compare-for-testing

Importing

from compare_for_testing import compare  # For compare of 2 objects

Example

json_1 = {
    'a': 1,
    'b': 2,
    'empty': '',
}

json_2 = {
    'aa': True,
    'b': 4,
    'empty': '!empty',
    'empty_failed': '!empty',
}
result = compare(json_2, json_1)

{
    'aa': {'Хотели': True, 'Получили': "Поля 'aa' нет в ответе"},
    'b': {'Хотели': 4, 'Получили': 2},
    'empty_failed': {'Хотели': '!empty', 'Получили': "Поля 'empty_failed' нет в ответе"}
}
json_1 = {

    'c': [
        {
            'sub_a': 1,
            'sub_b': 3
        },
        {
            'sub_a': 2,
            'sub_b': 4
        },
        {
            'sub_a': 3,
            'sub_b': 5,
            'sub_c': {
                'name': 'test',
                'id': 5,
            }
        },
    ],
}

json_2 = {

    'c': [
        {
            'sub_a': 11,
            'sub_b': 43
        },
        {
            'sub_a': 21,
            'sub_b': 4
        },
        {
            'sub_a': '!not_empty',
            'sub_b': '!empty',
            'sub_c': {
                'name': 'test',
                'name2': 'test',
            }
        },
        {
            'sub_a': '!not_empty',
            'sub_b': 8,
            'sub_c': {
                'name': 'test',
            }
        },
    ],
}
result = compare(json_2, json_1)

{
    'c': {
        0: {
            'sub_a': {'Хотели': 11, 'Получили': 1},
            'sub_b': {'Хотели': 43, 'Получили': 3}
        },
        1: {
            'sub_a': {'Хотели': 21, 'Получили': 2}
        },
        2: {
            'sub_b': {'Хотели': '!empty', 'Получили': 5},
            'sub_c': {
                'name2': {'Хотели': 'test', 'Получили': "Поля 'name2' нет в ответе"}
            }
        },
        3: {
            'Хотели': {'sub_a': '!not_empty', 'sub_b': 8, 'sub_c': {'name': 'test'}},
            'Получили': None
        }
    }
}

Release files for compare-for-testing 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for compare-for-testing 1.2.1
File Size Uploaded
compare_for_testing-1.2.1.tar.gz 3.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for compare-for-testing 1.2.1
File Interpreter ABI Platform
compare_for_testing-1.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 7.7 kB

Release files / compare_for_testing-1.2.1.tar.gz

Download URL compare_for_testing-1.2.1.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
37d288d04569753c302ae435e74ae0db56aad008c6c101495b396bb5de903370
BLAKE2b-256 checksum
How to use checksums
5f1f166542de9ed8ad9d291ea73396cb34d0baf76a6e3d4a1f425e4317515fad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.12

Release files / compare_for_testing-1.2.1-py3-none-any.whl

Download URL compare_for_testing-1.2.1-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eb05dd7ede44af979ae3e9ce0d9bf8ce0a638b58227df3e17c6cefecb0d7f840
BLAKE2b-256 checksum
How to use checksums
9a7c0f7fdd4c50c9d98c01a71b688c10f0d259215db5ff915169ee98d80ff041
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.12

Release history Release notifications | RSS feed

This release

1.2.1 This release

2 release files

1.1.4

1 release file

1.1.2

2 release files

1.1.1

1 release file

1.1

2 release files

1.0

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page