Home / File/ test_deepcopy.py — anthropic-sdk-python Source File

test_deepcopy.py — anthropic-sdk-python Source File

Architecture documentation for test_deepcopy.py, a python file in the anthropic-sdk-python codebase. 1 imports, 0 dependents.

File python AnthropicClient Authentication 1 imports 7 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  5a5ceb11_6dab_b4b1_afa8_f2e3fd683d45["test_deepcopy.py"]
  d1009234_f799_7c53_7892_4262523206dd["anthropic._utils"]
  5a5ceb11_6dab_b4b1_afa8_f2e3fd683d45 --> d1009234_f799_7c53_7892_4262523206dd
  style 5a5ceb11_6dab_b4b1_afa8_f2e3fd683d45 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from anthropic._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

Subdomains

Classes

Dependencies

  • anthropic._utils

Frequently Asked Questions

What does test_deepcopy.py do?
test_deepcopy.py is a source file in the anthropic-sdk-python codebase, written in python. It belongs to the AnthropicClient domain, Authentication subdomain.
What functions are defined in test_deepcopy.py?
test_deepcopy.py defines 7 function(s): assert_different_identities, test_complex_nested_dict, test_ignores_other_types, test_nested_dict, test_nested_list, test_simple_dict, test_simple_list.
What does test_deepcopy.py depend on?
test_deepcopy.py imports 1 module(s): anthropic._utils.
Where is test_deepcopy.py in the architecture?
test_deepcopy.py is located at tests/test_deepcopy.py (domain: AnthropicClient, subdomain: Authentication, directory: tests).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free