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
sixty-north/cosmic-ray
import stat import pytest from exit_codes import ExitCode import cosmic_ray.cli import cosmic_ray.config import cosmic_ray.modules import cosmic_ray.mutating import cosmic_ray.plugins def config_file(tmpdir): return str(tmpdir.join("config.toml")) def _make_config(test_command="python -m unittest discover tests...
ExitCode.CONFIG
assert
complex_expr
tests/unittests/test_command_line_processing.py
test_non_existent_config_file_returns_EX_NOINPUT
64
null
sixty-north/cosmic-ray
import os import pathlib import subprocess import sys import pytest from cosmic_ray.tools.survival_rate import survival_rate from cosmic_ray.work_db import WorkDB, use_db def example_project_root(pytestconfig): root = pathlib.Path(str(pytestconfig.rootdir)) return root / "tests" / "resources" / "example_proj...
"Could not find module path example" + os.sep + "unknown_file.py"
assert
string_literal
tests/e2e/test_e2e.py
test_inexisting
103
null
sixty-north/cosmic-ray
import pytest from cosmic_ray.work_db import WorkDB, use_db from cosmic_ray.work_item import MutationSpec, WorkItem, WorkResult, WorkerOutcome from cosmic_ray.work_item import TestOutcome as TOutcome # We do this to prevent pytest from "collecting" TOutcome def work_db(): with use_db(":memory:", WorkDB.Mode.crea...
sorted(items[idx:], key=repr)
assert
func_call
tests/unittests/test_work_db.py
test_adding_result_clears_pending
164
null
sixty-north/cosmic-ray
import stat import pytest from exit_codes import ExitCode import cosmic_ray.cli import cosmic_ray.config import cosmic_ray.modules import cosmic_ray.mutating import cosmic_ray.plugins def config_file(tmpdir): return str(tmpdir.join("config.toml")) def _make_config(test_command="python -m unittest discover tests...
ExitCode.OK
assert
complex_expr
tests/unittests/test_command_line_processing.py
test_new_config_success_returns_EX_OK
77
null
sixty-north/cosmic-ray
from pathlib import Path import pytest from cosmic_ray.modules import filter_paths, find_modules def test_small_directory_tree(data_dir): paths = (("a", "__init__.py"), ("a", "b.py"), ("a", "py.py"), ("a", "c", "__init__.py"), ("a", "c", "d.py")) expected = sorted(data_dir / Path(*path) for path in paths) ...
results
assert
variable
tests/unittests/test_find_modules.py
test_small_directory_tree
12
null
sixty-north/cosmic-ray
import os import pathlib import subprocess import sys import pytest from cosmic_ray.tools.survival_rate import survival_rate from cosmic_ray.work_db import WorkDB, use_db def example_project_root(pytestconfig): root = pathlib.Path(str(pytestconfig.rootdir)) return root / "tests" / "resources" / "example_proj...
0
assert
numeric_literal
tests/e2e/test_e2e.py
test_baseline_with_pytest_filter
116
null
sixty-north/cosmic-ray
import subprocess import sys from cosmic_ray.tools.filters import operators_filter from cosmic_ray.work_item import MutationSpec, WorkItem, WorkResult, WorkerOutcome def test_operators_filter_empty_excludes(): data = FakeWorkDB() exclude = [] operators_filter.OperatorsFilter()._skip_filtered(data, exclude...
[]
assert
collection
tests/tools/test_filter_operators.py
test_operators_filter_empty_excludes
104
null
sixty-north/cosmic-ray
import copy import unittest import uuid import adam.adam_1 import adam.adam_2 class Tests(unittest.TestCase): def test_single_iteration(self): self.assertTrue(
adam.adam_2.single_iteration())
self.assertTrue
func_call
tests/resources/example_project/tests/test_adam.py
test_single_iteration
Tests
65
null
sixty-north/cosmic-ray
import os import pathlib import subprocess import sys import pytest from cosmic_ray.tools.survival_rate import survival_rate from cosmic_ray.work_db import WorkDB, use_db def example_project_root(pytestconfig): root = pathlib.Path(str(pytestconfig.rootdir)) return root / "tests" / "resources" / "example_proj...
subprocess.CalledProcessError)
pytest.raises
complex_expr
tests/e2e/test_e2e.py
test_reinit_session_with_results_fails
134
null
sixty-north/cosmic-ray
from pathlib import Path import pytest from cosmic_ray.modules import filter_paths, find_modules def test_finding_modules_with_missing_file(data_dir): path = data_dir / "a" / "inexisting_file.py" with pytest.raises(
FileNotFoundError)
pytest.raises
variable
tests/unittests/test_find_modules.py
test_finding_modules_with_missing_file
38
null
sixty-north/cosmic-ray
import copy import unittest import uuid import adam.adam_1 import adam.adam_2 class Tests(unittest.TestCase): def test_equals(self): vals = [uuid.uuid4(), uuid.uuid4()] vals.append(copy.copy(vals[0])) self.assertTrue(
adam.adam_1.equals(vals))
self.assertTrue
func_call
tests/resources/example_project/tests/test_adam.py
test_equals
Tests
53
null
sixty-north/cosmic-ray
import copy import unittest import uuid import adam.adam_1 import adam.adam_2 class Tests(unittest.TestCase): def test_decorator(self): self.assertTrue(
adam.adam_2.decorated_func())
self.assertTrue
func_call
tests/resources/example_project/tests/test_adam.py
test_decorator
Tests
71
null
sixty-north/cosmic-ray
import pytest from cosmic_ray.work_db import WorkDB, use_db from cosmic_ray.work_item import MutationSpec, WorkItem, WorkResult, WorkerOutcome from cosmic_ray.work_item import TestOutcome as TOutcome # We do this to prevent pytest from "collecting" TOutcome def work_db(): with use_db(":memory:", WorkDB.Mode.crea...
0
assert
numeric_literal
tests/unittests/test_work_db.py
test_clear_removes_work_items
79
null
sixty-north/cosmic-ray
import stat import pytest from exit_codes import ExitCode import cosmic_ray.cli import cosmic_ray.config import cosmic_ray.modules import cosmic_ray.mutating import cosmic_ray.plugins def config_file(tmpdir): return str(tmpdir.join("config.toml")) def _make_config(test_command="python -m unittest discover tests...
2
assert
numeric_literal
tests/unittests/test_command_line_processing.py
test_invalid_command_line_returns_EX_USAGE
55
null
sixty-north/cosmic-ray
import copy import unittest import uuid import adam.adam_1 import adam.adam_2 class Tests(unittest.TestCase): def test_handle_exception(self): self.assertTrue(
adam.adam_2.handle_exception())
self.assertTrue
func_call
tests/resources/example_project/tests/test_adam.py
test_handle_exception
Tests
68
null
sixty-north/cosmic-ray
import stat import pytest from exit_codes import ExitCode import cosmic_ray.cli import cosmic_ray.config import cosmic_ray.modules import cosmic_ray.mutating import cosmic_ray.plugins def config_file(tmpdir): return str(tmpdir.join("config.toml")) def _make_config(test_command="python -m unittest discover tests...
ExitCode.NO_INPUT
assert
complex_expr
tests/unittests/test_command_line_processing.py
test_non_existent_session_file_returns_EX_NOINPUT
59
null
sixty-north/cosmic-ray
import os import pathlib import subprocess import sys import pytest from cosmic_ray.tools.survival_rate import survival_rate from cosmic_ray.work_db import WorkDB, use_db def example_project_root(pytestconfig): root = pathlib.Path(str(pytestconfig.rootdir)) return root / "tests" / "resources" / "example_proj...
66
assert
numeric_literal
tests/e2e/test_e2e.py
test_inexisting
101
null
sixty-north/cosmic-ray
import pytest from cosmic_ray.work_db import WorkDB, use_db from cosmic_ray.work_item import MutationSpec, WorkItem, WorkResult, WorkerOutcome from cosmic_ray.work_item import TestOutcome as TOutcome # We do this to prevent pytest from "collecting" TOutcome def work_db(): with use_db(":memory:", WorkDB.Mode.crea...
original
assert
variable
tests/unittests/test_work_db.py
test_work_items
104
null
sixty-north/cosmic-ray
import os import pathlib import subprocess import sys import pytest from cosmic_ray.tools.survival_rate import survival_rate from cosmic_ray.work_db import WorkDB, use_db def example_project_root(pytestconfig): root = pathlib.Path(str(pytestconfig.rootdir)) return root / "tests" / "resources" / "example_proj...
work_db.num_work_items
assert
complex_expr
tests/e2e/test_e2e.py
test_reinit_session_with_results_fails
140
null
sixty-north/cosmic-ray
from pathlib import Path from cosmic_ray.mutating import mutate_and_test from cosmic_ray.work_item import MutationSpec, WorkResult, WorkerOutcome def test_no_test_return_value(path_utils, data_dir): with path_utils.excursion(data_dir): result = mutate_and_test( [ MutationSpec( ...
expected
assert
variable
tests/unittests/test_mutate_and_test.py
test_no_test_return_value
32
null
sixty-north/cosmic-ray
import pytest from cosmic_ray.work_db import WorkDB, use_db from cosmic_ray.work_item import MutationSpec, WorkItem, WorkResult, WorkerOutcome from cosmic_ray.work_item import TestOutcome as TOutcome # We do this to prevent pytest from "collecting" TOutcome def work_db(): with use_db(":memory:", WorkDB.Mode.crea...
KeyError)
pytest.raises
variable
tests/unittests/test_work_db.py
test_set_result_throws_KeyError_if_no_matching_work_item
39
null
sixty-north/cosmic-ray
from unittest import TestCase from calculator import mul class CalculatorTest(TestCase): def test_mul(self): self.assertEqual(mul(2, 2),
4)
self.assertEqual
numeric_literal
tests/resources/fast_tests/test_calculator.py
test_mul
CalculatorTest
8
null
sixty-north/cosmic-ray
import copy import unittest import uuid import adam.adam_1 import adam.adam_2 class Tests(unittest.TestCase): def test_binary_add(self): self.assertEqual(adam.adam_1.binary_add(),
11)
self.assertEqual
numeric_literal
tests/resources/example_project/tests/test_adam.py
test_binary_add
Tests
48
null
sixty-north/cosmic-ray
import parso import pytest from cosmic_ray.mutating import MutationVisitor from cosmic_ray.operators.binary_operator_replacement import ReplaceBinaryOperator_Add_Mul from cosmic_ray.operators.operator import Example from cosmic_ray.operators.unary_operator_replacement import ReplaceUnaryOperator_USub_UAdd from cosmic_...
sample.example.pre_mutation_code
assert
complex_expr
tests/unittests/operators/test_operator_samples.py
test_no_mutation_leaves_ast_unchanged
58
null
sixty-north/cosmic-ray
import pytest from cosmic_ray.work_db import WorkDB, use_db from cosmic_ray.work_item import MutationSpec, WorkItem, WorkResult, WorkerOutcome from cosmic_ray.work_item import TestOutcome as TOutcome # We do this to prevent pytest from "collecting" TOutcome def work_db(): with use_db(":memory:", WorkDB.Mode.crea...
sorted(items[:idx], key=repr)
assert
func_call
tests/unittests/test_work_db.py
test_new_work_items_are_pending
147
null
sixty-north/cosmic-ray
import os import pathlib import subprocess import sys import pytest from cosmic_ray.tools.survival_rate import survival_rate from cosmic_ray.work_db import WorkDB, use_db def example_project_root(pytestconfig): root = pathlib.Path(str(pytestconfig.rootdir)) return root / "tests" / "resources" / "example_proj...
""
assert
string_literal
tests/e2e/test_e2e.py
test_inexisting
102
null
sixty-north/cosmic-ray
import copy import unittest import uuid import adam.adam_1 import adam.adam_2 class Tests(unittest.TestCase): def test_bool_and(self): self.assertFalse(
adam.adam_1.bool_and())
self.assertFalse
func_call
tests/resources/example_project/tests/test_adam.py
test_bool_and
Tests
24
null
sixty-north/cosmic-ray
import unittest import mod class Tests(unittest.TestCase): def test_func(self): self.assertEqual(mod.func(),
1234)
self.assertEqual
numeric_literal
docs/source/tutorials/distributed/test_mod.1.py
test_func
Tests
8
null
sixty-north/cosmic-ray
import logging import os import shlex import subprocess import traceback from cosmic_ray.work_item import TestOutcome log = logging.getLogger(__name__) def run_tests(command, timeout): """Run test command in a subprocess. If the command exits with status 0, then we assume that all tests passed. If it ex...
0
assert
numeric_literal
src/cosmic_ray/testing.py
run_tests
47
null
sixty-north/cosmic-ray
import io from unittest import mock import pytest from cosmic_ray.config import ConfigDict, ConfigError, load_config, serialize_config def test_load_non_existent_file_raises_ConfigError(): with pytest.raises(
ConfigError)
pytest.raises
variable
tests/unittests/test_config.py
test_load_non_existent_file_raises_ConfigError
43
null
sixty-north/cosmic-ray
import subprocess import sys def test_smoke_test_for_execd_session(execd_session): command = [sys.executable, "-m", "cosmic_ray.tools.survival_rate", str(execd_session.session)] proc = subprocess.run(command, cwd=str(execd_session.session.parent), capture_output=True) assert proc.returncode == 0 asse...
18.18
assert
numeric_literal
tests/tools/test_rate.py
test_smoke_test_for_execd_session
18
null
sixty-north/cosmic-ray
import unittest import mod class Tests(unittest.TestCase): def test_func(self): self.assertEqual(mod.func(),
1234)
self.assertEqual
numeric_literal
docs/source/tutorials/intro/test_mod.1.py
test_func
Tests
8
null
sixty-north/cosmic-ray
from pathlib import Path from cosmic_ray.work_item import MutationSpec def test_mutation_spec_accepts_str_module_path(): mutation = MutationSpec("foo/bar.py", "operator", 0, (0, 0), (0, 1)) assert mutation.module_path ==
Path("foo/bar.py")
assert
func_call
tests/unittests/test_work_item.py
test_mutation_spec_accepts_str_module_path
11
null
sixty-north/cosmic-ray
import pytest from cosmic_ray.work_db import WorkDB, use_db from cosmic_ray.work_item import MutationSpec, WorkItem, WorkResult, WorkerOutcome from cosmic_ray.work_item import TestOutcome as TOutcome # We do this to prevent pytest from "collecting" TOutcome def work_db(): with use_db(":memory:", WorkDB.Mode.crea...
1
assert
numeric_literal
tests/unittests/test_work_db.py
test_set_multiple_results_works
64
null
sixty-north/cosmic-ray
import pytest from cosmic_ray.work_db import WorkDB, use_db from cosmic_ray.work_item import MutationSpec, WorkItem, WorkResult, WorkerOutcome from cosmic_ray.work_item import TestOutcome as TOutcome # We do this to prevent pytest from "collecting" TOutcome def work_db(): with use_db(":memory:", WorkDB.Mode.crea...
items[:idx]
assert
complex_expr
tests/unittests/test_work_db.py
test_adding_result_completes_work_item
190
null
sixty-north/cosmic-ray
from cosmic_ray.ast import get_ast_from_path def test_call_get_ast_from_path(tmp_path): module_filepath = tmp_path / "module.py" input_code = "def foo():\n pass\n" module_filepath.write_text(input_code) ast = get_ast_from_path(module_filepath) assert ast.get_code() ==
input_code
assert
variable
tests/unittests/test_ast.py
test_call_get_ast_from_path
9
null
sixty-north/cosmic-ray
import parso import pytest from cosmic_ray.mutating import MutationVisitor from cosmic_ray.operators.binary_operator_replacement import ReplaceBinaryOperator_Add_Mul from cosmic_ray.operators.operator import Example from cosmic_ray.operators.unary_operator_replacement import ReplaceUnaryOperator_USub_UAdd from cosmic_...
sample.example.post_mutation_code
assert
complex_expr
tests/unittests/operators/test_operator_samples.py
test_mutation_changes_ast
48
null
sixty-north/cosmic-ray
import subprocess import sys from cosmic_ray.tools.filters import operators_filter from cosmic_ray.work_item import MutationSpec, WorkItem, WorkResult, WorkerOutcome def test_operators_filter_all_excluded(): data = FakeWorkDB() exclude = [r"."] operators_filter.OperatorsFilter()._skip_filtered(data, exclu...
data.expected_all_filtered
assert
complex_expr
tests/tools/test_filter_operators.py
test_operators_filter_all_excluded
111
null
sixty-north/cosmic-ray
import copy import unittest import uuid import adam.adam_1 import adam.adam_2 class Tests(unittest.TestCase): def test_constant_false(self): self.assertEqual(adam.adam_1.constant_false(),
False)
self.assertEqual
bool_literal
tests/resources/example_project/tests/test_adam.py
test_constant_false
Tests
21
null
sixty-north/cosmic-ray
import pathlib import subprocess import sys import pytest from cosmic_ray.tools.survival_rate import survival_rate from cosmic_ray.work_db import WorkDB, use_db def project_root(pytestconfig): root = pathlib.Path(str(pytestconfig.rootdir)) return root / "tests" / "resources" / "fast_tests" def test_fast_tes...
18.18
assert
numeric_literal
tests/e2e/test_fast.py
test_fast_tests
35
null
sixty-north/cosmic-ray
import pytest from cosmic_ray.work_db import WorkDB, use_db from cosmic_ray.work_item import MutationSpec, WorkItem, WorkResult, WorkerOutcome from cosmic_ray.work_item import TestOutcome as TOutcome # We do this to prevent pytest from "collecting" TOutcome def work_db(): with use_db(":memory:", WorkDB.Mode.crea...
"second result"
assert
string_literal
tests/unittests/test_work_db.py
test_set_multiple_results_works
65
null
sixty-north/cosmic-ray
import os import pathlib import subprocess import sys import pytest from cosmic_ray.tools.survival_rate import survival_rate from cosmic_ray.work_db import WorkDB, use_db def example_project_root(pytestconfig): root = pathlib.Path(str(pytestconfig.rootdir)) return root / "tests" / "resources" / "example_proj...
0.0
assert
numeric_literal
tests/e2e/test_e2e.py
test_init_and_exec
38
null
sixty-north/cosmic-ray
import copy import unittest import uuid import adam.adam_1 import adam.adam_2 class Tests(unittest.TestCase): def test_continue_to_break(self): self.assertEqual(adam.adam_1.use_continue(10),
9)
self.assertEqual
numeric_literal
tests/resources/example_project/tests/test_adam.py
test_continue_to_break
Tests
59
null
sixty-north/cosmic-ray
import copy import unittest import uuid import adam.adam_1 import adam.adam_2 class Tests(unittest.TestCase): def test_unary_add(self): self.assertEqual(adam.adam_1.unary_add(),
+1)
self.assertEqual
numeric_literal
tests/resources/example_project/tests/test_adam.py
test_unary_add
Tests
45
null
sixty-north/cosmic-ray
import copy import unittest import uuid import adam.adam_1 import adam.adam_2 class Tests(unittest.TestCase): def test_unary_sub(self): self.assertEqual(adam.adam_1.unary_sub(),
-1)
self.assertEqual
numeric_literal
tests/resources/example_project/tests/test_adam.py
test_unary_sub
Tests
42
null
sixty-north/cosmic-ray
import stat import pytest from exit_codes import ExitCode import cosmic_ray.cli import cosmic_ray.config import cosmic_ray.modules import cosmic_ray.mutating import cosmic_ray.plugins def config_file(tmpdir): return str(tmpdir.join("config.toml")) def _make_config(test_command="python -m unittest discover tests...
ExitCode.NO_PERM
assert
complex_expr
tests/unittests/test_command_line_processing.py
test_unreadable_file_returns_EX_PERM
71
null
sixty-north/cosmic-ray
import copy import unittest import uuid import adam.adam_1 import adam.adam_2 class Tests(unittest.TestCase): def test_assert_in_func(self): self.assertTrue(
adam.adam_1.assert_in_func())
self.assertTrue
func_call
tests/resources/example_project/tests/test_adam.py
test_assert_in_func
Tests
39
null
sixty-north/cosmic-ray
import unittest from eve import eve class Tests(unittest.TestCase): def test_constant_42(self): self.assertEqual(eve.constant_42(),
42)
self.assertEqual
numeric_literal
tests/resources/example_project/tests/test_eve.py
test_constant_42
Tests
8
null
sixty-north/cosmic-ray
import io from unittest import mock import pytest from cosmic_ray.config import ConfigDict, ConfigError, load_config, serialize_config def test_load_from_valid_config_file(tmpdir): config_path = tmpdir / "config.conf" config = ConfigDict() config["key"] = "value" with config_path.open(mode="wt", enco...
"value"
assert
string_literal
tests/unittests/test_config.py
test_load_from_valid_config_file
39
null
eyurtsev/kor
from typing import Optional from pydantic import BaseModel, Field, ValidationError from pydantic import validator as pydantic_validator from kor.validators import PydanticValidator def test_pydantic_validator() -> None: """Test the PydanticValidator wrapper around pydantic.""" class ToyModel(BaseModel): ...
( ToyModel(name="Eugene", age=5), [], )
assert
collection
tests/test_validators.py
test_pydantic_validator
30
null
eyurtsev/kor
from typing import Any, Type, Union import pytest from kor.encoders.xml import XMLEncoder, _write_tag def test_write_tag() -> None: """Verify XML encoding works as expected.""" assert _write_tag("tag", "data") == "<tag>data</tag>" assert _write_tag("tag", ["data1", "data2"]) ==
"<tag>data1</tag><tag>data2</tag>"
assert
string_literal
tests/test_encoders/test_xml.py
test_write_tag
67
null
eyurtsev/kor
import asyncio from typing import List import pytest from langchain_core.documents import Document from kor import ( DocumentExtraction, Object, Text, create_extraction_chain, extract_from_documents, ) from ..utils import ToyChatModel SIMPLE_TEXT_SCHEMA = Text( id="text_node", descriptio...
"a!"
assert
string_literal
tests/extraction/test_extraction_from_documents.py
test_extract_from_documents_with_extraction_uid_function
123
null
eyurtsev/kor
from typing import Any import pytest from kor.encoders import Encoder, JSONEncoder, XMLEncoder, encode_examples from kor.nodes import AbstractSchemaNode, Number, Object, Option, Selection, Text def _get_schema() -> AbstractSchemaNode: """Make an abstract input node.""" option = Option(id="option", descriptio...
expected
assert
variable
tests/test_encoders/test_encoders.py
test_xml_encoding
51
null
eyurtsev/kor
from typing import Any import pytest from kor import nodes from kor.nodes import AbstractVisitor def test_text_examples() -> None: """Text examples. Verify that examples do not get re-interpreted in a strange way. """ assert nodes.Text( id="text", description="description", e...
[("input", "")]
assert
collection
tests/test_nodes.py
test_text_examples
89
null
eyurtsev/kor
from typing import Any, Type, Union import pytest from kor.encoders.xml import XMLEncoder, _write_tag def test_write_tag() -> None: """Verify XML encoding works as expected.""" assert _write_tag("tag", "data") ==
"<tag>data</tag>"
assert
string_literal
tests/test_encoders/test_xml.py
test_write_tag
66
null
eyurtsev/kor
from langchain_openai.chat_models import ChatOpenAI from pydantic import BaseModel, Field from kor.adapters import from_pydantic from kor.extraction import create_extraction_chain def test_pydantic() -> None: llm = ChatOpenAI(model_name="gpt-3.5-turbo", temperature=0, max_tokens=2000) class Person(BaseModel)...
data
assert
variable
tests/integration/extraction_with_chain.py
test_pydantic
32
null
eyurtsev/kor
from typing import Any import pytest from kor import JSONEncoder def test_json_encoding_with_non_ascii_chars() -> None: """Test json encoder with chinese characters.""" text = "我喜欢珍珠奶茶" # Test encoding / decoding with chinese characters and ensure_ascii = True json_encoder = JSONEncoder(use_tags=Tru...
text
assert
variable
tests/test_encoders/test_json.py
test_json_encoding_with_non_ascii_chars
54
null
eyurtsev/kor
import enum from typing import List, Union, get_type_hints import pydantic import pytest from pydantic.fields import Field from kor.adapters import ( _is_many, _translate_pydantic_to_kor, from_pydantic, ) from kor.nodes import Bool, Number, Object, Option, Optional, Selection, Text def test_from_pydantic...
Object( id="toy", attributes=[Text(id="a"), Number(id="b")], )
assert
func_call
tests/test_adapters.py
test_from_pydantic
194
null
eyurtsev/kor
from typing import Optional, Tuple import pytest from langchain_core.documents import Document from kor.documents.html import MarkdownifyHTMLProcessor @pytest.mark.parametrize( "tags,expected", [ (None, "Title\n\nTest"), # Use default (tuple(), "Title\nSvg\nStyle\nScript\n\nTest"), (...
{"a": 1}
assert
collection
tests/documents/test_html.py
test_markdownify_html_preprocessor
46
null
eyurtsev/kor
import pytest from kor import Number, Object, Text from kor.nodes import Bool, Option, Selection from kor.type_descriptors import BulletPointDescriptor, TypeScriptDescriptor OPTION_1 = Option(id="blue", description="Option Description", examples=["blue"]) OPTION_2 = Option(id="red", description="Red color", examples=...
description
assert
variable
tests/test_type_descriptors.py
test_bullet_point_descriptions
71
null
eyurtsev/kor
from typing import Any import pytest from kor import nodes from kor.nodes import AbstractVisitor def test_extraction_input_cannot_be_instantiated() -> None: """ExtractionInput is abstract and should not be instantiated.""" with pytest.raises(
TypeError)
pytest.raises
variable
tests/test_nodes.py
test_extraction_input_cannot_be_instantiated
19
null
eyurtsev/kor
from typing import Any import pytest from kor.encoders import Encoder, JSONEncoder, XMLEncoder, encode_examples from kor.nodes import AbstractSchemaNode, Number, Object, Option, Selection, Text def _get_schema() -> AbstractSchemaNode: """Make an abstract input node.""" option = Option(id="option", descriptio...
[ ("input", "output"), ("input2", "output2"), ]
assert
collection
tests/test_encoders/test_encoders.py
test_encode_examples
76
null
eyurtsev/kor
from typing import Any, Type import pytest from kor import Bool, Number, Object, Selection, Text from kor._pydantic import PYDANTIC_MAJOR_VERSION from kor.nodes import ExtractionSchemaNode def extraction_subclass(request: Any) -> Any: """Fixture to test all subclasses of ExtractionSchemaNode.""" return reque...
"nested_object"
assert
string_literal
tests/test_serialization.py
test_nested_object_deserialization
213
null
eyurtsev/kor
from typing import Any, Type import pytest from kor import Bool, Number, Object, Selection, Text from kor._pydantic import PYDANTIC_MAJOR_VERSION from kor.nodes import ExtractionSchemaNode def extraction_subclass(request: Any) -> Any: """Fixture to test all subclasses of ExtractionSchemaNode.""" return reque...
{ "attributes": [ { "description": "Number description", "examples": [], "id": "number", "many": False, "$type": "Number", }, { "description": "text description", "examples": [], "id": "text", "many": False, "$type": "Text", }, { "description": "bool description", "examples": [], "id": "bool", "many": False, "$type": "...
assert
collection
tests/test_serialization.py
test_serialize_deserialize_equals
46
null
eyurtsev/kor
from typing import Any import pytest from kor import JSONEncoder def test_json_encoding_with_tags() -> None: """Test JSON encoder with content wrapped in tags.""" json_encoder = JSONEncoder(use_tags=True) assert
'<json>{"object": [{"a": 1}]}</json>'
assert
string_literal
tests/test_encoders/test_json.py
test_json_encoding_with_tags
29
null
eyurtsev/kor
from langchain_openai.chat_models import ChatOpenAI from pydantic import BaseModel, Field from kor.adapters import from_pydantic from kor.extraction import create_extraction_chain def test_pydantic() -> None: llm = ChatOpenAI(model_name="gpt-3.5-turbo", temperature=0, max_tokens=2000) class Person(BaseModel)...
2
assert
numeric_literal
tests/integration/extraction_with_chain.py
test_pydantic
33
null
eyurtsev/kor
from typing import Optional from pydantic import BaseModel, Field, ValidationError from pydantic import validator as pydantic_validator from kor.validators import PydanticValidator def test_pydantic_validator() -> None: """Test the PydanticValidator wrapper around pydantic.""" class ToyModel(BaseModel): ...
1
assert
numeric_literal
tests/test_validators.py
test_pydantic_validator
37
null
eyurtsev/kor
from typing import Any import pytest from kor import JSONEncoder @pytest.mark.parametrize( "node_data,expected", [ ({"object": [{"number": ["1"]}]}, '{"object": [{"number": ["1"]}]}'), ({"object": [{"text": ["3"]}]}, '{"object": [{"text": ["3"]}]}'), ( {"object": [{"select...
expected
assert
variable
tests/test_encoders/test_json.py
test_json_encoding
22
null
eyurtsev/kor
import enum from typing import List, Union, get_type_hints import pydantic import pytest from pydantic.fields import Field from kor.adapters import ( _is_many, _translate_pydantic_to_kor, from_pydantic, ) from kor.nodes import Bool, Number, Object, Option, Optional, Selection, Text def test_convert_pydan...
Object( id="toy", attributes=[ Text( # Any union type of primitives is mapped to a text field for now. id="a" ), ], )
assert
func_call
tests/test_adapters.py
test_convert_pydantic_with_union
155
null
eyurtsev/kor
from kor.encoders.utils import unwrap_tag, wrap_in_tag def test_unwrap_tag() -> None: """Test unwrap_tag.""" # Test with an empty string assert unwrap_tag("", "") is None # Test with a string that doesn't contain the tag assert unwrap_tag("table", "This is some text.") is None # Test with a s...
"hello"
assert
string_literal
tests/test_encoders/test_utils.py
test_unwrap_tag
13
null
eyurtsev/kor
from typing import Any import pytest from kor import nodes from kor.nodes import AbstractVisitor def test_object_examples() -> None: """Object examples. Verifying that examples do not get re-interpreted in a strange way. The reason for these tests is that we're using pydantic and pydantic does auto-coer...
[]
assert
collection
tests/test_nodes.py
test_object_examples
35
null
eyurtsev/kor
from typing import Any import pytest from kor import JSONEncoder def test_json_encoding_with_non_ascii_chars() -> None: """Test json encoder with chinese characters.""" text = "我喜欢珍珠奶茶" # Test encoding / decoding with chinese characters and ensure_ascii = True json_encoder = JSONEncoder(use_tags=Tru...
'<json>"\\u6211\\u559c\\u6b22\\u73cd\\u73e0\\u5976\\u8336"</json>'
assert
string_literal
tests/test_encoders/test_json.py
test_json_encoding_with_non_ascii_chars
44
null
eyurtsev/kor
from typing import Any import pytest from kor import JSONEncoder def test_json_encoding_with_tags() -> None: """Test JSON encoder with content wrapped in tags.""" json_encoder = JSONEncoder(use_tags=True) assert ( json_encoder.encode({"object": [{"a": 1}]}) == '<json>{"object": [{"a": 1}]...
{ "object": [{"a": 1}] }
assert
collection
tests/test_encoders/test_json.py
test_json_encoding_with_tags
33
null
eyurtsev/kor
from typing import Optional, Tuple import pytest from langchain_core.documents import Document from kor.documents.html import MarkdownifyHTMLProcessor @pytest.mark.parametrize( "tags,expected", [ (None, "Title\n\nTest"), # Use default (tuple(), "Title\nSvg\nStyle\nScript\n\nTest"), (...
expected
assert
variable
tests/documents/test_html.py
test_markdownify_html_preprocessor
45
null
eyurtsev/kor
from kor import __all__ def test_kor__all__() -> None: """Hard-code contents of __all__. Upon changes this may help serve as a reminder to correctly bump the semver. """ assert sorted(__all__) ==
[ "Bool", "BulletPointDescriptor", "CSVEncoder", "DocumentExtraction", "Extraction", "JSONEncoder", "Number", "Object", "Option", "Selection", "Text", "TypeDescriptor", "TypeScriptDescriptor", "XMLEncoder", "__version__", "create_extraction_chain", "extract_from_documents", "from_pydantic", ]
assert
collection
tests/test_public_interface.py
test_kor__all__
10
null
eyurtsev/kor
from typing import Any import pytest from kor import JSONEncoder @pytest.mark.parametrize( "node_data,expected", [ ({"object": [{"number": ["1"]}]}, '{"object": [{"number": ["1"]}]}'), ({"object": [{"text": ["3"]}]}, '{"object": [{"text": ["3"]}]}'), ( {"object": [{"select...
node_data
assert
variable
tests/test_encoders/test_json.py
test_json_encoding
23
null
eyurtsev/kor
from typing import Any, Type, Union import pytest from kor.encoders.xml import XMLEncoder, _write_tag @pytest.mark.parametrize( "obj,output", [ ({}, ""), ("hello", TypeError), ({"obj": []}, ""), ({"obj": 5}, "<obj>5</obj>"), ({"obj": {"name": ["Eugene"]}}, "<obj><name>...
output)
pytest.raises
variable
tests/test_encoders/test_xml.py
test_xml_encode
60
null
eyurtsev/kor
import enum from typing import List, Union, get_type_hints import pydantic import pytest from pydantic.fields import Field from kor.adapters import ( _is_many, _translate_pydantic_to_kor, from_pydantic, ) from kor.nodes import Bool, Number, Object, Option, Optional, Selection, Text def test_convert_pydan...
Object( id="toy", attributes=[ Selection( id="single_choice", options=[ Option(id="a"), Option(id="b"), Option(id="c"), ], examples=[("a", "a")], ), Selection( id="multiple_choices", many=True, options=[ Option(id="a"), Option(id="b"), Option(id="c"), ], examples=[("a b", ["a", "b"])], ), ], )
assert
func_call
tests/test_adapters.py
test_convert_pydantic_with_enum
120
null
eyurtsev/kor
from typing import Any, Type import pytest from kor import Bool, Number, Object, Selection, Text from kor._pydantic import PYDANTIC_MAJOR_VERSION from kor.nodes import ExtractionSchemaNode def extraction_subclass(request: Any) -> Any: """Fixture to test all subclasses of ExtractionSchemaNode.""" return reque...
"root_object"
assert
string_literal
tests/test_serialization.py
test_nested_object_deserialization
208
null
eyurtsev/kor
import enum from typing import List, Union, get_type_hints import pydantic import pytest from pydantic.fields import Field from kor.adapters import ( _is_many, _translate_pydantic_to_kor, from_pydantic, ) from kor.nodes import Bool, Number, Object, Option, Optional, Selection, Text @pytest.mark.parametri...
expected
assert
variable
tests/test_adapters.py
test_is_many
46
null
eyurtsev/kor
import enum from typing import List, Union, get_type_hints import pydantic import pytest from pydantic.fields import Field from kor.adapters import ( _is_many, _translate_pydantic_to_kor, from_pydantic, ) from kor.nodes import Bool, Number, Object, Option, Optional, Selection, Text def test_from_pydantic...
(Toy(a="hello", b=5), [])
assert
collection
tests/test_adapters.py
test_from_pydantic
193
null
eyurtsev/kor
from typing import Any import pytest from kor import JSONEncoder def test_json_encoding_with_non_ascii_chars() -> None: """Test json encoder with chinese characters.""" text = "我喜欢珍珠奶茶" # Test encoding / decoding with chinese characters and ensure_ascii = True json_encoder = JSONEncoder(use_tags=Tru...
'<json>"我喜欢珍珠奶茶"</json>'
assert
string_literal
tests/test_encoders/test_json.py
test_json_encoding_with_non_ascii_chars
53
null
eyurtsev/kor
from kor.encoders.utils import unwrap_tag, wrap_in_tag def test_wrap_in_tag() -> None: """Test wrap_in_tag.""" assert wrap_in_tag("table", "hello") ==
"<table>hello</table>"
assert
string_literal
tests/test_encoders/test_utils.py
test_wrap_in_tag
21
null
eyurtsev/kor
import enum from typing import List, Union, get_type_hints import pydantic import pytest from pydantic.fields import Field from kor.adapters import ( _is_many, _translate_pydantic_to_kor, from_pydantic, ) from kor.nodes import Bool, Number, Object, Option, Optional, Selection, Text def test_convert_pydan...
NotImplementedError)
pytest.raises
variable
tests/test_adapters.py
test_convert_pydantic_with_complex_union
179
null
eyurtsev/kor
from typing import Any, Type, Union import pytest from kor.encoders.xml import XMLEncoder, _write_tag def test_write_tag() -> None: """Verify XML encoding works as expected.""" assert _write_tag("tag", "data") == "<tag>data</tag>" assert _write_tag("tag", ["data1", "data2"]) == "<tag>data1</tag><tag>data...
"<tag><key1>value1</key1></tag>"
assert
string_literal
tests/test_encoders/test_xml.py
test_write_tag
68
null
eyurtsev/kor
from typing import Any import pytest from kor.encoders import Encoder, JSONEncoder, XMLEncoder, encode_examples from kor.nodes import AbstractSchemaNode, Number, Object, Option, Selection, Text def _get_schema() -> AbstractSchemaNode: """Make an abstract input node.""" option = Option(id="option", descriptio...
[ ("input", '<json>"output"</json>'), ("input2", '<json>"output2"</json>'), ]
assert
collection
tests/test_encoders/test_encoders.py
test_encode_examples
71
null
eyurtsev/kor
from typing import Any, Mapping, Optional import pytest from langchain_core.runnables import Runnable from kor.encoders import CSVEncoder, JSONEncoder from kor.extraction import create_extraction_chain from kor.nodes import Object, Text from tests.utils import ToyChatModel SIMPLE_TEXT_SCHEMA = Text( id="text_nod...
NotImplementedError)
pytest.raises
variable
tests/extraction/test_extraction_with_chain.py
test_not_implemented_assertion_raised_for_csv
102
null
eyurtsev/kor
from typing import Any, Type, Union import pytest from kor.encoders.xml import XMLEncoder, _write_tag def test_write_tag() -> None: """Verify XML encoding works as expected.""" assert _write_tag("tag", "data") == "<tag>data</tag>" assert _write_tag("tag", ["data1", "data2"]) == "<tag>data1</tag><tag>data...
"<tag><key1>value1</key1><key2>a</key2><key2>b</key2></tag>"
assert
string_literal
tests/test_encoders/test_xml.py
test_write_tag
73
null
eyurtsev/kor
import asyncio from typing import List import pytest from langchain_core.documents import Document from kor import ( DocumentExtraction, Object, Text, create_extraction_chain, extract_from_documents, ) from ..utils import ToyChatModel SIMPLE_TEXT_SCHEMA = Text( id="text_node", descriptio...
ValueError)
pytest.raises
variable
tests/extraction/test_extraction_from_documents.py
test_check_assertion_is_raised_when_using_missing_uuid
135
null
eyurtsev/kor
from typing import Any, Type import pytest from kor import Bool, Number, Object, Selection, Text from kor._pydantic import PYDANTIC_MAJOR_VERSION from kor.nodes import ExtractionSchemaNode def extraction_subclass(request: Any) -> Any: """Fixture to test all subclasses of ExtractionSchemaNode.""" return reque...
1
assert
numeric_literal
tests/test_serialization.py
test_nested_object_deserialization
216
null
eyurtsev/kor
from typing import Any import pytest from kor import nodes from kor.nodes import AbstractVisitor def test_text_examples() -> None: """Text examples. Verify that examples do not get re-interpreted in a strange way. """ assert nodes.T
[("input", "output")]
assert
collection
tests/test_nodes.py
test_text_examples
83
null
eyurtsev/kor
from typing import Any, Type, Union import pytest from kor.encoders.xml import XMLEncoder, _write_tag @pytest.mark.parametrize( "xml_string,output", [ ("", {}), ("<123>", {}), ("<d>blah</d>", {"d": ["blah"]}), ("<a>1</a><a>2</a>", {"a": ["1", "2"]}), ("<a>1</a><b>2</b>...
output
assert
variable
tests/test_encoders/test_xml.py
test_xml_decode
29
null
eyurtsev/kor
import enum from typing import List, Union, get_type_hints import pydantic import pytest from pydantic.fields import Field from kor.adapters import ( _is_many, _translate_pydantic_to_kor, from_pydantic, ) from kor.nodes import Bool, Number, Object, Option, Optional, Selection, Text def test_convert_pydan...
Object( id="toy", attributes=[ Text(id="a", description="hello"), Number(id="b", examples=[("b is 1", 1)]), Number(id="c", many=False), Bool(id="d"), # We don't have optional yet internally, so we don't check the # optional setting. Number(id="e"), # We don't have a boolean type yet. Number(id="f", many=True), Text(id=...
assert
func_call
tests/test_adapters.py
test_convert_pydantic
80
null
eyurtsev/kor
from typing import Any import pytest from kor import nodes from kor.nodes import AbstractVisitor def test_object_examples() -> None: """Object examples. Verifying that examples do not get re-interpreted in a strange way. The reason for these tests is that we're using pydantic and pydantic does auto-coer...
[("input", [{"a": "1", "b": "2"}, {"a": "3", "b": "4"}])]
assert
collection
tests/test_nodes.py
test_object_examples
54
null
eyurtsev/kor
import pytest from kor import JSONEncoder, Object, TypeScriptDescriptor from kor.encoders import InputFormatter from kor.prompts import create_langchain_prompt @pytest.mark.parametrize( "input_formatter, expected_string", [ (None, "user input"), ("triple_quotes", '"""\nuser input\n"""'), ...
prompt_value.to_string()
assert
func_call
tests/test_prompt_generation.py
test_input_formatter_applied_correctly
34
null
eyurtsev/kor
import pytest from kor import JSONEncoder, Object, TypeScriptDescriptor from kor.encoders import InputFormatter from kor.prompts import create_langchain_prompt @pytest.mark.parametrize( "input_formatter, expected_string", [ (None, "user input"), ("triple_quotes", '"""\nuser input\n"""'), ...
expected_string
assert
variable
tests/test_prompt_generation.py
test_input_formatter_applied_correctly
33
null
eyurtsev/kor
from typing import Any import pytest from kor.encoders import Encoder, JSONEncoder, XMLEncoder, encode_examples from kor.nodes import AbstractSchemaNode, Number, Object, Option, Selection, Text def _get_schema() -> AbstractSchemaNode: """Make an abstract input node.""" option = Option(id="option", descriptio...
[ ('"""\ninput\n"""', "output"), ('"""\ninput2\n"""', "output2"), ]
assert
collection
tests/test_encoders/test_encoders.py
test_encode_examples
86
null
eyurtsev/kor
from typing import Any, Type, Union import pytest from kor.encoders.xml import XMLEncoder, _write_tag def test_write_tag() -> None: """Verify XML encoding works as expected.""" assert _write_tag("tag", "data") == "<tag>data</tag>" assert _write_tag("tag", ["data1", "data2"]) == "<tag>data1</tag><tag>data...
"<tag><key1>value1</key1><key2>value2</key2></tag>"
assert
string_literal
tests/test_encoders/test_xml.py
test_write_tag
69
null
eyurtsev/kor
from typing import Any, Tuple import pytest from kor.nodes import ( AbstractSchemaNode, AbstractVisitor, Number, Object, Option, Selection, Text, ) @pytest.mark.parametrize( "node", [ Number(id="uid"), Text(id="uid"), Object(id="uid", attributes=[]), ...
("uid", {"a": "a", "b": "b"})
assert
collection
tests/test_visitors.py
test_visit_default_is_invoked
43
null
eyurtsev/kor
from typing import Any import pytest from kor.encoders import Encoder, JSONEncoder, XMLEncoder, encode_examples from kor.nodes import AbstractSchemaNode, Number, Object, Option, Selection, Text def _get_schema() -> AbstractSchemaNode: """Make an abstract input node.""" option = Option(id="option", descriptio...
[ ('Text: """\ninput\n"""', "output"), ('Text: """\ninput2\n"""', "output2"), ]
assert
collection
tests/test_encoders/test_encoders.py
test_encode_examples
81
null