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 |
|---|---|---|---|---|---|---|---|---|---|
danielgtaylor/python-betterproto | import json
import sys
from copy import (
copy,
deepcopy,
)
from dataclasses import dataclass
from datetime import (
datetime,
timedelta,
)
from inspect import (
Parameter,
signature,
)
from typing import (
Dict,
List,
Optional,
)
from unittest.mock import ANY
import pytest
import ... | b"" | assert | string_literal | tests/test_features.py | test_optional_flag | 274 | null | |
danielgtaylor/python-betterproto | import json
from tests.output_betterproto.proto3_field_presence import (
InnerTest,
Test,
TestEnum,
)
def test_unset_access(): # see #523
assert Test().test1 is | None | assert | none_literal | tests/inputs/proto3_field_presence/test_proto3_field_presence.py | test_unset_access | 47 | null | |
danielgtaylor/python-betterproto | from dataclasses import dataclass
from io import BytesIO
from pathlib import Path
from shutil import which
from subprocess import run
from typing import Optional
import pytest
import betterproto
from tests.output_betterproto import (
map,
nested,
oneof,
repeated,
repeatedpacked,
)
oneof_example =... | b"" | assert | string_literal | tests/test_streams.py | test_single_message | 390 | null | |
danielgtaylor/python-betterproto | from dataclasses import dataclass
from io import BytesIO
from pathlib import Path
from shutil import which
from subprocess import run
from typing import Optional
import pytest
import betterproto
from tests.output_betterproto import (
map,
nested,
oneof,
repeated,
repeatedpacked,
)
oneof_example =... | single_byte | assert | variable | tests/test_streams.py | test_single_varint | 345 | null | |
danielgtaylor/python-betterproto | import json
from tests.output_betterproto.proto3_field_presence import (
InnerTest,
Test,
TestEnum,
)
def test_null_fields_json():
"""Ensure that using "null" in JSON is equivalent to not specifying a
field, for fields with explicit presence"""
def test_json(ref_json: str, obj_json: str) -> N... | {} | assert | collection | tests/inputs/proto3_field_presence/test_proto3_field_presence.py | test_null_fields_json | 32 | null | |
danielgtaylor/python-betterproto | import json
import sys
from copy import (
copy,
deepcopy,
)
from dataclasses import dataclass
from datetime import (
datetime,
timedelta,
)
from inspect import (
Parameter,
signature,
)
from typing import (
Dict,
List,
Optional,
)
from unittest.mock import ANY
import pytest
import ... | "baz" | assert | string_literal | tests/test_features.py | test_oneof_support | 160 | null | |
danielgtaylor/python-betterproto | from datetime import (
datetime,
timezone,
)
import pytest
from google.protobuf import json_format
from google.protobuf.timestamp_pb2 import Timestamp
import betterproto
from tests.output_betterproto.google_impl_behavior_equivalence import (
Empty,
Foo,
Request,
Spam,
Test,
)
from tests.ou... | message_reference_bytes | assert | variable | tests/inputs/google_impl_behavior_equivalence/test_google_impl_behavior_equivalence.py | test_bytes_are_the_same_for_oneof | 50 | null | |
danielgtaylor/python-betterproto | from typing import (
List,
Optional,
Set,
)
import pytest
from betterproto.plugin.module_validation import ModuleValidator
@pytest.mark.parametrize(
["text", "expected_collisions"],
[
pytest.param(
["import os"],
None,
id="single import",
),
... | expected_collisions | assert | variable | tests/test_module_validation.py | test_module_validator | 110 | null | |
danielgtaylor/python-betterproto | from datetime import (
datetime,
timezone,
)
import pytest
from google.protobuf import json_format
from google.protobuf.timestamp_pb2 import Timestamp
import betterproto
from tests.output_betterproto.google_impl_behavior_equivalence import (
Empty,
Foo,
Request,
Spam,
Test,
)
from tests.ou... | ReferenceSpam(ts=ts).SerializeToString() | assert | func_call | tests/inputs/google_impl_behavior_equivalence/test_google_impl_behavior_equivalence.py | test_datetime_clamping | 74 | null | |
danielgtaylor/python-betterproto | import datetime
import pytest
import betterproto
from tests.output_betterproto.oneof_default_value_serialization import (
Message,
NestedMessage,
Test,
)
def assert_round_trip_serialization_works(message: Test) -> None:
assert betterproto.which_one_of(message, "value_type") == betterproto.which_one_o... | betterproto.which_one_of(Test().from_json(message.to_json()), "value_type") | assert | func_call | tests/inputs/oneof_default_value_serialization/test_oneof_default_value_serialization.py | test_oneof_no_default_values_passed | 52 | null | |
danielgtaylor/python-betterproto | import pytest
from betterproto.plugin.typing_compiler import (
DirectImportTypingCompiler,
NoTyping310TypingCompiler,
TypingImportTypingCompiler,
)
def test_direct_import_typing_compiler():
compiler = DirectImportTypingCompiler()
assert compiler.imports() == {}
assert compiler.optional("str")... | "Optional[str]" | assert | string_literal | tests/test_typing_compiler.py | test_direct_import_typing_compiler | 13 | null | |
danielgtaylor/python-betterproto | from tests.output_betterproto.enum import (
ArithmeticOperator,
Choice,
Test,
)
def test_repeated_enum_is_comparable_with_int():
assert Test(choices=[Choice.ZERO]).choices == [0]
assert Test(choices=[Choice.ONE]).choices == | [1] | assert | collection | tests/inputs/enum/test_enum.py | test_repeated_enum_is_comparable_with_int | 44 | null | |
danielgtaylor/python-betterproto | import pytest
from tests.output_betterproto.bool import Test
from tests.output_betterproto_pydantic.bool import Test as TestPyd
def test_pydantic_bad_value():
with pytest.raises( | ValueError) | pytest.raises | variable | tests/inputs/bool/test_bool.py | test_pydantic_bad_value | 23 | null | |
danielgtaylor/python-betterproto | import pytest
import betterproto
from tests.output_betterproto.oneof_enum import (
Move,
Signal,
Test,
)
from tests.util import get_test_case_json_data
def test_which_one_of_returns_enum_with_default_value():
"""
returns first field when it is enum and set with default value
"""
message = ... | betterproto.PLACEHOLDER | assert | complex_expr | tests/inputs/oneof_enum/test_oneof_enum.py | test_which_one_of_returns_enum_with_default_value | 22 | null | |
danielgtaylor/python-betterproto | from dataclasses import dataclass
from io import BytesIO
from pathlib import Path
from shutil import which
from subprocess import run
from typing import Optional
import pytest
import betterproto
from tests.output_betterproto import (
map,
nested,
oneof,
repeated,
repeatedpacked,
)
oneof_example =... | ValueError) | pytest.raises | variable | tests/test_streams.py | test_calculate_varint_size_negative | 243 | null | |
danielgtaylor/python-betterproto | from tests.output_betterproto.regression_387 import (
ParentElement,
Test,
)
def test_regression_387():
el = ParentElement(name="test", elems=[Test(id=0), Test(id=42)])
binary = bytes(el)
decoded = ParentElement().parse(binary)
assert decoded == | el | assert | variable | tests/inputs/regression_387/test_regression_387.py | test_regression_387 | 11 | null | |
danielgtaylor/python-betterproto | from tests.output_betterproto.enum import (
ArithmeticOperator,
Choice,
Test,
)
def test_enum_to_dict():
assert "choice" not in Test(choice=Choice.ZERO).to_dict(), (
"Default enum value is not serialized"
)
assert (
Test(choice=Choice.ZERO).to_dict(include_default_values=True)["... | "ONE" | assert | string_literal | tests/inputs/enum/test_enum.py | test_enum_to_dict | 37 | null | |
danielgtaylor/python-betterproto | from tests.output_betterproto.enum import (
ArithmeticOperator,
Choice,
Test,
)
def test_repeated_enum_is_comparable_with_int():
assert Test(choices=[Choice.ZERO]).choices == [0]
assert Test(choices=[Choice.ONE]).choices == [1]
assert Test(choices=[Choice.THREE]).choices == | [3] | assert | collection | tests/inputs/enum/test_enum.py | test_repeated_enum_is_comparable_with_int | 45 | null | |
danielgtaylor/python-betterproto | import pickle
from copy import (
copy,
deepcopy,
)
from dataclasses import dataclass
from typing import (
Dict,
List,
)
from unittest.mock import ANY
import cachelib
import betterproto
from betterproto.lib.google import protobuf as google
def unpickled(message):
return pickle.loads(pickle.dumps(m... | "1" | assert | string_literal | tests/test_pickling.py | test_pickling_complex_message | 96 | null | |
danielgtaylor/python-betterproto | import asyncio
import uuid
import grpclib
import grpclib.client
import grpclib.metadata
import grpclib.server
import pytest
from grpclib.testing import ChannelFor
from betterproto.grpc.util.async_channel import AsyncChannel
from tests.output_betterproto.service import (
DoThingRequest,
DoThingResponse,
Ge... | grpclib.exceptions.GRPCError) | pytest.raises | complex_expr | tests/grpc/test_grpclib_client.py | test_trailer_only_error_unary_unary | 67 | null | |
danielgtaylor/python-betterproto | from typing import (
Any,
Callable,
Optional,
)
import pytest
import betterproto.lib.google.protobuf as protobuf
from tests.mocks import MockChannel
from tests.output_betterproto.googletypes_response import (
Input,
TestStub,
)
test_cases = [
(TestStub.get_double, protobuf.DoubleValue, 2.5),
... | Optional[type(value)] | assert | func_call | tests/inputs/googletypes_response/test_googletypes_response.py | test_channel_receives_wrapped_type | 43 | null | |
danielgtaylor/python-betterproto | import json
import sys
from copy import (
copy,
deepcopy,
)
from dataclasses import dataclass
from datetime import (
datetime,
timedelta,
)
from inspect import (
Parameter,
signature,
)
from typing import (
Dict,
List,
Optional,
)
from unittest.mock import ANY
import pytest
import ... | None | assert | none_literal | tests/test_features.py | test_optional_flag | 279 | null | |
danielgtaylor/python-betterproto | from pathlib import Path
import tomlkit
from betterproto import __version__
PROJECT_TOML = Path(__file__).joinpath("..", "..", "pyproject.toml").resolve()
def test_version():
with PROJECT_TOML.open() as toml_file:
project_config = tomlkit.loads(toml_file.read())
assert __version__ == | project_config["project"]["version"] | assert | complex_expr | tests/test_version.py | test_version | 14 | null | |
danielgtaylor/python-betterproto | from tests.output_betterproto.enum import (
ArithmeticOperator,
Choice,
Test,
)
def test_enum_to_dict():
assert "choice" not in Test(choice=Choice.ZERO).to_dict(), (
"Default enum value is not serialized"
)
assert (
Test(choice=Choice.ZERO).to_dict(include_default_values=True)["... | "THREE" | assert | string_literal | tests/inputs/enum/test_enum.py | test_enum_to_dict | 38 | null | |
danielgtaylor/python-betterproto | import importlib
import json
import math
import os
import sys
from collections import namedtuple
from types import ModuleType
from typing import (
Any,
Dict,
List,
Set,
Tuple,
)
import pytest
import betterproto
from tests.inputs import config as test_input_config
from tests.mocks import MockChanne... | reference_binary_output | assert | variable | tests/test_inputs.py | test_binary_compatibility | 217 | null | |
danielgtaylor/python-betterproto | import pytest
from betterproto.compile.importing import (
get_type_reference,
parse_source_type_name,
)
from betterproto.plugin.typing_compiler import DirectImportTypingCompiler
def typing_compiler() -> DirectImportTypingCompiler:
"""
Generates a simple Direct Import Typing Compiler for testing.
"... | '"Message"' | assert | string_literal | tests/test_get_ref_type.py | test_reference_root_sibling | 273 | null | |
danielgtaylor/python-betterproto | import pickle
from copy import (
copy,
deepcopy,
)
from dataclasses import dataclass
from typing import (
Dict,
List,
)
from unittest.mock import ANY
import cachelib
import betterproto
from betterproto.lib.google import protobuf as google
def unpickled(message):
return pickle.loads(pickle.dumps(m... | True | assert | bool_literal | tests/test_pickling.py | test_pickling_complex_message | 97 | null | |
danielgtaylor/python-betterproto | from dataclasses import dataclass
from io import BytesIO
from pathlib import Path
from shutil import which
from subprocess import run
from typing import Optional
import pytest
import betterproto
from tests.output_betterproto import (
map,
nested,
oneof,
repeated,
repeatedpacked,
)
oneof_example =... | over32 | assert | variable | tests/test_streams.py | test_multiple_varints | 376 | null | |
danielgtaylor/python-betterproto | import json
from tests.output_betterproto.proto3_field_presence import (
InnerTest,
Test,
TestEnum,
)
def test_json(ref_json: str, obj_json: str) -> None:
"""`ref_json` and `obj_json` are JSON strings describing a `Test` object.
Test that deserializing both leads to the same object, an... | json.loads(ref_json) | assert | func_call | tests/inputs/proto3_field_presence/test_proto3_field_presence.py | test_json | 22 | null | |
danielgtaylor/python-betterproto | import pytest
from betterproto.compile.importing import (
get_type_reference,
parse_source_type_name,
)
from betterproto.plugin.typing_compiler import DirectImportTypingCompiler
def typing_compiler() -> DirectImportTypingCompiler:
"""
Generates a simple Direct Import Typing Compiler for testing.
"... | '"__p_q__.Message"' | assert | string_literal | tests/test_get_ref_type.py | test_reference_unrelated_nested_package | 400 | null | |
danielgtaylor/python-betterproto | import asyncio
import uuid
import grpclib
import grpclib.client
import grpclib.metadata
import grpclib.server
import pytest
from grpclib.testing import ChannelFor
from betterproto.grpc.util.async_channel import AsyncChannel
from tests.output_betterproto.service import (
DoThingRequest,
DoThingResponse,
Ge... | expected_versions.pop() | assert | func_call | tests/grpc/test_grpclib_client.py | test_async_gen_for_unary_stream_request | 235 | null | |
danielgtaylor/python-betterproto | import datetime
import pytest
import betterproto
from tests.output_betterproto.oneof_default_value_serialization import (
Message,
NestedMessage,
Test,
)
def assert_round_trip_serialization_works(message: Test) -> None:
assert betterproto.which_one_of(message, "value_type") == betterproto.which_one_o... | message) | assert_* | variable | tests/inputs/oneof_default_value_serialization/test_oneof_default_value_serialization.py | test_oneof_default_value_serialization_works_for_all_values | 47 | null | |
danielgtaylor/python-betterproto | import asyncio
import uuid
import grpclib
import grpclib.client
import grpclib.metadata
import grpclib.server
import pytest
from grpclib.testing import ChannelFor
from betterproto.grpc.util.async_channel import AsyncChannel
from tests.output_betterproto.service import (
DoThingRequest,
DoThingResponse,
Ge... | comments | assert | variable | tests/grpc/test_grpclib_client.py | test_service_call_mutable_defaults | 100 | null | |
danielgtaylor/python-betterproto | import asyncio
import uuid
import grpclib
import grpclib.client
import grpclib.metadata
import grpclib.server
import pytest
from grpclib.testing import ChannelFor
from betterproto.grpc.util.async_channel import AsyncChannel
from tests.output_betterproto.service import (
DoThingRequest,
DoThingResponse,
Ge... | thing_name | assert | variable | tests/grpc/test_grpclib_client.py | test_async_gen_for_unary_stream_request | 234 | null | |
danielgtaylor/python-betterproto | from typing import (
Optional,
Tuple,
)
import pytest
import betterproto
@pytest.mark.parametrize(
"member, str_value",
[
(Colour.RED, "RED"),
(Colour.GREEN, "GREEN"),
(Colour.BLUE, "BLUE"),
],
)
def test_str(member: Colour, str_value: str) -> None:
assert str(member)... | str_value | assert | variable | tests/test_enum.py | test_str | 29 | null | |
danielgtaylor/python-betterproto | from tests.output_betterproto.enum import (
ArithmeticOperator,
Choice,
Test,
)
def test_enum_is_comparable_with_int():
assert Test(choice=Choice.ZERO).choice == 0
assert Test(choice=Choice.ONE).choice == 1
assert Test(choice=Choice.THREE).choice == | 3 | assert | numeric_literal | tests/inputs/enum/test_enum.py | test_enum_is_comparable_with_int | 25 | null | |
danielgtaylor/python-betterproto | import warnings
import pytest
from tests.mocks import MockChannel
from tests.output_betterproto.deprecated import (
Empty,
Message,
Test,
TestServiceStub,
)
def message():
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
return Message... | f"{Test.__name__}.message is deprecated" | assert | string_literal | tests/test_deprecated.py | test_message_with_deprecated_field | 34 | null | |
danielgtaylor/python-betterproto | from tests.output_betterproto.proto3_field_presence_oneof import (
InnerNested,
Nested,
Test,
WithOptional,
)
def test_empty_with_optional(message: Test) -> None:
# '12' => tag 2, length delimited
# '00' => length: 0
assert bytes(message) == | bytearray.fromhex("12 00") | assert | func_call | tests/inputs/proto3_field_presence_oneof/test_proto3_field_presence_oneof.py | test_empty_with_optional | 26 | null | |
danielgtaylor/python-betterproto | import pickle
from copy import (
copy,
deepcopy,
)
from dataclasses import dataclass
from typing import (
Dict,
List,
)
from unittest.mock import ANY
import cachelib
import betterproto
from betterproto.lib.google import protobuf as google
def unpickled(message):
return pickle.loads(pickle.dumps(m... | deser | assert | variable | tests/test_pickling.py | test_pickling_complex_message | 95 | null | |
danielgtaylor/python-betterproto | from datetime import (
datetime,
timezone,
)
import pytest
from google.protobuf import json_format
from google.protobuf.timestamp_pb2 import Timestamp
import betterproto
from tests.output_betterproto.google_impl_behavior_equivalence import (
Empty,
Foo,
Request,
Spam,
Test,
)
from tests.ou... | betterproto.PLACEHOLDER | assert | complex_expr | tests/inputs/google_impl_behavior_equivalence/test_google_impl_behavior_equivalence.py | test_bytes_are_the_same_for_oneof | 62 | null | |
danielgtaylor/python-betterproto | from datetime import (
datetime,
timedelta,
timezone,
)
import pytest
from tests.output_betterproto.timestamp_dict_encode import Test
MIN_UTC_OFFSET_MIN = -12 * 60
MAX_UTC_OFFSET_MIN = 14 * 60
timezones = [
timezone(timedelta(minutes=x))
for x in range(MIN_UTC_OFFSET_MIN, MAX_UTC_OFFSET_MIN + 1,... | decoded_message.ts | assert | complex_expr | tests/inputs/timestamp_dict_encode/test_timestamp_dict_encode.py | test_timezone_aware_datetime_dict_encode | 35 | null | |
danielgtaylor/python-betterproto | from datetime import (
datetime,
timedelta,
)
from typing import (
Any,
Callable,
)
import pytest
import betterproto.lib.google.protobuf as protobuf
from tests.mocks import MockChannel
from tests.output_betterproto.googletypes_request import (
Input,
TestStub,
)
test_cases = [
(TestStub.s... | type(wrapped_value) | assert | func_call | tests/inputs/googletypes_request/test_googletypes_request.py | test_channel_receives_wrapped_type | 47 | null | |
danielgtaylor/python-betterproto | import pickle
from copy import (
copy,
deepcopy,
)
from dataclasses import dataclass
from typing import (
Dict,
List,
)
from unittest.mock import ANY
import cachelib
import betterproto
from betterproto.lib.google import protobuf as google
def unpickled(message):
return pickle.loads(pickle.dumps(m... | 1 | assert | numeric_literal | tests/test_pickling.py | test_message_can_be_cached | 197 | null | |
danielgtaylor/python-betterproto | from datetime import (
datetime,
timezone,
)
import pytest
from google.protobuf import json_format
from google.protobuf.timestamp_pb2 import Timestamp
import betterproto
from tests.output_betterproto.google_impl_behavior_equivalence import (
Empty,
Foo,
Request,
Spam,
Test,
)
from tests.ou... | message_reference2 | assert | variable | tests/inputs/google_impl_behavior_equivalence/test_google_impl_behavior_equivalence.py | test_bytes_are_the_same_for_oneof | 57 | null | |
danielgtaylor/python-betterproto | import json
from tests.output_betterproto.proto3_field_presence import (
InnerTest,
Test,
TestEnum,
)
def test_null_fields_json():
"""Ensure that using "null" in JSON is equivalent to not specifying a
field, for fields with explicit presence"""
def test_json(ref_json: str, obj_json: str) -> N... | { "test1": None, "test2": None, "test3": None, "test4": None, "test5": None, "test6": None, "test7": None, "test8": None, "test9": None, } | assert | collection | tests/inputs/proto3_field_presence/test_proto3_field_presence.py | test_null_fields_json | 33 | null | |
danielgtaylor/python-betterproto | import asyncio
import uuid
import grpclib
import grpclib.client
import grpclib.metadata
import grpclib.server
import pytest
from grpclib.testing import ChannelFor
from betterproto.grpc.util.async_channel import AsyncChannel
from tests.output_betterproto.service import (
DoThingRequest,
DoThingResponse,
Ge... | 0 | assert | numeric_literal | tests/grpc/test_grpclib_client.py | test_stream_unary_with_empty_iterable | 281 | null | |
danielgtaylor/python-betterproto | import json
import sys
from copy import (
copy,
deepcopy,
)
from dataclasses import dataclass
from datetime import (
datetime,
timedelta,
)
from inspect import (
Parameter,
signature,
)
from typing import (
Dict,
List,
Optional,
)
from unittest.mock import ANY
import pytest
import ... | {} | assert | collection | tests/test_features.py | test_optional_datetime_to_dict | 289 | null | |
danielgtaylor/python-betterproto | import pickle
from copy import (
copy,
deepcopy,
)
from dataclasses import dataclass
from typing import (
Dict,
List,
)
from unittest.mock import ANY
import cachelib
import betterproto
from betterproto.lib.google import protobuf as google
def unpickled(message):
return pickle.loads(pickle.dumps(m... | "howdy" | assert | string_literal | tests/test_pickling.py | test_pickling_complex_message | 99 | null | |
danielgtaylor/python-betterproto | import pytest
from tests.mocks import MockChannel
from tests.output_betterproto.googletypes_response_embedded import (
Input,
Output,
TestStub,
)
@pytest.mark.asyncio
async def test_service_passes_through_unwrapped_values_embedded_in_response():
"""
We do not not need to implement value unwrapping... | -15 | assert | numeric_literal | tests/inputs/googletypes_response_embedded/test_googletypes_response_embedded.py | test_service_passes_through_unwrapped_values_embedded_in_response | 36 | null | |
danielgtaylor/python-betterproto | import json
import sys
from copy import (
copy,
deepcopy,
)
from dataclasses import dataclass
from datetime import (
datetime,
timedelta,
)
from inspect import (
Parameter,
signature,
)
from typing import (
Dict,
List,
Optional,
)
from unittest.mock import ANY
import pytest
import ... | "abc" | assert | string_literal | tests/test_features.py | test_oneof_support | 170 | null | |
danielgtaylor/python-betterproto | import json
import sys
from copy import (
copy,
deepcopy,
)
from dataclasses import dataclass
from datetime import (
datetime,
timedelta,
)
from inspect import (
Parameter,
signature,
)
from typing import (
Dict,
List,
Optional,
)
from unittest.mock import ANY
import pytest
import ... | ANY | assert | variable | tests/test_features.py | test_equality_comparison | 677 | null | |
danielgtaylor/python-betterproto | from typing import (
Any,
Callable,
Optional,
)
import pytest
import betterproto.lib.google.protobuf as protobuf
from tests.mocks import MockChannel
from tests.output_betterproto.googletypes_response import (
Input,
TestStub,
)
test_cases = [
(TestStub.get_double, protobuf.DoubleValue, 2.5),
... | type(wrapped_value) | assert | func_call | tests/inputs/googletypes_response/test_googletypes_response.py | test_channel_receives_wrapped_type | 44 | null | |
danielgtaylor/python-betterproto | import warnings
import pytest
from tests.mocks import MockChannel
from tests.output_betterproto.deprecated import (
Empty,
Message,
Test,
TestServiceStub,
)
def message():
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
return Message... | f"TestService.deprecated_func is deprecated" | assert | string_literal | tests/test_deprecated.py | test_service_with_deprecated_method | 57 | null | |
danielgtaylor/python-betterproto | from tests.output_betterproto.enum import (
ArithmeticOperator,
Choice,
Test,
)
def test_enum_is_comparable_with_int():
assert Test(choice=Choice.ZERO).choice == 0
assert Test(choice=Choice.ONE).choice == 1
assert Test(choice=Choice.THREE).choice == 3
assert Test(choice=Choice.FOUR).choice... | 4 | assert | numeric_literal | tests/inputs/enum/test_enum.py | test_enum_is_comparable_with_int | 26 | null | |
danielgtaylor/python-betterproto | from datetime import (
datetime,
timezone,
)
import pytest
from google.protobuf import json_format
from google.protobuf.timestamp_pb2 import Timestamp
import betterproto
from tests.output_betterproto.google_impl_behavior_equivalence import (
Empty,
Foo,
Request,
Spam,
Test,
)
from tests.ou... | message2 | assert | variable | tests/inputs/google_impl_behavior_equivalence/test_google_impl_behavior_equivalence.py | test_bytes_are_the_same_for_oneof | 56 | null | |
danielgtaylor/python-betterproto | from tests.output_betterproto.enum import (
ArithmeticOperator,
Choice,
Test,
)
def test_enum_mapped_on_parse():
# test default value
b = Test().parse(bytes(Test()))
assert b.choice.name == Choice.ZERO.name
assert b.choices == | [] | assert | collection | tests/inputs/enum/test_enum.py | test_enum_mapped_on_parse | 92 | null | |
danielgtaylor/python-betterproto | import pytest
from betterproto.plugin.typing_compiler import (
DirectImportTypingCompiler,
NoTyping310TypingCompiler,
TypingImportTypingCompiler,
)
def test_direct_import_typing_compiler():
compiler = DirectImportTypingCompiler()
assert compiler.imports() == {}
assert compiler.optional("str") ... | "Dict[str, int]" | assert | string_literal | tests/test_typing_compiler.py | test_direct_import_typing_compiler | 17 | null | |
danielgtaylor/python-betterproto | from typing import (
Optional,
Tuple,
)
import pytest
import betterproto
@pytest.mark.parametrize(
"member, input_str",
[
(Colour.RED, "RED"),
(Colour.GREEN, "GREEN"),
(Colour.BLUE, "BLUE"),
],
)
def test_from_string(member: Colour, input_str: str) -> None:
assert Col... | member | assert | variable | tests/test_enum.py | test_from_string | 66 | null | |
danielgtaylor/python-betterproto | def test_all_definition():
"""
Check that a compiled module defines __all__ with the right value.
These modules have been chosen since they contain messages, services and enums.
"""
import tests.output_betterproto.enum as enum
import tests.output_betterproto.service as service
assert servi... | ("Choice", "ArithmeticOperator", "Test") | assert | collection | tests/test_all_definition.py | test_all_definition | 19 | null | |
danielgtaylor/python-betterproto | from dataclasses import dataclass
from io import BytesIO
from pathlib import Path
from shutil import which
from subprocess import run
from typing import Optional
import pytest
import betterproto
from tests.output_betterproto import (
map,
nested,
oneof,
repeated,
repeatedpacked,
)
oneof_example =... | num_messages | assert | variable | tests/test_streams.py | test_infinite_messages | 434 | null | |
danielgtaylor/python-betterproto | import pytest
from tests.mocks import MockChannel
from tests.output_betterproto.import_service_input_message import (
NestedRequestMessage,
RequestMessage,
RequestResponse,
TestStub,
)
from tests.output_betterproto.import_service_input_message.child import (
ChildRequestMessage,
)
@pytest.mark.asy... | response | assert | variable | tests/inputs/import_service_input_message/test_import_service_input_message.py | test_service_correctly_imports_reference_message | 20 | null | |
danielgtaylor/python-betterproto | from tests.output_betterproto.enum import (
ArithmeticOperator,
Choice,
Test,
)
def test_repeated_enum_is_comparable_with_int():
assert Test(choices=[Choice.ZERO]).choices == | [0] | assert | collection | tests/inputs/enum/test_enum.py | test_repeated_enum_is_comparable_with_int | 43 | null | |
danielgtaylor/python-betterproto | import pytest
import betterproto
from tests.output_betterproto.oneof_enum import (
Move,
Signal,
Test,
)
from tests.util import get_test_case_json_data
def test_which_one_of_returns_enum_with_non_default_value():
"""
returns first field when it is enum and set with non default value
"""
me... | Signal.RESIGN | assert | complex_expr | tests/inputs/oneof_enum/test_oneof_enum.py | test_which_one_of_returns_enum_with_non_default_value | 37 | null | |
danielgtaylor/python-betterproto | from tests.output_betterproto.regression_414 import Test
def test_full_cycle():
body = bytes([0, 1])
auth = bytes([2, 3])
sig = [b""]
obj = Test(body=body, auth=auth, signatures=sig)
decoded = Test().parse(bytes(obj))
assert decoded == | obj | assert | variable | tests/inputs/regression_414/test_regression_414.py | test_full_cycle | 12 | null | |
danielgtaylor/python-betterproto | import json
import sys
from copy import (
copy,
deepcopy,
)
from dataclasses import dataclass
from datetime import (
datetime,
timedelta,
)
from inspect import (
Parameter,
signature,
)
from typing import (
Dict,
List,
Optional,
)
from unittest.mock import ANY
import pytest
import ... | True | assert | bool_literal | tests/test_features.py | test_has_field | 43 | null | |
danielgtaylor/python-betterproto | import json
import sys
from copy import (
copy,
deepcopy,
)
from dataclasses import dataclass
from datetime import (
datetime,
timedelta,
)
from inspect import (
Parameter,
signature,
)
from typing import (
Dict,
List,
Optional,
)
from unittest.mock import ANY
import pytest
import ... | msg | assert | variable | tests/test_features.py | test_equality_comparison | 676 | null | |
danielgtaylor/python-betterproto | import pytest
from betterproto.compile.importing import (
get_type_reference,
parse_source_type_name,
)
from betterproto.plugin.typing_compiler import DirectImportTypingCompiler
def typing_compiler() -> DirectImportTypingCompiler:
"""
Generates a simple Direct Import Typing Compiler for testing.
"... | '"__b_c__.Message"' | assert | string_literal | tests/test_get_ref_type.py | test_reference_far_cousin_package | 471 | null | |
danielgtaylor/python-betterproto | def test_all_definition():
"""
Check that a compiled module defines __all__ with the right value.
These modules have been chosen since they contain messages, services and enums.
"""
import tests.output_betterproto.enum as enum
import tests.output_betterproto.service as service
assert serv... | ( "ThingType", "DoThingRequest", "DoThingResponse", "GetThingRequest", "GetThingResponse", "TestStub", "TestBase", ) | assert | collection | tests/test_all_definition.py | test_all_definition | 10 | null | |
danielgtaylor/python-betterproto | from tests.output_betterproto.regression_414 import Test
def test_full_cycle():
body = bytes([0, 1])
auth = bytes([2, 3])
sig = [b""]
obj = Test(body=body, auth=auth, signatures=sig)
decoded = Test().parse(bytes(obj))
assert decoded == obj
assert decoded.body == body
assert decoded.a... | auth | assert | variable | tests/inputs/regression_414/test_regression_414.py | test_full_cycle | 14 | null | |
danielgtaylor/python-betterproto | from datetime import (
datetime,
timezone,
)
import pytest
from google.protobuf import json_format
from google.protobuf.timestamp_pb2 import Timestamp
import betterproto
from tests.output_betterproto.google_impl_behavior_equivalence import (
Empty,
Foo,
Request,
Spam,
Test,
)
from tests.ou... | json_format.MessageToDict(message_reference) | assert | func_call | tests/inputs/google_impl_behavior_equivalence/test_google_impl_behavior_equivalence.py | test_oneof_serializes_similar_to_google_oneof | 40 | null | |
danielgtaylor/python-betterproto | from dataclasses import dataclass
import pytest
import betterproto
def test_oneof_pattern_matching():
@dataclass
class Sub(betterproto.Message):
val: int = betterproto.int32_field(1)
@dataclass
class Foo(betterproto.Message):
bar: int = betterproto.int32_field(1, group="group1")
... | 1 | assert | numeric_literal | tests/oneof_pattern_matching.py | test_oneof_pattern_matching | 42 | null | |
danielgtaylor/python-betterproto | from tests.output_betterproto.enum import (
ArithmeticOperator,
Choice,
Test,
)
def test_repeated_enum_to_dict():
assert Test(choices=[Choice.ZERO]).to_dict()["choices"] == ["ZERO"]
assert Test(choices=[Choice.ONE]).to_dict()["choices"] == | ["ONE"] | assert | collection | tests/inputs/enum/test_enum.py | test_repeated_enum_to_dict | 58 | null | |
danielgtaylor/python-betterproto | from typing import (
AsyncIterable,
AsyncIterator,
)
import pytest
from grpclib.testing import ChannelFor
from tests.output_betterproto.example_service import (
ExampleRequest,
ExampleResponse,
TestBase,
TestStub,
)
@pytest.mark.asyncio
async def test_calls_with_different_cardinalities():
... | example_request.example_string | assert | complex_expr | tests/inputs/example_service/test_example_service.py | test_calls_with_different_cardinalities | 65 | null | |
danielgtaylor/python-betterproto | import json
import sys
from copy import (
copy,
deepcopy,
)
from dataclasses import dataclass
from datetime import (
datetime,
timedelta,
)
from inspect import (
Parameter,
signature,
)
from typing import (
Dict,
List,
Optional,
)
from unittest.mock import ANY
import pytest
import ... | 0 | assert | numeric_literal | tests/test_features.py | test_oneof_support | 180 | null | |
danielgtaylor/python-betterproto | import pickle
from copy import (
copy,
deepcopy,
)
from dataclasses import dataclass
from typing import (
Dict,
List,
)
from unittest.mock import ANY
import cachelib
import betterproto
from betterproto.lib.google import protobuf as google
def unpickled(message):
return pickle.loads(pickle.dumps(m... | "world" | assert | string_literal | tests/test_pickling.py | test_pickling_complex_message | 100 | null | |
danielgtaylor/python-betterproto | import pytest
from betterproto.compile.importing import (
get_type_reference,
parse_source_type_name,
)
from betterproto.plugin.typing_compiler import DirectImportTypingCompiler
def typing_compiler() -> DirectImportTypingCompiler:
"""
Generates a simple Direct Import Typing Compiler for testing.
"... | '"__Message__"' | assert | string_literal | tests/test_get_ref_type.py | test_reference_root_package_from_child | 357 | null | |
danielgtaylor/python-betterproto | import pytest
import betterproto
from tests.output_betterproto.oneof import (
MixedDrink,
Test,
)
from tests.output_betterproto_pydantic.oneof import Test as TestPyd
from tests.util import get_test_case_json_data
def test_which_count():
message = Test()
message.from_json(get_test_case_json_data("oneof... | ("pitied", 100) | assert | collection | tests/inputs/oneof/test_oneof.py | test_which_count | 15 | null | |
danielgtaylor/python-betterproto | import importlib
import json
import math
import os
import sys
from collections import namedtuple
from types import ModuleType
from typing import (
Any,
Dict,
List,
Set,
Tuple,
)
import pytest
import betterproto
from tests.inputs import config as test_input_config
from tests.mocks import MockChanne... | dict_replace_nans( json.loads(sample.json) ) | assert | func_call | tests/test_inputs.py | test_message_json | 189 | null | |
danielgtaylor/python-betterproto | from tests.output_betterproto.enum import (
ArithmeticOperator,
Choice,
Test,
)
def test_enum_is_comparable_with_int():
assert Test(choice=Choice.ZERO).choice == 0
assert Test(choice=Choice.ONE).choice == | 1 | assert | numeric_literal | tests/inputs/enum/test_enum.py | test_enum_is_comparable_with_int | 24 | null | |
danielgtaylor/python-betterproto | import asyncio
import uuid
import grpclib
import grpclib.client
import grpclib.metadata
import grpclib.server
import pytest
from grpclib.testing import ChannelFor
from betterproto.grpc.util.async_channel import AsyncChannel
from tests.output_betterproto.service import (
DoThingRequest,
DoThingResponse,
Ge... | response_index + 1 | assert | complex_expr | tests/grpc/test_grpclib_client.py | test_async_gen_for_stream_stream_request | 256 | null | |
danielgtaylor/python-betterproto | import pytest
from betterproto.compile.importing import (
get_type_reference,
parse_source_type_name,
)
from betterproto.plugin.typing_compiler import DirectImportTypingCompiler
def typing_compiler() -> DirectImportTypingCompiler:
"""
Generates a simple Direct Import Typing Compiler for testing.
"... | expected_output | assert | variable | tests/test_get_ref_type.py | test_parse_field_type_name | 497 | null | |
danielgtaylor/python-betterproto | import pytest
from tests.output_betterproto.nestedtwice import (
Test,
TestTop,
TestTopMiddle,
TestTopMiddleBottom,
TestTopMiddleEnumBottom,
TestTopMiddleTopMiddleBottom,
)
@pytest.mark.parametrize(
("cls", "expected_comment"),
[
(Test, "Test doc."),
(TestTopMiddleEnumB... | expected_comment | assert | variable | tests/inputs/nestedtwice/test_nestedtwice.py | test_comment | 25 | null | |
danielgtaylor/python-betterproto | import pytest
import betterproto
from tests.output_betterproto.oneof_enum import (
Move,
Signal,
Test,
)
from tests.util import get_test_case_json_data
def test_which_one_of_returns_enum_with_default_value():
"""
returns first field when it is enum and set with default value
"""
message = ... | ("signal", Signal.PASS) | assert | collection | tests/inputs/oneof_enum/test_oneof_enum.py | test_which_one_of_returns_enum_with_default_value | 24 | null | |
danielgtaylor/python-betterproto | from dataclasses import dataclass
import pytest
import betterproto
def test_oneof_pattern_matching():
@dataclass
class Sub(betterproto.Message):
val: int = betterproto.int32_field(1)
@dataclass
class Foo(betterproto.Message):
bar: int = betterproto.int32_field(1, group="group1")
... | "test1" | assert | string_literal | tests/oneof_pattern_matching.py | test_oneof_pattern_matching | 26 | null | |
danielgtaylor/python-betterproto | import datetime
import pytest
import betterproto
from tests.output_betterproto.oneof_default_value_serialization import (
Message,
NestedMessage,
Test,
)
def assert_round_trip_serialization_works(message: Test) -> None:
assert betterproto.which_one_of(message, "value_type") == | betterproto.which_one_of( Test().from_json(message.to_json()), "value_type" ) | assert | func_call | tests/inputs/oneof_default_value_serialization/test_oneof_default_value_serialization.py | assert_round_trip_serialization_works | 14 | null | |
danielgtaylor/python-betterproto | from datetime import (
datetime,
timezone,
)
import pytest
from google.protobuf import json_format
from google.protobuf.timestamp_pb2 import Timestamp
import betterproto
from tests.output_betterproto.google_impl_behavior_equivalence import (
Empty,
Foo,
Request,
Spam,
Test,
)
from tests.ou... | ReferenceSpam.FromString(message_bytes).ts.seconds | assert | func_call | tests/inputs/google_impl_behavior_equivalence/test_google_impl_behavior_equivalence.py | test_datetime_clamping | 77 | null | |
danielgtaylor/python-betterproto | import pytest
from tests.mocks import MockChannel
from tests.output_betterproto.googletypes_response_embedded import (
Input,
Output,
TestStub,
)
@pytest.mark.asyncio
async def test_service_passes_through_unwrapped_values_embedded_in_response():
"""
We do not not need to implement value unwrapping... | -13 | assert | numeric_literal | tests/inputs/googletypes_response_embedded/test_googletypes_response_embedded.py | test_service_passes_through_unwrapped_values_embedded_in_response | 34 | null | |
danielgtaylor/python-betterproto | import pickle
from copy import (
copy,
deepcopy,
)
from dataclasses import dataclass
from typing import (
Dict,
List,
)
from unittest.mock import ANY
import cachelib
import betterproto
from betterproto.lib.google import protobuf as google
def unpickled(message):
return pickle.loads(pickle.dumps(m... | copied.baz | assert | complex_expr | tests/test_pickling.py | test_copyability | 166 | null | |
danielgtaylor/python-betterproto | import pytest
from betterproto.compile.importing import (
get_type_reference,
parse_source_type_name,
)
from betterproto.plugin.typing_compiler import DirectImportTypingCompiler
def typing_compiler() -> DirectImportTypingCompiler:
"""
Generates a simple Direct Import Typing Compiler for testing.
"... | '"_y__.Message"' | assert | string_literal | tests/test_get_ref_type.py | test_reference_cousin_package | 428 | null | |
lark-parser/lark | from __future__ import absolute_import
import unittest
from functools import partial, reduce, partialmethod
from operator import add, mul
from unittest import TestCase
import copy
import pickle
import functools
from lark.tree import Tree
from lark.lexer import Token
from lark.visitors import Visitor, Visitor_Recursiv... | 1) | self.assertEqual | numeric_literal | tests/test_trees.py | test_vargs | TestTrees | 187 | null |
lark-parser/lark | from __future__ import absolute_import
import os
from unittest import TestCase, main
from lark import Lark, Token, Tree, ParseError, UnexpectedInput
from lark.load_grammar import GrammarError, GRAMMAR_ERRORS, find_grammar_errors, list_grammar_imports
from lark.load_grammar import FromPackageLoader
from lark.grammar i... | 5 | assert | numeric_literal | tests/test_grammar.py | test_ignore_name | TestGrammar | 37 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from copy import deepcopy
from lark import Lark, Tree, Token
from lark.exceptions import MissingVariableError
from lark.tree_templates import TemplateConf, Template, TemplateTranslator
SOME_NON_TEMPLATED_STRING = "foo bar"
SOME_TEMPLATE_NAME = "thing"
SOME_TEMPL... | template.match(test_case)) | self.assertEqual | func_call | tests/test_tree_templates.py | test_template_match__no_template__empty_dictionary | TestTreeTemplatesTemplate | 121 | null |
lark-parser/lark | import json
import sys
import unittest
from itertools import product
from unittest import TestCase
from lark import Lark
from lark.reconstruct import Reconstructor
common = """
%import common (WS_INLINE, NUMBER, WORD)
%ignore WS_INLINE
"""
def _remove_ws(s):
return s.replace(' ', '').replace('\n', '')
class Tes... | c) | assert_* | variable | tests/test_reconstructor.py | test_expand_rule | TestReconstructor | 102 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from lark import Lark
from lark.lexer import Token
from lark.tree import Tree
from lark.visitors import Visitor, Transformer, Discard
from lark.parsers.earley_forest import TreeForestTransformer, handles_ambiguity
class CustomTransformer(TreeForestTransf... | 'D' | assert | string_literal | tests/test_tree_forest_transformer.py | D | CustomTransformer | 62 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from lark import Lark
from lark.lexer import Token
from lark.tree import Tree
from lark.visitors import Visitor, Transformer, Discard
from lark.parsers.earley_forest import TreeForestTransformer, handles_ambiguity
class CustomTransformer(TreeForestTransf... | 'cd' | assert | string_literal | tests/test_tree_forest_transformer.py | ambiguous | CustomTransformer | 181 | null |
lark-parser/lark | from __future__ import absolute_import
import logging
from unittest import TestCase, main, skipIf
from lark import Lark, Tree, Transformer, UnexpectedInput
from lark.exceptions import ConfigurationError
from lark.lexer import Lexer, Token
import lark.lark as lark_module
from lark.reconstruct import Reconstructor
from... | Tree('start', []) | assert | func_call | tests/test_cache.py | test_simple | TestCache | 90 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from copy import deepcopy
from lark import Lark, Tree, Token
from lark.exceptions import MissingVariableError
from lark.tree_templates import TemplateConf, Template, TemplateTranslator
SOME_NON_TEMPLATED_STRING = "foo bar"
SOME_TEMPLATE_NAME = "thing"
SOME_TEMPL... | list(template.search(SOME_NON_TEMPLATE_TREE))) | self.assertEqual | func_call | tests/test_tree_templates.py | test_template_search__same_tree_no_template__empty_generator | TestTreeTemplatesTemplate | 149 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from copy import deepcopy
from lark import Lark, Tree, Token
from lark.exceptions import MissingVariableError
from lark.tree_templates import TemplateConf, Template, TemplateTranslator
SOME_NON_TEMPLATED_STRING = "foo bar"
SOME_TEMPLATE_NAME = "thing"
SOME_TEMPL... | template.match(tree)) | self.assertEqual | func_call | tests/test_tree_templates.py | test_template_match__match_same_tree__empty_dictionary | TestTreeTemplatesTemplateDefaultConf | 227 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from functools import partial, reduce, partialmethod
from operator import add, mul
from unittest import TestCase
import copy
import pickle
import functools
from lark.tree import Tree
from lark.lexer import Token
from lark.visitors import Visitor, Visitor_Recursiv... | 0 | assert | numeric_literal | tests/test_trees.py | test_eq | TestTrees | 28 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from copy import deepcopy
from lark import Lark, Tree, Token
from lark.exceptions import MissingVariableError
from lark.tree_templates import TemplateConf, Template, TemplateTranslator
SOME_NON_TEMPLATED_STRING = "foo bar"
SOME_TEMPLATE_NAME = "thing"
SOME_TEMPL... | translator.translate(tree)) | self.assertEqual | func_call | tests/test_tree_templates.py | test_translate__empty_translations__same_tree | TestTreeTemplatesTemplateTranslator | 205 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.