forked from Gibies/conda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_auxlib.py
44 lines (36 loc) · 1012 Bytes
/
test_auxlib.py
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
38
39
40
41
42
43
44
# Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
from enum import Enum
from typing import TYPE_CHECKING
import pytest
from frozendict import deepfreeze
from conda.auxlib.collection import make_immutable
from conda.base.constants import UpdateModifier
if TYPE_CHECKING:
from typing import Any
IMMUTABLE = (
"text",
42,
42.0,
True,
UpdateModifier.FREEZE_INSTALLED,
(1, 1, 2),
frozenset({1, 1, 2}),
)
MUTABLE = ([1, 1, 2], {1, 1, 2}, {1: 1, 2: 2})
@pytest.mark.parametrize(
"unfrozen",
[
*IMMUTABLE,
*MUTABLE,
# make_immutable leaves a tuple as is, deepfreeze does a better job
# (*IMMUTABLE, *MUTABLE),
[*IMMUTABLE, *MUTABLE],
{*IMMUTABLE},
frozenset({*IMMUTABLE}),
dict(enumerate((*IMMUTABLE, *MUTABLE))),
],
)
def test_deepfreeze(unfrozen: Any) -> None:
assert make_immutable(unfrozen) == deepfreeze(unfrozen, {Enum: lambda x: x})