Debian Codegraph @

test/units/vars/test_module_response_deepcopy.py

raw
1 # -*- coding: utf-8 -*-
2 # (c) 2018 Matt Martz <[email protected]>
3 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
4
5 from __future__ import annotations
6
7 from ansible.vars.clean import module_response_deepcopy
8
9
10 def test_module_response_deepcopy_basic():
11 x = 42
12 y = module_response_deepcopy(x)
13 assert y == x
14
15
16 def test_module_response_deepcopy_atomic():
17 tests = [None, 42, 2**100, 3.14, True, False, 1j,
18 "hello", u"hello\u1234"]
19 for x in tests:
20 assert module_response_deepcopy(x) is x
21
22
23 def test_module_response_deepcopy_list():
24 x = [[1, 2], 3]
25 y = module_response_deepcopy(x)
26 assert y == x
27 assert x is not y
28 assert x[0] is not y[0]
29
30
31 def test_module_response_deepcopy_empty_tuple():
32 x = ()
33 y = module_response_deepcopy(x)
34 assert x is y
35
36
37 def test_module_response_deepcopy_tuple_of_immutables():
38 x = ((1, 2), 3)
39 y = module_response_deepcopy(x)
40 assert x is y
41
42
43 def test_module_response_deepcopy_dict():
44 x = {"foo": [1, 2], "bar": 3}
45 y = module_response_deepcopy(x)
46 assert y == x
47 assert x is not y
48 assert x["foo"] is not y["foo"]