FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
openai-python/tests/test_deepcopy.py at main · kpdevspace/openai-python · GitHub
kpdevspace
/
openai-python
Public
forked from
openai/openai-python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
openai-python
/
tests
/
test_deepcopy.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
58 lines (41 loc) · 1.52 KB
Breadcrumbs
openai-python
/
tests
/
test_deepcopy.py
Copy path
File metadata and controls
58 lines (41 loc) · 1.52 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from
openai
.
_utils
import
deepcopy_minimal
def
assert_different_identities
(
obj1
:
object
,
obj2
:
object
)
->
None
:
assert
obj1
==
obj2
assert
id
(
obj1
)
!=
id
(
obj2
)
def
test_simple_dict
()
->
None
:
obj1
=
{
"foo"
:
"bar"
}
obj2
=
deepcopy_minimal
(
obj1
)
assert_different_identities
(
obj1
,
obj2
)
def
test_nested_dict
()
->
None
:
obj1
=
{
"foo"
: {
"bar"
:
True
}}
obj2
=
deepcopy_minimal
(
obj1
)
assert_different_identities
(
obj1
,
obj2
)
assert_different_identities
(
obj1
[
"foo"
],
obj2
[
"foo"
])
def
test_complex_nested_dict
()
->
None
:
obj1
=
{
"foo"
: {
"bar"
: [{
"hello"
:
"world"
}]}}
obj2
=
deepcopy_minimal
(
obj1
)
assert_different_identities
(
obj1
,
obj2
)
assert_different_identities
(
obj1
[
"foo"
],
obj2
[
"foo"
])
assert_different_identities
(
obj1
[
"foo"
][
"bar"
],
obj2
[
"foo"
][
"bar"
])
assert_different_identities
(
obj1
[
"foo"
][
"bar"
][
0
],
obj2
[
"foo"
][
"bar"
][
0
])
def
test_simple_list
()
->
None
:
obj1
=
[
"a"
,
"b"
,
"c"
]
obj2
=
deepcopy_minimal
(
obj1
)
assert_different_identities
(
obj1
,
obj2
)
def
test_nested_list
()
->
None
:
obj1
=
[
"a"
, [
1
,
2
,
3
]]
obj2
=
deepcopy_minimal
(
obj1
)
assert_different_identities
(
obj1
,
obj2
)
assert_different_identities
(
obj1
[
1
],
obj2
[
1
])
class
MyObject
: ...
def
test_ignores_other_types
()
->
None
:
# custom classes
my_obj
=
MyObject
()
obj1
=
{
"foo"
:
my_obj
}
obj2
=
deepcopy_minimal
(
obj1
)
assert_different_identities
(
obj1
,
obj2
)
assert
obj1
[
"foo"
]
is
my_obj
# tuples
obj3
=
(
"a"
,
"b"
)
obj4
=
deepcopy_minimal
(
obj3
)
assert
obj3
is
obj4
Back
|
FazBrowse Home
|
New Git URL