repo_id
stringclasses
409 values
prefix
large_stringlengths
34
36.3k
target
large_stringlengths
1
498
assertion_type
stringclasses
31 values
difficulty
stringclasses
8 values
test_file
stringlengths
10
121
test_function
stringlengths
1
104
test_class
stringlengths
0
51
lineno
int32
2
11.3k
commit_idx
int32
matthewwardrop/formulaic
import pytest from formulaic.parser.types import Factor, Term from formulaic.parser.types.ordered_set import OrderedSet class TestTerm: def term1(self): return Term([Factor("c"), Factor("b")]) def term2(self): return Term([Factor("c"), Factor("d")]) def term3(self): return Term(...
3
assert
numeric_literal
tests/parser/types/test_term.py
test_degree
TestTerm
49
null
matthewwardrop/formulaic
import pickle import re from io import BytesIO from xml.etree.ElementInclude import include import pytest from formulaic.errors import FormulaParsingError, FormulaSyntaxError from formulaic.parser import DefaultFormulaParser, DefaultOperatorResolver from formulaic.parser.types import Token from formulaic.parser.types...
2
assert
numeric_literal
tests/parser/test_parser.py
test_feature_flags
TestFormulaParser
270
null
matthewwardrop/formulaic
from formulaic.parser.types import OrderedSet def test_ordered_set(): assert OrderedSet() == OrderedSet() assert len(OrderedSet()) == 0 assert list(OrderedSet(["a", "a", "z", "b"])) == ["a", "z", "b"] assert repr(OrderedSet(["z", "b", "c"])) == "{'z', 'b', 'c'}" assert OrderedSet(["z", "k"]) | ["...
OrderedSet("ba")
assert
func_call
tests/parser/types/test_ordered_set.py
test_ordered_set
13
null
matthewwardrop/formulaic
import pytest from formulaic.parser.types import Factor, Term from formulaic.parser.types.ordered_set import OrderedSet class TestTerm: def term1(self): return Term([Factor("c"), Factor("b")]) def term2(self): return Term([Factor("c"), Factor("d")]) def term3(self): return Term(...
"c:b"
assert
string_literal
tests/parser/types/test_term.py
test_repr
TestTerm
45
null
matthewwardrop/formulaic
import pytest from formulaic.materializers.types import EvaluatedFactor, FactorValues from formulaic.parser.types import Factor class TestEvaluatedFactor: def ev_factor(self): return EvaluatedFactor(Factor("a"), FactorValues([1, 2, 3], kind="numerical")) def test_attributes(self, ev_factor): ...
"a"
assert
string_literal
tests/materializers/types/test_evaluated_factor.py
test_attributes
TestEvaluatedFactor
14
null
matthewwardrop/formulaic
import pytest from formulaic.errors import FormulaSyntaxError from formulaic.parser.algos.tokenize import tokenize TOKEN_TESTS = { "": [], "a": ["name:a"], "a+b": ["name:a", "operator:+", "name:b"], "a + b": ["name:a", "operator:+", "name:b"], "a * b": ["name:a", "operator:*", "name:b"], "a * ...
tokens
assert
variable
tests/parser/algos/test_tokenize.py
test_tokenize
95
null
matthewwardrop/formulaic
import pytest from formulaic.parser.types import Factor class TestFactor: def factor_unknown(self): return Factor("unknown") def factor_literal(self): return Factor('"string"', kind="literal") def factor_lookup(self): return Factor("a", kind="lookup") def test_attributes(se...
Factor.Kind.CONSTANT
assert
complex_expr
tests/parser/types/test_factor.py
test_attributes
TestFactor
21
null
matthewwardrop/formulaic
import pickle import re from io import BytesIO import pandas import pytest from formulaic import Formula, SimpleFormula, StructuredFormula from formulaic.errors import FormulaInvalidError, FormulaMaterializerInvalidError from formulaic.parser.types.factor import Factor from formulaic.parser.types.term import Term fro...
f
assert
variable
tests/test_formula.py
test_constructor
TestFormula
81
null
matthewwardrop/formulaic
import json import os import numpy import numpy as np import pandas import pandas as pd import pytest from formulaic import model_matrix from formulaic.transforms.cubic_spline import ( ExtrapolationError, _get_all_sorted_knots, _map_cyclic, cubic_spline, cyclic_cubic_spline, natural_cubic_spli...
x_orig)
assert_*
variable
tests/transforms/test_cubic_spline.py
test_map_cyclic
44
null
matthewwardrop/formulaic
import pytest from formulaic.parser.types import Operator class TestOperator: def test_attributes(self): op1 = Operator("~", arity=2, precedence=100) assert op1.associativity ==
Operator.Associativity.NONE
assert
complex_expr
tests/parser/types/test_operator.py
test_attributes
TestOperator
9
null
matthewwardrop/formulaic
import re import pytest from formulaic.parser.types import Factor, Term from formulaic.utils.calculus import _differentiate_factors, differentiate_term def test_differentiate_term(): t = Term([Factor("a"), Factor("log(b)")]) assert str(differentiate_term(t, ["a"])) == "log(b)" assert str(differentiate_...
"a"
assert
string_literal
tests/utils/test_calculus.py
test_differentiate_term
13
null
matthewwardrop/formulaic
import pickle import re from io import BytesIO import numpy import pandas import pytest import scipy.sparse as spsparse from formulaic import ModelMatrices from formulaic.errors import ( FactorEncodingError, FactorEvaluationError, FormulaMaterializationError, ) from formulaic.materializers import PandasMa...
[1]
assert
collection
tests/materializers/test_pandas.py
test_data_conversion
TestPandasMaterializer
128
null
matthewwardrop/formulaic
import pytest from formulaic.parser.types import Operator class TestOperator: def test_attributes(self): op1 = Operator("~", arity=2, precedence=100) assert op1.associativity == Operator.Associativity.NONE assert op1.fixity ==
Operator.Fixity.INFIX
assert
complex_expr
tests/parser/types/test_operator.py
test_attributes
TestOperator
10
null
matthewwardrop/formulaic
import pickle import re from io import BytesIO from xml.etree.ElementInclude import include import pytest from formulaic.errors import FormulaParsingError, FormulaSyntaxError from formulaic.parser import DefaultFormulaParser, DefaultOperatorResolver from formulaic.parser.types import Token from formulaic.parser.types...
1
assert
numeric_literal
tests/parser/test_parser.py
test_resolve
TestDefaultOperatorResolver
316
null
matthewwardrop/formulaic
import pickle import re from io import BytesIO import numpy import pandas import pytest import scipy.sparse as spsparse from formulaic import ModelMatrices from formulaic.errors import ( FactorEncodingError, FactorEvaluationError, FormulaMaterializationError, ) from formulaic.materializers import PandasMa...
1
assert
numeric_literal
tests/materializers/test_pandas.py
test_none_values
TestPandasMaterializer
488
null
matthewwardrop/formulaic
import re from pyexpat import model import numpy import pandas import pytest import scipy.sparse from formulaic import Formula, ModelMatrices, ModelMatrix, ModelSpec, ModelSpecs from formulaic.materializers.base import FormulaMaterializerMeta from formulaic.materializers.pandas import PandasMaterializer from formulai...
{"A"}
assert
collection
tests/test_model_spec.py
test_attributes
TestModelSpec
100
null
matthewwardrop/formulaic
import pickle import re from io import BytesIO import pandas import pytest from formulaic import Formula, SimpleFormula, StructuredFormula from formulaic.errors import FormulaInvalidError, FormulaMaterializerInvalidError from formulaic.parser.types.factor import Factor from formulaic.parser.types.term import Term fro...
s2
assert
variable
tests/test_formula.py
test_pickling
TestStructuredFormula
403
null
matthewwardrop/formulaic
import json import os import numpy import numpy as np import pandas import pandas as pd import pytest from formulaic import model_matrix from formulaic.transforms.cubic_spline import ( ExtrapolationError, _get_all_sorted_knots, _map_cyclic, cubic_spline, cyclic_cubic_spline, natural_cubic_spli...
res[2])
assert_*
complex_expr
tests/transforms/test_cubic_spline.py
test_cubic_spline_edges
295
null
matthewwardrop/formulaic
import copy import pickle import numpy import pandas import pytest from formulaic import ( FactorValues, ModelMatrices, ModelMatrix, ModelSpec, ModelSpecs, model_matrix, ) def test_factor_values_copy(): d = {"1": object()} f = FactorValues(d, drop_field="test") f2 = copy.copy(f) ...
d
assert
variable
tests/test_model_matrix.py
test_factor_values_copy
47
null
matthewwardrop/formulaic
import pickle import re from io import BytesIO import pytest from formulaic.utils.structured import Structured class TestStructured: def test_equality(self): assert Structured() == Structured() assert Structured(1) != Structured() assert Structured(1) == Structured(1) assert Stru...
object()
assert
func_call
tests/parser/types/test_structured.py
test_equality
TestStructured
237
null
matthewwardrop/formulaic
import numpy import pytest from formulaic.transforms.poly import poly class TestPoly: def data(self): return numpy.linspace(0, 1, 21) def test_basic(self, data): state = {} V = poly(data, _state=state) assert V.shape[1] == 1 # Comparison data copied from R output of...
{0: 0.5})
pytest.approx
collection
tests/transforms/test_poly.py
test_basic
TestPoly
50
null
matthewwardrop/formulaic
import re import pandas import pyarrow import pytest from formulaic.errors import FactorEncodingError, FormulaMaterializerNotFoundError from formulaic.materializers.base import FormulaMaterializer from formulaic.materializers.narwhals import NarwhalsMaterializer from formulaic.materializers.pandas import PandasMateri...
sorted(["A-:b", "b"])
assert
func_call
tests/materializers/test_base.py
test__get_scoped_terms_spanned_by_evaled_factors
TestFormulaMaterializer
105
null
matthewwardrop/formulaic
import numpy import pandas as pd import pytest import scipy.sparse as spsparse from formulaic import model_matrix from formulaic.materializers import FactorValues from formulaic.transforms.hashed import hashed def _compare_factor_values(a, b, comp=lambda x, y: numpy.allclose(x, y)): assert type(a) is type(b) ...
levels
assert
variable
tests/transforms/test_hashed.py
test_usage_in_model_matrix
60
null
matthewwardrop/formulaic
import re from pyexpat import model import numpy import pandas import pytest import scipy.sparse from formulaic import Formula, ModelMatrices, ModelMatrix, ModelSpec, ModelSpecs from formulaic.materializers.base import FormulaMaterializerMeta from formulaic.materializers.pandas import PandasMaterializer from formulai...
[0, 1]
assert
collection
tests/test_model_spec.py
test_get_term_indices
TestModelSpec
116
null
matthewwardrop/formulaic
import numpy import pandas from scipy.sparse import csc_matrix from formulaic.utils.sparse import categorical_encode_series_to_sparse_csc_matrix def test_sparse_category_encoding(): data = pandas.Series(list("abcdefgabcdefg")) levels, encoded = categorical_encode_series_to_sparse_csc_matrix(data) ( ...
[]
assert
collection
tests/utils/test_sparse.py
test_sparse_category_encoding
62
null
matthewwardrop/formulaic
import pytest from formulaic.parser.types import Factor, Term from formulaic.parser.types.ordered_set import OrderedSet class TestTerm: def term1(self): return Term([Factor("c"), Factor("b")]) def term2(self): return Term([Factor("c"), Factor("d")]) def term3(self): return Term(...
OrderedSet((term1,))
assert
func_call
tests/parser/types/test_term.py
test_to_terms
TestTerm
54
null
matthewwardrop/formulaic
import json import os import numpy import numpy as np import pandas import pandas as pd import pytest from formulaic import model_matrix from formulaic.transforms.cubic_spline import ( ExtrapolationError, _get_all_sorted_knots, _map_cyclic, cubic_spline, cyclic_cubic_spline, natural_cubic_spli...
[1, 5])
assert_*
collection
tests/transforms/test_cubic_spline.py
test_get_all_sorted_knots
70
null
matthewwardrop/formulaic
import copy import pickle from formulaic.materializers.types import FactorValues def test_factor_values_copy(): d = {"1": object()} f = FactorValues(d, drop_field="test") f2 = copy.copy(f) assert f2.__wrapped__ ==
d
assert
variable
tests/materializers/types/test_factor_values.py
test_factor_values_copy
12
null
matthewwardrop/formulaic
import pickle import re from io import BytesIO import pandas import pytest from formulaic import Formula, SimpleFormula, StructuredFormula from formulaic.errors import FormulaInvalidError, FormulaMaterializerInvalidError from formulaic.parser.types.factor import Factor from formulaic.parser.types.term import Term fro...
"c"
assert
string_literal
tests/test_formula.py
test_sequencing
TestSimpleFormula
304
null
matthewwardrop/formulaic
from typing import Any import pandas import pytest import scipy.sparse from formulaic.materializers import FormulaMaterializer DATASET = pandas.DataFrame( { "a": [1, 2, None], "b": [1, 2, 3], "A": ["a", None, "c"], "B": ["a", "b", None], "D": ["a", "a", "a"], } ) TEST...
"numpy"
assert
string_literal
tests/materializers/test_equivalence.py
assert_equivalent
165
null
matthewwardrop/formulaic
import re import numpy import pandas import pytest import scipy.sparse as spsparse from formulaic import model_matrix from formulaic.errors import DataMismatchWarning from formulaic.materializers import FactorValues from formulaic.model_spec import ModelSpec from formulaic.transforms.contrasts import ( ContrastsR...
None
assert
none_literal
tests/transforms/test_contrasts.py
test_sparse
TestTreatmentContrasts
404
null
matthewwardrop/formulaic
import pytest from formulaic.materializers.types import EvaluatedFactor, ScopedFactor, ScopedTerm from formulaic.parser.types import Factor from formulaic.utils.variables import Variable class TestScopedTerm: def scoped_term(self): return ScopedTerm( [ ScopedFactor( ...
hash(())
assert
func_call
tests/materializers/types/test_scoped_term.py
test_hash
TestScopedTerm
32
null
matthewwardrop/formulaic
import re import numpy import pandas import pytest import scipy.sparse as spsparse from formulaic import model_matrix from formulaic.errors import DataMismatchWarning from formulaic.materializers import FactorValues from formulaic.model_spec import ModelSpec from formulaic.transforms.contrasts import ( ContrastsR...
"a"
assert
string_literal
tests/transforms/test_contrasts.py
test_sparse
TestTreatmentContrasts
417
null
matthewwardrop/formulaic
import pytest from formulaic.parser.types import Term, Token class TestToken: def token_a(self): return Token("a", kind="name") def token_b(self): return Token( "log(x)", kind="python", source="y ~ log(x)", source_start=4, source_end=9 ) def token_c(self): re...
1
assert
numeric_literal
tests/parser/types/test_token.py
test_update
TestToken
25
null
matthewwardrop/formulaic
import pickle import re from io import BytesIO import pandas import pytest from formulaic import Formula, SimpleFormula, StructuredFormula from formulaic.errors import FormulaInvalidError, FormulaMaterializerInvalidError from formulaic.parser.types.factor import Factor from formulaic.parser.types.term import Term fro...
1
assert
numeric_literal
tests/test_formula.py
test_equality
TestFormula
228
null
matthewwardrop/formulaic
import pickle import re from io import BytesIO import pandas import pytest from formulaic import Formula, SimpleFormula, StructuredFormula from formulaic.errors import FormulaInvalidError, FormulaMaterializerInvalidError from formulaic.parser.types.factor import Factor from formulaic.parser.types.term import Term fro...
"a:b"
assert
string_literal
tests/test_formula.py
test_sequencing
TestSimpleFormula
305
null
matthewwardrop/formulaic
import pickle import re from io import BytesIO import pandas import pytest from formulaic import Formula, SimpleFormula, StructuredFormula from formulaic.errors import FormulaInvalidError, FormulaMaterializerInvalidError from formulaic.parser.types.factor import Factor from formulaic.parser.types.term import Term fro...
["c"]
assert
collection
tests/test_formula.py
test_sequencing
TestSimpleFormula
306
null
anthropics/anthropic-sdk-python
import operator from typing import Any from typing_extensions import override from anthropic._utils import LazyProxy def test_recursive_proxy() -> None: proxy = RecursiveLazyProxy() assert repr(proxy) == "RecursiveLazyProxy" assert str(proxy) == "RecursiveLazyProxy" assert dir(proxy) ==
[]
assert
collection
tests/test_utils/test_proxy.py
test_recursive_proxy
21
null
anthropics/anthropic-sdk-python
from __future__ import annotations import pytest from anthropic._exceptions import AnthropicError from anthropic.lib.foundry import AnthropicFoundry, AsyncAnthropicFoundry class TestAnthropicFoundry: def test_missing_credentials_error(self) -> None: """Test error raised when no credentials are provided....
AnthropicError, match="Missing credentials")
pytest.raises
complex_expr
tests/lib/test_azure.py
test_missing_credentials_error
TestAnthropicFoundry
56
null
anthropics/anthropic-sdk-python
import json import logging from typing import Any, Dict, List, Union, cast from typing_extensions import Literal import pytest from inline_snapshot import external, snapshot from anthropic import Anthropic, AsyncAnthropic, beta_tool, beta_async_tool from anthropic._utils import assert_signatures_in_sync from anthropi...
snapshots["streaming"]["result"]
assert
complex_expr
tests/lib/tools/test_runners.py
test_streaming_call_sync
TestSyncRunTools
347
null
anthropics/anthropic-sdk-python
from __future__ import annotations from typing import Any, cast import pytest from pydantic import BaseModel from anthropic import beta_tool from anthropic._compat import PYDANTIC_V1 from anthropic.lib.tools._beta_functions import BaseFunctionTool from anthropic.types.beta.beta_tool_param import InputSchema class T...
"12"
assert
string_literal
tests/lib/tools/test_functions.py
test_decorator_without_parentheses
TestFunctionTool
382
null
anthropics/anthropic-sdk-python
from __future__ import annotations import json import base64 from typing import Any from unittest.mock import AsyncMock import anyio import pytest mcp = pytest.importorskip("mcp") from mcp.types import ( # noqa: E402 Tool, TextContent, AudioContent, ImageContent, ResourceLink, PromptMessage...
""
assert
string_literal
tests/lib/tools/test_mcp_tool.py
test_mcp_tool_no_description
TestMCPToolFactory
302
null
anthropics/anthropic-sdk-python
from __future__ import annotations import os import inspect from typing import Any, Set, TypeVar, cast import httpx import pytest from respx import MockRouter from anthropic import Stream, Anthropic, AsyncStream, AsyncAnthropic from anthropic._compat import PYDANTIC_V1 from anthropic.lib.streaming import ParsedMessa...
0
assert
numeric_literal
tests/lib/streaming/test_messages.py
assert_tool_use_response
79
null
anthropics/anthropic-sdk-python
from pathlib import Path import anyio import pytest from dirty_equals import IsDict, IsList, IsBytes, IsTuple from anthropic._files import to_httpx_files, async_to_httpx_files readme_path = Path(__file__).parent.parent.joinpath("README.md") def test_pathlib_includes_file_name() -> None: result = to_httpx_files(...
IsDict({"file": IsTuple("README.md", IsBytes())})
assert
func_call
tests/test_files.py
test_pathlib_includes_file_name
15
null
anthropics/anthropic-sdk-python
import json import logging from typing import Any, Dict, List, Union, cast from typing_extensions import Literal import pytest from inline_snapshot import external, snapshot from anthropic import Anthropic, AsyncAnthropic, beta_tool, beta_async_tool from anthropic._utils import assert_signatures_in_sync from anthropi...
snapshots["custom"]["result"]
assert
complex_expr
tests/lib/tools/test_runners.py
test_custom_message_handling
TestSyncRunTools
279
null
anthropics/anthropic-sdk-python
from __future__ import annotations from typing import Any, Iterator, AsyncIterator from typing_extensions import TypeVar import httpx import pytest from anthropic._decoders.jsonl import JSONLDecoder, AsyncJSONLDecoder _T = TypeVar("_T") @pytest.mark.asyncio @pytest.mark.parametrize("sync", [True, False], ids=["syn...
{"foo": True}
assert
collection
tests/decoders/test_jsonl.py
test_basic
27
null
anthropics/anthropic-sdk-python
from __future__ import annotations from typing import Any, cast import pytest from pydantic import BaseModel from anthropic import beta_tool from anthropic._compat import PYDANTIC_V1 from anthropic.lib.tools._beta_functions import BaseFunctionTool from anthropic.types.beta.beta_tool_param import InputSchema class T...
"simple_function"
assert
string_literal
tests/lib/tools/test_functions.py
test_function_with_multiple_types
TestFunctionTool
54
null
anthropics/anthropic-sdk-python
from __future__ import annotations import io import pathlib from typing import Any, Dict, List, Union, TypeVar, Iterable, Optional, cast from datetime import date, datetime from typing_extensions import Required, Annotated, TypedDict import pytest from anthropic._types import Base64FileInput, omit, not_given from an...
{"foo": True}
assert
collection
tests/test_transform.py
test_pydantic_mismatched_types
305
null
anthropics/anthropic-sdk-python
from __future__ import annotations import os from typing import Any, cast import pytest from anthropic import Anthropic, AsyncAnthropic from tests.utils import assert_matches_type from anthropic.types import ( Message, MessageTokensCount, ) from anthropic.resources.messages import DEPRECATED_MODELS base_url...
"python"
assert
string_literal
tests/api_resources/test_messages.py
test_raw_response_create_overload_1
TestMessages
137
null
anthropics/anthropic-sdk-python
from __future__ import annotations from typing import Any, cast import pytest from pydantic import BaseModel from anthropic import beta_tool from anthropic._compat import PYDANTIC_V1 from anthropic.lib.tools._beta_functions import BaseFunctionTool from anthropic.types.beta.beta_tool_param import InputSchema class T...
"multiply"
assert
string_literal
tests/lib/tools/test_functions.py
test_decorator_without_parentheses
TestFunctionTool
380
null
anthropics/anthropic-sdk-python
import json import warnings import httpx import pytest from respx import MockRouter from pydantic import BaseModel from anthropic import Anthropic, AnthropicError, AsyncAnthropic, _compat class TestStructuredOutputsBetaHeader: @pytest.mark.skipif(_compat.PYDANTIC_V1, reason="parse with Pydantic models requires ...
beta_header
assert
variable
tests/api_resources/beta/test_output_format_conversion.py
test_parse_preserves_existing_betas
TestStructuredOutputsBetaHeader
452
null
anthropics/anthropic-sdk-python
from __future__ import annotations import json import base64 from typing import Any from unittest.mock import AsyncMock import anyio import pytest mcp = pytest.importorskip("mcp") from mcp.types import ( # noqa: E402 Tool, TextContent, AudioContent, ImageContent, ResourceLink, PromptMessage...
[]
assert
collection
tests/lib/tools/test_mcp_tool.py
_test
TestAsyncMCPToolCall
383
null
anthropics/anthropic-sdk-python
from typing import Any, cast from functools import partial from urllib.parse import unquote import pytest from anthropic._qs import Querystring, stringify def test_empty() -> None: assert stringify({}) ==
""
assert
string_literal
tests/test_qs.py
test_empty
11
null
anthropics/anthropic-sdk-python
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_ignores_other_types() -> None: # custom classes my_obj = MyObject() obj1 = {"foo": my_obj} obj2 = deepcopy_minimal(obj1) ...
my_obj
assert
variable
tests/test_deepcopy.py
test_ignores_other_types
53
null
anthropics/anthropic-sdk-python
from __future__ import annotations import os from typing import Any, cast import httpx import pytest from respx import MockRouter from anthropic import Anthropic, AsyncAnthropic from tests.utils import assert_matches_type from anthropic._response import ( BinaryAPIResponse, AsyncBinaryAPIResponse, Stream...
True
assert
bool_literal
tests/api_resources/beta/test_files.py
test_raw_response_list
TestFiles
50
null
anthropics/anthropic-sdk-python
from __future__ import annotations import os import json from typing import Any, cast import httpx import pytest from respx import MockRouter from anthropic import Anthropic, AsyncAnthropic from tests.utils import assert_matches_type from anthropic.pagination import SyncPage, AsyncPage from anthropic.types.beta.mess...
1
assert
numeric_literal
tests/api_resources/beta/messages/test_batches.py
test_method_results
TestBatches
447
null
anthropics/anthropic-sdk-python
from __future__ import annotations from typing import Any, cast import pytest from pydantic import BaseModel from anthropic import beta_tool from anthropic._compat import PYDANTIC_V1 from anthropic.lib.tools._beta_functions import BaseFunctionTool from anthropic.types.beta.beta_tool_param import InputSchema class T...
""
assert
string_literal
tests/lib/tools/test_functions.py
test_function_without_docstring
TestFunctionTool
197
null
anthropics/anthropic-sdk-python
from __future__ import annotations import os from typing import Any, cast import pytest from anthropic import Anthropic, AsyncAnthropic from tests.utils import assert_matches_type from anthropic.types import Completion base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") class TestCompletions: ...
True
assert
bool_literal
tests/api_resources/test_completions.py
test_raw_response_create_overload_1
TestCompletions
53
null
anthropics/anthropic-sdk-python
from __future__ import annotations import gc import os import sys import json import asyncio import inspect import dataclasses import tracemalloc from typing import Any, Union, TypeVar, Callable, Iterable, Iterator, Optional, Coroutine, cast from unittest import mock from typing_extensions import Literal, AsyncIterato...
6
assert
numeric_literal
tests/test_client.py
test_copy_default_options
TestAnthropic
151
null
anthropics/anthropic-sdk-python
from __future__ import annotations from typing import Generic, TypeVar, cast from anthropic._utils import extract_type_var_from_base _T = TypeVar("_T") _T2 = TypeVar("_T2") _T3 = TypeVar("_T3") def test_extract_type_var_multiple() -> None: typ = BaseGenericMultipleTypeArgs[int, str, None] generic_bases = c...
str
assert
variable
tests/test_utils/test_typing.py
test_extract_type_var_multiple
54
null
anthropics/anthropic-sdk-python
from typing import Any, List, cast import pytest from pydantic import BaseModel from inline_snapshot import external, snapshot from anthropic import Anthropic, AsyncAnthropic, _compat class TestSyncParse: @pytest.mark.parametrize( "http_snapshot", [ cast(Any, external("uuid:c11eefc7-f...
2
assert
numeric_literal
tests/lib/_parse/test_messages.py
test_parse_with_pydantic_model
TestSyncParse
48
null
anthropics/anthropic-sdk-python
from __future__ import annotations from typing import Iterator, AsyncIterator import httpx import pytest from anthropic import Anthropic, AsyncAnthropic from anthropic._streaming import Stream, AsyncStream, ServerSentEvent @pytest.mark.asyncio @pytest.mark.parametrize("sync", [True, False], ids=["sync", "async"]) a...
""
assert
string_literal
tests/test_streaming.py
test_event_missing_data
56
null
anthropics/anthropic-sdk-python
from __future__ import annotations import os import json from typing import Any, cast import httpx import pytest from respx import MockRouter from anthropic import Anthropic, AsyncAnthropic from tests.utils import assert_matches_type from anthropic.pagination import SyncPage, AsyncPage from anthropic.types.messages ...
1
assert
numeric_literal
tests/api_resources/messages/test_batches.py
test_method_results
TestBatches
274
null
anthropics/anthropic-sdk-python
from typing import Any, cast from functools import partial from urllib.parse import unquote import pytest from anthropic._qs import Querystring, stringify @pytest.mark.parametrize("method", ["class", "function"]) def test_nested_dotted(method: str) -> None: if method == "class": serialise = Querystring(n...
"a.b.c.d=e"
assert
string_literal
tests/test_qs.py
test_nested_dotted
34
null
anthropics/anthropic-sdk-python
from __future__ import annotations from typing import Any, cast import pytest from pydantic import BaseModel from anthropic import beta_tool from anthropic._compat import PYDANTIC_V1 from anthropic.lib.tools._beta_functions import BaseFunctionTool from anthropic.types.beta.beta_tool_param import InputSchema class T...
"get_weather"
assert
string_literal
tests/lib/tools/test_functions.py
test_basic_function_schema_conversion
TestFunctionTool
25
null
anthropics/anthropic-sdk-python
from __future__ import annotations import pytest from anthropic._utils import required_args def test_positional_param() -> None: @required_args(["a"]) def foo(a: str | None = None) -> str | None: return a assert foo("a") == "a" assert foo(None) is
None
assert
none_literal
tests/test_required_args.py
test_positional_param
23
null
anthropics/anthropic-sdk-python
from __future__ import annotations import io import re import inspect from typing import Any, Iterable from typing_extensions import TypeAlias import rich import pytest import pydantic import rich.pretty import rich.console ReprArgs: TypeAlias = "Iterable[tuple[str | None, Any]]" def print_obj(obj: object) -> str: ...
None
assert
none_literal
tests/lib/utils.py
get_caller_name
52
null
anthropics/anthropic-sdk-python
from __future__ import annotations import os from typing import cast from typing_extensions import Protocol import httpx import pytest from respx import MockRouter from anthropic import AnthropicVertex, AsyncAnthropicVertex base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") class TestAnthropic...
6
assert
numeric_literal
tests/lib/test_vertex.py
test_copy_default_options
TestAnthropicVertex
75
null
anthropics/anthropic-sdk-python
import copy from typing import List, cast import httpx from anthropic.types.beta import BetaDirectCaller, BetaToolUseBlock, BetaInputJSONDelta, BetaRawContentBlockDeltaEvent from anthropic.types.tool_use_block import ToolUseBlock from anthropic.types.beta.beta_usage import BetaUsage from anthropic.lib.streaming._beta...
["item1", "item2"]
assert
collection
tests/lib/streaming/test_partial_json.py
test_trailing_strings_mode_header
TestPartialJson
96
null
anthropics/anthropic-sdk-python
from __future__ import annotations import pytest from anthropic._utils import required_args def test_multiple_params() -> None: @required_args(["a", "b", "c"]) def foo(a: str = "", *, b: str = "", c: str = "") -> str | None: return f"{a} {b} {c}" assert foo(a="a", b="b", c="c") == "a b c" e...
TypeError, match=error_message)
pytest.raises
complex_expr
tests/test_required_args.py
test_multiple_params
52
null
anthropics/anthropic-sdk-python
from __future__ import annotations from typing import Any, cast import pytest from pydantic import BaseModel from anthropic import beta_tool from anthropic._compat import PYDANTIC_V1 from anthropic.lib.tools._beta_functions import BaseFunctionTool from anthropic.types.beta.beta_tool_param import InputSchema class T...
"divide"
assert
string_literal
tests/lib/tools/test_functions.py
test_decorator_with_parentheses
TestFunctionTool
403
null
anthropics/anthropic-sdk-python
from __future__ import annotations import os from typing import Any, cast import pytest from anthropic import Anthropic, AsyncAnthropic from tests.utils import assert_matches_type from anthropic.types import ModelInfo from anthropic.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL"...
model)
assert_*
variable
tests/api_resources/test_models.py
test_raw_response_retrieve
TestModels
45
null
anthropics/anthropic-sdk-python
from __future__ import annotations import json import base64 from typing import Any from unittest.mock import AsyncMock import anyio import pytest mcp = pytest.importorskip("mcp") from mcp.types import ( # noqa: E402 Tool, TextContent, AudioContent, ImageContent, ResourceLink, PromptMessage...
"t2"
assert
string_literal
tests/lib/tools/test_mcp_tool.py
test_list_comprehension
TestMCPToolFactory
315
null
anthropics/anthropic-sdk-python
from copy import deepcopy import pytest from inline_snapshot import snapshot from anthropic.lib._parse._transform import transform_schema def test_array_schema(): schema = { "type": "array", "items": {"type": "string"}, "minItems": 2, "description": "A list of strings", } ...
snapshot( { "type": "array", "description": """\ A list of strings {minItems: 2}\ """, "items": {"type": "string"}, } )
assert
func_call
tests/lib/_parse/test_transform.py
test_array_schema
95
null
anthropics/anthropic-sdk-python
from __future__ import annotations import io import pathlib from typing import Any, Dict, List, Union, TypeVar, Iterable, Optional, cast from datetime import date, datetime from typing_extensions import Required, Annotated, TypedDict import pytest from anthropic._types import Base64FileInput, omit, not_given from an...
{"bar": None}
assert
collection
tests/test_transform.py
test_optional_iso8601_format
214
null
anthropics/anthropic-sdk-python
from __future__ import annotations import os from typing import Any, cast import pytest from anthropic import Anthropic, AsyncAnthropic from tests.utils import assert_matches_type from anthropic.types import ( Message, MessageTokensCount, ) from anthropic.resources.messages import DEPRECATED_MODELS base_url...
message)
assert_*
variable
tests/api_resources/test_messages.py
test_raw_response_create_overload_1
TestMessages
139
null
anthropics/anthropic-sdk-python
from anthropic._utils import deepcopy_minimal def assert_different_identities(obj1: object, obj2: object) -> None: assert obj1 == obj2 assert id(obj1) !=
id(obj2)
assert
func_call
tests/test_deepcopy.py
assert_different_identities
6
null
anthropics/anthropic-sdk-python
from __future__ import annotations from typing import Any, cast import pytest from pydantic import BaseModel from anthropic import beta_tool from anthropic._compat import PYDANTIC_V1 from anthropic.lib.tools._beta_functions import BaseFunctionTool from anthropic.types.beta.beta_tool_param import InputSchema class T...
"10"
assert
string_literal
tests/lib/tools/test_functions.py
test_decorator_with_custom_parameters
TestFunctionTool
417
null
anthropics/anthropic-sdk-python
from copy import deepcopy import pytest from inline_snapshot import snapshot from anthropic.lib._parse._transform import transform_schema def test_ref_schema(): schema = {"$ref": "#/components/schemas/SomeSchema"} result = transform_schema(schema) assert result ==
snapshot({"$ref": "#/components/schemas/SomeSchema"})
assert
func_call
tests/lib/_parse/test_transform.py
test_ref_schema
12
null
anthropics/anthropic-sdk-python
import json from typing import Any, Union, cast from typing_extensions import Annotated import httpx import pytest import pydantic from anthropic import Anthropic, BaseModel from anthropic._streaming import Stream from anthropic._base_client import FinalRequestOptions from anthropic._legacy_response import LegacyAPIR...
2
assert
numeric_literal
tests/test_legacy_response.py
test_response_parse_custom_model
91
null
anthropics/anthropic-sdk-python
from typing import Any, cast from functools import partial from urllib.parse import unquote import pytest from anthropic._qs import Querystring, stringify @pytest.mark.parametrize("method", ["class", "function"]) def test_nested_dotted(method: str) -> None: if method == "class": serialise = Querystring(n...
"a.b=c&a.d=e&a.f=g"
assert
string_literal
tests/test_qs.py
test_nested_dotted
33
null
anthropics/anthropic-sdk-python
from __future__ import annotations import json import base64 from typing import Any from unittest.mock import AsyncMock import anyio import pytest mcp = pytest.importorskip("mcp") from mcp.types import ( # noqa: E402 Tool, TextContent, AudioContent, ImageContent, ResourceLink, PromptMessage...
"image"
assert
string_literal
tests/lib/tools/test_mcp_tool.py
test_image_content_png
TestMCPContent
83
null
anthropics/anthropic-sdk-python
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_ignores_other_types() -> None: # custom classes my_obj = MyObject() obj1 = {"foo": my_obj} obj2 = deepcopy_minimal(obj1) ...
obj2)
assert_*
variable
tests/test_deepcopy.py
test_ignores_other_types
52
null
anthropics/anthropic-sdk-python
from __future__ import annotations import os import inspect import traceback import contextlib from typing import Any, TypeVar, Iterator, Sequence, cast from datetime import date, datetime from typing_extensions import Literal, get_args, get_origin, assert_type from anthropic._types import Omit, NoneType from anthrop...
entry)
assert_*
variable
tests/utils.py
assert_matches_type
79
null
anthropics/anthropic-sdk-python
from typing import Any, cast from functools import partial from urllib.parse import unquote import pytest from anthropic._qs import Querystring, stringify def test_basic() -> None: assert stringify({"a": 1}) ==
"a=1"
assert
string_literal
tests/test_qs.py
test_basic
17
null
anthropics/anthropic-sdk-python
from __future__ import annotations import os from typing import Any, cast import pytest import pydantic from anthropic import Anthropic, AsyncAnthropic from tests.utils import assert_matches_type from anthropic.types.beta import ( BetaMessage, BetaMessageTokensCount, ) base_url = os.environ.get("TEST_API_BA...
True
assert
bool_literal
tests/api_resources/beta/test_messages.py
test_raw_response_create_overload_1
TestMessages
188
null
anthropics/anthropic-sdk-python
from __future__ import annotations from typing import Any, cast import pytest from pydantic import BaseModel from anthropic import beta_tool from anthropic._compat import PYDANTIC_V1 from anthropic.lib.tools._beta_functions import BaseFunctionTool from anthropic.types.beta.beta_tool_param import InputSchema class T...
"custom_calculator"
assert
string_literal
tests/lib/tools/test_functions.py
test_decorator_with_custom_parameters
TestFunctionTool
415
null
anthropics/anthropic-sdk-python
from __future__ import annotations import os import json import inspect from typing import Any, Set, Dict, TypeVar, cast from unittest import TestCase import httpx import pytest from respx import MockRouter from anthropic import Anthropic, AsyncAnthropic from anthropic._compat import PYDANTIC_V1 from anthropic.types...
stream.get_final_message())
assert_*
func_call
tests/lib/streaming/test_beta_messages.py
test_basic_response
TestSyncMessages
208
null
anthropics/anthropic-sdk-python
from __future__ import annotations from typing import Sequence import pytest from anthropic._types import FileTypes from anthropic._utils import extract_files def test_multiple_files() -> None: query = {"documents": [{"file": b"My first file"}, {"file": b"My second file"}]} assert extract_files(query, paths...
{"documents": [{}, {}]}
assert
collection
tests/test_extract_files.py
test_multiple_files
35
null
anthropics/anthropic-sdk-python
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_nested_dict() -> None: obj1 = {"foo": {"bar": True}} obj2 = deepcopy_minimal(obj1) assert_different_identities(obj1, obj2) ...
obj2["foo"])
assert_*
complex_expr
tests/test_deepcopy.py
test_nested_dict
19
null
anthropics/anthropic-sdk-python
from __future__ import annotations import os import inspect import traceback import contextlib from typing import Any, TypeVar, Iterator, Sequence, cast from datetime import date, datetime from typing_extensions import Literal, get_args, get_origin, assert_type from anthropic._types import Omit, NoneType from anthrop...
None
assert
none_literal
tests/utils.py
assert_matches_type
67
null
anthropics/anthropic-sdk-python
import json import logging from typing import Any, Dict, List, Union, cast from typing_extensions import Literal import pytest from inline_snapshot import external, snapshot from anthropic import Anthropic, AsyncAnthropic, beta_tool, beta_async_tool from anthropic._utils import assert_signatures_in_sync from anthropi...
response2
assert
variable
tests/lib/tools/test_runners.py
test_tool_call_caching
TestSyncRunTools
318
null
anthropics/anthropic-sdk-python
from __future__ import annotations import io import pathlib from typing import Any, Dict, List, Union, TypeVar, Iterable, Optional, cast from datetime import date, datetime from typing_extensions import Required, Annotated, TypedDict import pytest from anthropic._types import Base64FileInput, omit, not_given from an...
"foo"
assert
string_literal
tests/test_transform.py
test_pydantic_default_field
344
null
anthropics/anthropic-sdk-python
from __future__ import annotations import os from typing import Any, cast import pytest from anthropic import Anthropic, AsyncAnthropic from tests.utils import assert_matches_type from anthropic.types import ( Message, MessageTokensCount, ) from anthropic.resources.messages import DEPRECATED_MODELS base_url...
True
assert
bool_literal
tests/api_resources/test_messages.py
test_raw_response_create_overload_1
TestMessages
136
null
anthropics/anthropic-sdk-python
from __future__ import annotations import io import pathlib from typing import Any, Dict, List, Union, TypeVar, Iterable, Optional, cast from datetime import date, datetime from typing_extensions import Required, Annotated, TypedDict import pytest from anthropic._types import Base64FileInput, omit, not_given from an...
"06"
assert
string_literal
tests/test_transform.py
test_datetime_custom_format
255
null
anthropics/anthropic-sdk-python
from __future__ import annotations import os from typing import Any, cast import pytest from anthropic import Anthropic, AsyncAnthropic from tests.utils import assert_matches_type from anthropic.pagination import SyncPageCursor, AsyncPageCursor from anthropic.types.beta.skills import ( VersionListResponse, V...
"python"
assert
string_literal
tests/api_resources/beta/skills/test_versions.py
test_raw_response_create
TestVersions
52
null
anthropics/anthropic-sdk-python
from __future__ import annotations import gc import os import sys import json import asyncio import inspect import dataclasses import tracemalloc from typing import Any, Union, TypeVar, Callable, Iterable, Iterator, Optional, Coroutine, cast from unittest import mock from typing_extensions import Literal, AsyncIterato...
0
assert
numeric_literal
tests/test_client.py
test_retrying_timeout_errors_doesnt_leak
TestAnthropic
887
null
anthropics/anthropic-sdk-python
from copy import deepcopy import pytest from inline_snapshot import snapshot from anthropic.lib._parse._transform import transform_schema def test_boolean_schema(): schema = {"type": "boolean", "description": "A flag"} result = transform_schema(schema) assert result ==
snapshot({"type": "boolean", "description": "A flag"})
assert
func_call
tests/lib/_parse/test_transform.py
test_boolean_schema
160
null
anthropics/anthropic-sdk-python
import json from typing import Any, Union, cast from typing_extensions import Annotated import httpx import pytest import pydantic from anthropic import Anthropic, BaseModel from anthropic._streaming import Stream from anthropic._base_client import FinalRequestOptions from anthropic._legacy_response import LegacyAPIR...
"foo"
assert
string_literal
tests/test_legacy_response.py
test_response_parse_expect_model_union_non_json_content
148
null
anthropics/anthropic-sdk-python
from __future__ import annotations import os from typing import cast from typing_extensions import Protocol import httpx import pytest from respx import MockRouter from anthropic import AnthropicVertex, AsyncAnthropicVertex base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") class TestAnthropic...
"project"
assert
string_literal
tests/lib/test_vertex.py
test_copy
TestAnthropicVertex
59
null