File: test_impl.py

package info (click to toggle)
python-convertertools 1.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 388 kB
  • sloc: python: 157; makefile: 19
file content (37 lines) | stat: -rw-r--r-- 1,035 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from pytest_codspeed import BenchmarkFixture

from convertertools.impl import (
    pop_dict_set,
    pop_dict_set_if_none,
    pop_dict_tuple,
)


def test_pop_dict_set_if_none(benchmark: BenchmarkFixture) -> None:
    d = {"a": 1, "b": None, "c": 3}
    benchmark(pop_dict_set_if_none, d, {"a", "b", "d"})
    assert d == {"a": 1, "c": 3}


def test_pop_dict_tuple(benchmark: BenchmarkFixture) -> None:
    d = {"a": 1, "b": 2, "c": 3}
    benchmark(pop_dict_tuple, d, ("a", "b"))
    assert d == {"c": 3}


def test_pop_dict_set(benchmark: BenchmarkFixture) -> None:
    d = {"a": 1, "b": 2, "c": 3}
    benchmark(pop_dict_set, d, {"a", "b"})
    assert d == {"c": 3}


def test_pop_dict_tuple_missing_key(benchmark: BenchmarkFixture) -> None:
    d = {"a": 1, "b": 2, "c": 3}
    benchmark(pop_dict_tuple, d, ("a", "b", "d"))
    assert d == {"c": 3}


def test_pop_dict_set_missing_key(benchmark: BenchmarkFixture) -> None:
    d = {"a": 1, "b": 2, "c": 3}
    benchmark(pop_dict_set, d, {"a", "b", "d"})
    assert d == {"c": 3}