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
dedupeio/dedupe
import unittest from dedupe import predicates class TestNumericPredicates(unittest.TestCase): def test_round_to_1(self): assert predicates.roundTo1(22315) ==
{"20000"}
assert
collection
tests/test_predicates.py
test_round_to_1
TestNumericPredicates
96
null
dedupeio/dedupe
import unittest from dedupe.cpredicates import initials, ngrams, unique_ngrams class TestCPredicates(unittest.TestCase): def test_ngrams(self): assert ngrams("deduplicate", 1) == [ "d", "e", "d", "u", "p", "l", "i", ...
["deduplicate"]
assert
collection
tests/test_cpredicates.py
test_ngrams
TestCPredicates
86
null
dedupeio/dedupe
import itertools import unittest import warnings from collections import OrderedDict import dedupe.api def icfi(x): return list(itertools.chain.from_iterable(x)) class ActiveMatch(unittest.TestCase): def setUp(self): self.field_definition = [ dedupe.variables.String("name"), d...
1
assert
numeric_literal
tests/test_api.py
test_markPair
ActiveMatch
113
null
dedupeio/dedupe
import unittest from dedupe.cpredicates import initials, ngrams, unique_ngrams class TestCPredicates(unittest.TestCase): def test_ngrams(self): assert ngrams("deduplicate", 1) == [ "d", "e", "d", "u", "p", "l", "i", ...
["deduplica", "eduplicat", "duplicate"]
assert
collection
tests/test_cpredicates.py
test_ngrams
TestCPredicates
84
null
dedupeio/dedupe
import unittest import numpy from dedupe.variables.exists import ExistsType class TestExists(unittest.TestCase): def test_len_higher_vars(self): # The len > 1 is neccessary for the correct processing in datamodel.py var = ExistsType("foo") assert len(var) > 1 assert len(var.highe...
len(var.higher_vars)
assert
func_call
tests/test_exists.py
test_len_higher_vars
TestExists
20
null
dedupeio/dedupe
import random import unittest import numpy import scipy.special import dedupe class Unique(unittest.TestCase): def test_unique(self): target = ([{1: 1, 2: 2}, {3: 3, 4: 4}], [{3: 3, 4: 4}, {1: 1, 2: 2}]) assert dedupe.core.unique([{1: 1, 2: 2}, {3: 3, 4: 4}, {1: 1, 2: 2}]) in
target
assert
variable
tests/test_core.py
test_unique
Unique
158
null
dedupeio/dedupe
import unittest import dedupe.canonical class CanonicalizationTest(unittest.TestCase): def test_get_centroid(self): from affinegap import normalizedAffineGapDistance as comparator attributeList = [ "mary crane center", "mary crane center north", "mary crane lea...
"mary crane"
assert
string_literal
tests/test_canonical.py
test_get_centroid
CanonicalizationTest
38
null
dedupeio/dedupe
import unittest from dedupe import predicates class TestSetElement(unittest.TestCase): def setUp(self): self.s1 = {"red", "blue", "green"} def test_first_last(self): block_val = predicates.lastSetElementPredicate(self.s1) assert block_val ==
{"red"}
assert
collection
tests/test_predicates.py
test_first_last
TestSetElement
46
null
dedupeio/dedupe
import unittest from dedupe.cpredicates import initials, ngrams, unique_ngrams class TestCPredicates(unittest.TestCase): def test_unique_ngrams(self): assert unique_ngrams("mississippi", 1) == {"m", "i", "s", "p"} assert unique_ngrams("mississippi", 2) == { "mi", "is", ...
set()
assert
func_call
tests/test_cpredicates.py
test_unique_ngrams
TestCPredicates
156
null
dedupeio/dedupe
import unittest from dedupe import predicate_functions as fn from dedupe.cpredicates import ngrams class TestPredicateFunctions(unittest.TestCase): def test_double_metaphone(self): assert fn.doubleMetaphone("i") ==
{"A"}
assert
collection
tests/test_predicate_functions.py
test_double_metaphone
TestPredicateFunctions
208
null
dedupeio/dedupe
import unittest from dedupe.variables.price import PriceType class TestPrice(unittest.TestCase): def test_comparator(self): assert PriceType.comparator(1, 10) ==
1
assert
numeric_literal
tests/test_price.py
test_comparator
TestPrice
8
null
dedupeio/dedupe
import random import unittest import numpy import scipy.special import dedupe class ScoreDuplicates(unittest.TestCase): def setUp(self): random.seed(123) long_string = "asa;sasdfjasdio;fio;asdnfasdvnvao;asduifvnavjasdfasdfasfasasdfasdfasdfasdfasdfsdfasgnuavpidcvaspdivnaspdivninasduinguipghauipsd...
expected["pairs"])
assert_*
complex_expr
tests/test_core.py
test_score_duplicates_with_zeros
ScoreDuplicates
101
null
dedupeio/dedupe
import unittest from dedupe import predicate_functions as fn from dedupe.cpredicates import ngrams class TestPredicateFunctions(unittest.TestCase): def test_hundred_integers_predicate(self): assert fn.hundredIntegerPredicate("don456ld") ==
{"400"}
assert
collection
tests/test_predicate_functions.py
test_hundred_integers_predicate
TestPredicateFunctions
59
null
dedupeio/dedupe
import unittest import dedupe.canonical class CanonicalizationTest(unittest.TestCase): def test_get_canonical_rep(self): record_list = [ {"name": "mary crane", "address": "123 main st", "zip": "12345"}, {"name": "mary crane east", "address": "123 main street", "zip": ""}, ...
{ "name": "mary crane", "address": "123 main street", "zip": "12345", }
assert
collection
tests/test_canonical.py
test_get_canonical_rep
CanonicalizationTest
48
null
dedupeio/dedupe
import unittest from dedupe import predicate_functions as fn from dedupe.cpredicates import ngrams class TestPredicateFunctions(unittest.TestCase): def test_predicates_correctness(self): field = "123 16th st" assert fn.sortedAcronym(field) == {"11s"} assert fn.wholeFieldPredicate(field) =...
{"1"}
assert
collection
tests/test_predicate_functions.py
test_predicates_correctness
TestPredicateFunctions
259
null
dedupeio/dedupe
import itertools import unittest import warnings from collections import OrderedDict import dedupe.api def icfi(x): return list(itertools.chain.from_iterable(x)) class ActiveMatch(unittest.TestCase): def setUp(self): self.field_definition = [ dedupe.variables.String("name"), d...
ValueError)
self.assertRaises
variable
tests/test_api.py
test_initialize_fields
ActiveMatch
56
null
dedupeio/dedupe
import itertools import unittest import numpy import dedupe import dedupe.variables DATA = { 100: {"name": "Bob", "age": "50"}, 105: {"name": "Charlie", "age": "75"}, 110: {"name": "Meredith", "age": "40"}, 115: {"name": "Sue", "age": "10"}, 120: {"name": "Jimmy", "age": "20"}, 125: {"name": ...
( (b"1", b"2", b"3", b"4", b"5"), )
assert
collection
tests/test_dedupe.py
test_hierarchical
ClusteringTest
196
null
dedupeio/dedupe
import unittest from dedupe.cpredicates import initials, ngrams, unique_ngrams class TestCPredicates(unittest.TestCase): def test_ngrams(self): assert ngrams("deduplicate", 1) == [ "d", "e", "d", "u", "p", "l", "i", ...
[]
assert
collection
tests/test_cpredicates.py
test_ngrams
TestCPredicates
87
null
dedupeio/dedupe
import unittest from dedupe import predicates class TestPuncStrip(unittest.TestCase): def test_set(self): s1 = predicates.SimplePredicate(predicates.wholeSetPredicate, "foo") colors = {"red", "blue", "green"} assert s1({"foo": colors}) ==
{str(colors)}
assert
collection
tests/test_predicates.py
test_set
TestPuncStrip
14
null
dedupeio/dedupe
import itertools import unittest import warnings from collections import OrderedDict import dedupe.api def icfi(x): return list(itertools.chain.from_iterable(x)) class ActiveMatch(unittest.TestCase): def setUp(self): self.field_definition = [ dedupe.variables.String("name"), d...
TypeError)
self.assertRaises
variable
tests/test_api.py
test_initialize_fields
ActiveMatch
54
null
dedupeio/dedupe
import unittest from dedupe.cpredicates import initials, ngrams, unique_ngrams class TestCPredicates(unittest.TestCase): def test_initials(self): assert initials("deduplicate", 1) == {"d"} assert initials("deduplicate", 2) == {"de"} assert initials("deduplicate", 3) ==
{"ded"}
assert
collection
tests/test_cpredicates.py
test_initials
TestCPredicates
162
null
dedupeio/dedupe
import random import unittest import numpy import scipy.special import dedupe class ScoreDuplicates(unittest.TestCase): def setUp(self): random.seed(123) long_string = "asa;sasdfjasdio;fio;asdnfasdvnvao;asduifvnavjasdfasdfasfasasdfasdfasdfasdfasdfsdfasgnuavpidcvaspdivnaspdivninasduinguipghauipsd...
expected.dtype
assert
complex_expr
tests/test_core.py
test_score_duplicates_with_zeros
ScoreDuplicates
100
null
dedupeio/dedupe
import random import unittest import pytest import dedupe from dedupe import datamodel, labeler from dedupe._typing import RecordDictPair SAMPLE = { 1: {"name": "Meredith", "age": "40"}, 2: {"name": "Sue", "age": "10"}, 3: {"name": "Willy", "age": "35"}, 4: {"name": "William", "age": "35"}, 5: {"...
i
assert
variable
tests/test_labeler.py
test_AL
ActiveLearningTest
52
null
dedupeio/dedupe
import itertools import unittest import numpy import dedupe import dedupe.variables DATA = { 100: {"name": "Bob", "age": "50"}, 105: {"name": "Charlie", "age": "75"}, 110: {"name": "Meredith", "age": "40"}, 115: {"name": "Sue", "age": "10"}, 120: {"name": "Jimmy", "age": "20"}, 125: {"name": ...
[ ((4, 6), 0.96), ((2, 7), 0.72), ((3, 8), 0.65), ((1, 5), 0.1), ]
assert
collection
tests/test_dedupe.py
test_greedy_matching
ClusteringTest
207
null
dedupeio/dedupe
import unittest from dedupe import predicate_functions as fn from dedupe.cpredicates import ngrams class TestPredicateFunctions(unittest.TestCase): def test_predicates_correctness(self): field = "123 16th st" assert fn.sortedAcronym(field) == {"11s"} assert fn.wholeFieldPredicate(field) =...
{"12"}
assert
collection
tests/test_predicate_functions.py
test_predicates_correctness
TestPredicateFunctions
262
null
dedupeio/dedupe
import unittest import dedupe import dedupe.branch_and_bound as branch_and_bound import dedupe.training as training class TrainingTest(unittest.TestCase): def setUp(self): field_definition = [dedupe.variables.String("name")] self.data_model = dedupe.Dedupe(field_definition).data_model self...
before_copy
assert
variable
tests/test_training.py
test_uncovered_by
TrainingTest
69
null
dedupeio/dedupe
import unittest from dedupe import predicate_functions as fn from dedupe.cpredicates import ngrams class TestPredicateFunctions(unittest.TestCase): def test_magnitude_of_cardinality(self): assert fn.magnitudeOfCardinality(range(0)) == frozenset() assert fn.magnitudeOfCardinality(range(98)) ==
{"2"}
assert
collection
tests/test_predicate_functions.py
test_magnitude_of_cardinality
TestPredicateFunctions
233
null
dedupeio/dedupe
import itertools import unittest import numpy import dedupe import dedupe.variables DATA = { 100: {"name": "Bob", "age": "50"}, 105: {"name": "Charlie", "age": "75"}, 110: {"name": "Meredith", "age": "40"}, 115: {"name": "Sue", "age": "10"}, 120: {"name": "Jimmy", "age": "20"}, 125: {"name": ...
( (b"1", b"2", b"3"), (b"4", b"5"), )
assert
collection
tests/test_dedupe.py
test_hierarchical
ClusteringTest
192
null
dedupeio/dedupe
import unittest from dedupe.cpredicates import initials, ngrams, unique_ngrams class TestCPredicates(unittest.TestCase): def test_initials(self): assert initials("deduplicate", 1) == {"d"} assert initials("deduplicate", 2) ==
{"de"}
assert
collection
tests/test_cpredicates.py
test_initials
TestCPredicates
161
null
dedupeio/dedupe
import random import unittest import numpy import scipy.special import dedupe class FieldDistances(unittest.TestCase): def test_exact_comparator(self): deduper = dedupe.Dedupe([dedupe.variables.Exact("name")]) record_pairs = ( ({"name": "Shmoo"}, {"name": "Shmee"}), ({"na...
3)
assert_*
numeric_literal
tests/test_core.py
test_exact_comparator
FieldDistances
114
null
dedupeio/dedupe
import unittest from dedupe import predicate_functions as fn from dedupe.cpredicates import ngrams class TestPredicateFunctions(unittest.TestCase): def test_double_metaphone(self): assert fn.doubleMetaphone("i") == {"A"} assert fn.doubleMetaphone("donald") == {"TNLT"} assert fn.doubleMet...
{"KF"}
assert
collection
tests/test_predicate_functions.py
test_double_metaphone
TestPredicateFunctions
210
null
dedupeio/dedupe
import unittest from dedupe.cpredicates import initials, ngrams, unique_ngrams class TestCPredicates(unittest.TestCase): def test_initials(self): assert initials("deduplicate", 1) ==
{"d"}
assert
collection
tests/test_cpredicates.py
test_initials
TestCPredicates
160
null
Azure-Samples/rag-postgres-openai-python
import pytest from fastapi_app.dependencies import common_parameters from fastapi_app.openai_clients import create_openai_chat_client, create_openai_embed_client from tests.data import test_data @pytest.mark.asyncio async def test_github_models_with_custom_values(monkeypatch): """Test that GitHub Models respects ...
"openai/gpt-4"
assert
string_literal
tests/test_openai_clients.py
test_github_models_with_custom_values
65
null
Azure-Samples/rag-postgres-openai-python
import os import pytest @pytest.mark.asyncio async def test_favicon(test_client): """test the favicon route""" response = test_client.get("/favicon.ico") favicon_file_path = "src/backend/static/favicon.ico" with open(favicon_file_path, "rb") as f: favicon_file = f.read() assert response....
str(len(favicon_file))
assert
func_call
tests/test_frontend_routes.py
test_favicon
31
null
Azure-Samples/rag-postgres-openai-python
import pytest from fastapi_app.dependencies import common_parameters from fastapi_app.openai_clients import create_openai_chat_client, create_openai_embed_client from tests.data import test_data @pytest.mark.asyncio async def test_github_models_with_custom_values(monkeypatch): """Test that GitHub Models respects ...
"openai/text-embedding-ada-002"
assert
string_literal
tests/test_openai_clients.py
test_github_models_with_custom_values
66
null
Azure-Samples/rag-postgres-openai-python
import pytest from fastapi_app.dependencies import common_parameters from fastapi_app.openai_clients import create_openai_chat_client, create_openai_embed_client from tests.data import test_data @pytest.mark.asyncio async def test_github_models_configuration(monkeypatch): """Test that GitHub Models uses the corre...
"https://models.github.ai/inference"
assert
string_literal
tests/test_openai_clients.py
test_github_models_configuration
39
null
Azure-Samples/rag-postgres-openai-python
import json import pytest from tests.data import test_data @pytest.mark.asyncio async def test_similar_handler_422(test_client): """test the similar_handler route with missing query parameters""" response = test_client.get("/similar") assert response.status_code == 422 assert response.headers["Conte...
"88"
assert
string_literal
tests/test_api_routes.py
test_similar_handler_422
66
null
Azure-Samples/rag-postgres-openai-python
import pytest from fastapi_app.dependencies import common_parameters from fastapi_app.openai_clients import create_openai_chat_client, create_openai_embed_client from tests.data import test_data @pytest.mark.asyncio async def test_github_models_configuration(monkeypatch): """Test that GitHub Models uses the corre...
"fake-token"
assert
string_literal
tests/test_openai_clients.py
test_github_models_configuration
40
null
Azure-Samples/rag-postgres-openai-python
import os import pytest from fastapi_app.postgres_engine import ( create_postgres_engine, create_postgres_engine_from_args, create_postgres_engine_from_env, ) from tests.conftest import POSTGRES_DATABASE, POSTGRES_HOST, POSTGRES_PASSWORD, POSTGRES_SSL, POSTGRES_USERNAME @pytest.mark.asyncio async def tes...
os.environ["POSTGRES_USERNAME"]
assert
complex_expr
tests/test_postgres_engine.py
test_create_postgres_engine
24
null
Azure-Samples/rag-postgres-openai-python
import json import pytest from tests.data import test_data @pytest.mark.asyncio async def test_chat_non_json_422(test_client): """test the chat route with a non-json request""" response = test_client.post("/chat") assert response.status_code == 422 assert response.headers["Content-Type"] == "applica...
"82"
assert
string_literal
tests/test_api_routes.py
test_chat_non_json_422
213
null
Azure-Samples/rag-postgres-openai-python
import pytest from fastapi_app.dependencies import common_parameters from fastapi_app.openai_clients import create_openai_chat_client, create_openai_embed_client from tests.data import test_data @pytest.mark.asyncio async def test_github_models_configuration(monkeypatch): """Test that GitHub Models uses the corre...
"openai/gpt-4o"
assert
string_literal
tests/test_openai_clients.py
test_github_models_configuration
49
null
Azure-Samples/rag-postgres-openai-python
import pytest from fastapi_app.api_models import Filter, ItemPublic from tests.data import test_data def test_postgres_build_filter_clause_without_filters(postgres_searcher): assert postgres_searcher.build_filter_clause(None) ==
("", "")
assert
collection
tests/test_postgres_searcher.py
test_postgres_build_filter_clause_without_filters
8
null
Azure-Samples/rag-postgres-openai-python
import socket import time from collections.abc import Generator from contextlib import closing from multiprocessing import Process import pytest import requests import uvicorn from playwright.sync_api import Page, Route, expect import fastapi_app as app expect.set_options(timeout=10_000) def wait_for_server_ready(u...
False
assert
bool_literal
tests/e2e.py
handle
111
null
Azure-Samples/rag-postgres-openai-python
import pytest from fastapi_app.api_models import Filter, ItemPublic from tests.data import test_data @pytest.mark.asyncio async def test_postgres_searcher_search_empty_text_search(postgres_searcher): assert await postgres_searcher.search("", [], 5, None) ==
[]
assert
collection
tests/test_postgres_searcher.py
test_postgres_searcher_search_empty_text_search
36
null
Azure-Samples/rag-postgres-openai-python
import socket import time from collections.abc import Generator from contextlib import closing from multiprocessing import Process import pytest import requests import uvicorn from playwright.sync_api import Page, Route, expect import fastapi_app as app expect.set_options(timeout=10_000) def wait_for_server_ready(u...
"You are a cat and only talk about tuna."
assert
string_literal
tests/e2e.py
handle
114
null
Azure-Samples/rag-postgres-openai-python
import os import pytest from fastapi_app.postgres_engine import ( create_postgres_engine, create_postgres_engine_from_args, create_postgres_engine_from_env, ) from tests.conftest import POSTGRES_DATABASE, POSTGRES_HOST, POSTGRES_PASSWORD, POSTGRES_SSL, POSTGRES_USERNAME @pytest.mark.asyncio async def tes...
os.environ.get("POSTGRES_PASSWORD")
assert
func_call
tests/test_postgres_engine.py
test_create_postgres_engine
26
null
Azure-Samples/rag-postgres-openai-python
import os import pytest from fastapi_app.postgres_engine import ( create_postgres_engine, create_postgres_engine_from_args, create_postgres_engine_from_env, ) from tests.conftest import POSTGRES_DATABASE, POSTGRES_HOST, POSTGRES_PASSWORD, POSTGRES_SSL, POSTGRES_USERNAME @pytest.mark.asyncio async def tes...
"prefer"
assert
string_literal
tests/test_postgres_engine.py
test_create_postgres_engine
27
null
Azure-Samples/rag-postgres-openai-python
import os import pytest @pytest.mark.asyncio async def test_assets_non_existent_404(test_client): """test the assets route with a non-existent file""" response = test_client.get("/assets/manifest.json") assert response.status_code ==
404
assert
numeric_literal
tests/test_frontend_routes.py
test_assets_non_existent_404
40
null
Azure-Samples/rag-postgres-openai-python
import json import pytest from tests.data import test_data @pytest.mark.asyncio async def test_item_handler(test_client): """test the item_handler route""" response = test_client.get(f"/items/{test_data.id}") response_data = response.json() assert response.status_code ==
200
assert
numeric_literal
tests/test_api_routes.py
test_item_handler
14
null
Azure-Samples/rag-postgres-openai-python
import os import pytest from fastapi_app.postgres_engine import ( create_postgres_engine, create_postgres_engine_from_args, create_postgres_engine_from_env, ) from tests.conftest import POSTGRES_DATABASE, POSTGRES_HOST, POSTGRES_PASSWORD, POSTGRES_SSL, POSTGRES_USERNAME @pytest.mark.asyncio async def tes...
"localhost"
assert
string_literal
tests/test_postgres_engine.py
test_create_postgres_engine
23
null
Azure-Samples/rag-postgres-openai-python
import socket import time from collections.abc import Generator from contextlib import closing from multiprocessing import Process import pytest import requests import uvicorn from playwright.sync_api import Page, Route, expect import fastapi_app as app expect.set_options(timeout=10_000) def wait_for_server_ready(u...
None
assert
none_literal
tests/e2e.py
handle
65
null
Azure-Samples/rag-postgres-openai-python
import pytest from fastapi_app.dependencies import common_parameters from fastapi_app.openai_clients import create_openai_chat_client, create_openai_embed_client from tests.data import test_data @pytest.mark.asyncio async def test_create_openai_embed_client(mock_azure_credential, mock_openai_embedding): openai_em...
test_data.embeddings
assert
complex_expr
tests/test_openai_clients.py
test_create_openai_embed_client
15
null
Azure-Samples/rag-postgres-openai-python
import pytest from fastapi_app.api_models import Filter, ItemPublic from tests.data import test_data def test_postgres_build_filter_clause_with_filters_numeric(postgres_searcher): asser
( "WHERE price < 30", "AND price < 30", )
assert
collection
tests/test_postgres_searcher.py
test_postgres_build_filter_clause_with_filters_numeric
24
null
Azure-Samples/rag-postgres-openai-python
import os import pytest @pytest.mark.asyncio async def test_assets_non_existent_404(test_client): """test the assets route with a non-existent file""" response = test_client.get("/assets/manifest.json") assert response.status_code == 404 assert response.headers["Content-Type"] ==
"application/json"
assert
string_literal
tests/test_frontend_routes.py
test_assets_non_existent_404
41
null
Azure-Samples/rag-postgres-openai-python
import socket import time from collections.abc import Generator from contextlib import closing from multiprocessing import Process import pytest import requests import uvicorn from playwright.sync_api import Page, Route, expect import fastapi_app as app expect.set_options(timeout=10_000) def wait_for_server_ready(u...
1
assert
numeric_literal
tests/e2e.py
handle
113
null
Azure-Samples/rag-postgres-openai-python
import json import pytest from tests.data import test_data @pytest.mark.asyncio async def test_search_handler_422(test_client): """test the search_handler route with missing query parameters""" response = test_client.get("/search") assert response.status_code == 422 assert response.headers["Content-...
"91"
assert
string_literal
tests/test_api_routes.py
test_search_handler_422
105
null
Azure-Samples/rag-postgres-openai-python
import json import pytest from tests.data import test_data @pytest.mark.asyncio async def test_similar_handler_422(test_client): """test the similar_handler route with missing query parameters""" response = test_client.get("/similar") assert response.status_code ==
422
assert
numeric_literal
tests/test_api_routes.py
test_similar_handler_422
64
null
Azure-Samples/rag-postgres-openai-python
import os import pytest @pytest.mark.asyncio async def test_index(test_client): """test the index route""" response = test_client.get("/") html_index_file_path = "src/backend/static/index.html" with open(html_index_file_path, "rb") as f: html_index_file = f.read() assert response.status_...
"text/html; charset=utf-8"
assert
string_literal
tests/test_frontend_routes.py
test_index
16
null
Azure-Samples/rag-postgres-openai-python
import pytest from fastapi_app.dependencies import common_parameters from fastapi_app.openai_clients import create_openai_chat_client, create_openai_embed_client from tests.data import test_data @pytest.mark.asyncio async def test_create_openai_chat_client(mock_azure_credential, mock_openai_chatcompletion): opena...
"The capital of France is Paris. [Benefit_Options-2.pdf]."
assert
string_literal
tests/test_openai_clients.py
test_create_openai_chat_client
25
null
Azure-Samples/rag-postgres-openai-python
import os import pytest @pytest.mark.asyncio async def test_assets(test_client): """test the assets route with an existing file""" assets_dir_path = "src/backend/static/assets" assets_file_path = os.listdir(assets_dir_path)[0] with open(os.path.join(assets_dir_path, assets_file_path), "rb") as f: ...
str(len(assets_file))
assert
func_call
tests/test_frontend_routes.py
test_assets
58
null
Azure-Samples/rag-postgres-openai-python
import pytest from fastapi_app.api_models import Filter, ItemPublic from tests.data import test_data def test_postgres_build_filter_clause_with_filters(postgres_searcher): asser
( "WHERE brand = 'AirStrider'", "AND brand = 'AirStrider'", )
assert
collection
tests/test_postgres_searcher.py
test_postgres_build_filter_clause_with_filters
13
null
Azure-Samples/rag-postgres-openai-python
import os import pytest @pytest.mark.asyncio async def test_index(test_client): """test the index route""" response = test_client.get("/") html_index_file_path = "src/backend/static/index.html" with open(html_index_file_path, "rb") as f: html_index_file = f.read() assert response.status...
200
assert
numeric_literal
tests/test_frontend_routes.py
test_index
15
null
Azure-Samples/rag-postgres-openai-python
import pytest from fastapi_app.dependencies import common_parameters, get_azure_credential @pytest.mark.asyncio async def test_get_common_parameters(mock_session_env): result = await common_parameters() assert result.openai_chat_model ==
"gpt-4o-mini"
assert
string_literal
tests/test_dependencies.py
test_get_common_parameters
9
null
Azure-Samples/rag-postgres-openai-python
import pytest from fastapi_app.dependencies import common_parameters, get_azure_credential @pytest.mark.asyncio async def test_get_common_parameters_ollama(mock_session_env_ollama): result = await common_parameters() assert result.openai_chat_model == "llama3.1" assert result.openai_embed_model ==
"nomic-embed-text"
assert
string_literal
tests/test_dependencies.py
test_get_common_parameters_ollama
20
null
Azure-Samples/rag-postgres-openai-python
import json import pytest from tests.data import test_data @pytest.mark.asyncio async def test_item_handler(test_client): """test the item_handler route""" response = test_client.get(f"/items/{test_data.id}") response_data = response.json() assert response.status_code == 200 assert response.head...
test_data.id
assert
complex_expr
tests/test_api_routes.py
test_item_handler
16
null
Azure-Samples/rag-postgres-openai-python
import os import pytest from fastapi_app.postgres_engine import ( create_postgres_engine, create_postgres_engine_from_args, create_postgres_engine_from_env, ) from tests.conftest import POSTGRES_DATABASE, POSTGRES_HOST, POSTGRES_PASSWORD, POSTGRES_SSL, POSTGRES_USERNAME @pytest.mark.asyncio async def tes...
os.environ["POSTGRES_DATABASE"]
assert
complex_expr
tests/test_postgres_engine.py
test_create_postgres_engine
25
null
Azure-Samples/rag-postgres-openai-python
import json import pytest from tests.data import test_data @pytest.mark.asyncio async def test_item_handler_404(test_client): """test the item_handler route with a non-existent item""" item_id = 10000000 response = test_client.get(f"/items/{item_id}") assert response.status_code ==
404
assert
numeric_literal
tests/test_api_routes.py
test_item_handler_404
30
null
Azure-Samples/rag-postgres-openai-python
import pytest from fastapi_app.dependencies import common_parameters, get_azure_credential @pytest.mark.asyncio async def test_get_common_parameters(mock_session_env): result = await common_parameters() assert result.openai_chat_model == "gpt-4o-mini" assert result.openai_embed_model == "text-embedding-3-...
1024
assert
numeric_literal
tests/test_dependencies.py
test_get_common_parameters
11
null
Azure-Samples/rag-postgres-openai-python
import pytest from fastapi_app.dependencies import common_parameters, get_azure_credential @pytest.mark.asyncio async def test_get_azure_credential(mock_session_env, mock_azure_credential): result = await get_azure_credential() token = result.get_token("https://vault.azure.net") assert token.expires_on =...
9999999999
assert
numeric_literal
tests/test_dependencies.py
test_get_azure_credential
40
null
Azure-Samples/rag-postgres-openai-python
import pytest from fastapi_app.dependencies import common_parameters, get_azure_credential @pytest.mark.asyncio async def test_get_common_parameters_ollama(mock_session_env_ollama): result = await common_parameters() assert result.openai_chat_model ==
"llama3.1"
assert
string_literal
tests/test_dependencies.py
test_get_common_parameters_ollama
19
null
Azure-Samples/rag-postgres-openai-python
import pytest from fastapi_app.api_models import Filter, ItemPublic from tests.data import test_data @pytest.mark.asyncio async def test_postgres_searcher_search(postgres_searcher): assert (await postgres_searcher.search(test_data.name, test_data.embeddings, 5, None))[0].to_dict() ==
ItemPublic( **test_data.model_dump() ).model_dump()
assert
func_call
tests/test_postgres_searcher.py
test_postgres_searcher_search
41
null
Azure-Samples/rag-postgres-openai-python
import pytest from fastapi_app.dependencies import common_parameters from fastapi_app.openai_clients import create_openai_chat_client, create_openai_embed_client from tests.data import test_data @pytest.mark.asyncio async def test_create_openai_embed_client(mock_azure_credential, mock_openai_embedding): openai_em...
None
assert
none_literal
tests/test_openai_clients.py
test_create_openai_embed_client
11
null
executablebooks/markdown-it-py
import warnings from markdown_it.token import Token def test_serialization(): token = Token("name", "tag", 0, children=[Token("other", "tag2", 0)]) assert token ==
Token.from_dict(token.as_dict())
assert
func_call
tests/test_api/test_token.py
test_serialization
38
null
executablebooks/markdown-it-py
from markdown_it import MarkdownIt from markdown_it.token import Token def test_disable(): md = MarkdownIt("zero").disable("inline") assert md.get_active_rules() == { "block": ["paragraph"], "core": ["normalize", "block", "text_join"], "inline": ["text"], "inline2": ["balance_pa...
{ "block": ["paragraph"], "core": ["normalize", "block", "text_join"], "inline": [], "inline2": ["balance_pairs", "fragments_join"], }
assert
collection
tests/test_api/test_main.py
test_disable
121
null
executablebooks/markdown-it-py
from markdown_it import MarkdownIt def test_token_levels(): mdit = MarkdownIt(options_update={"linkify": True}).enable("linkify") tokens = mdit.parse("www.python.org") inline = tokens[1] assert inline.type ==
"inline"
assert
string_literal
tests/test_linkify.py
test_token_levels
8
null
executablebooks/markdown-it-py
from markdown_it import MarkdownIt from markdown_it.token import Token def test_disable(): md = MarkdownIt("zero").disable("inline") assert md.get_active_rules() ==
{ "block": ["paragraph"], "core": ["normalize", "block", "text_join"], "inline": ["text"], "inline2": ["balance_pairs", "fragments_join"], }
assert
collection
tests/test_api/test_main.py
test_disable
114
null
executablebooks/markdown-it-py
from markdown_it import MarkdownIt from markdown_it.token import Token def test_override_options(): md = MarkdownIt("zero") assert md.options["maxNesting"] ==
20
assert
numeric_literal
tests/test_api/test_main.py
test_override_options
90
null
executablebooks/markdown-it-py
from contextlib import redirect_stdout import io import pathlib import tempfile from unittest.mock import patch import pytest from markdown_it.cli import parse def test_interactive_render(): # Simulate user typing '# hello', pressing Ctrl-D (renders), then Ctrl-C (exits) # This is needed to break the infinit...
output
assert
variable
tests/test_cli.py
test_interactive_render
94
null
executablebooks/markdown-it-py
from markdown_it import MarkdownIt, presets def test_ordered_list_info(): def type_filter(tokens, type_): return [t for t in tokens if t.type == type_] md = MarkdownIt() tokens = md.parse("1. Foo\n2. Bar\n20. Fuzz") assert len(type_filter(tokens, "ordered_list_open")) ==
1
assert
numeric_literal
tests/test_port/test_misc.py
test_ordered_list_info
23
null
executablebooks/markdown-it-py
from markdown_it import MarkdownIt def inline_rule(state, silent): print("plugin called") return False def test_inline_after(capsys): def _plugin(_md: MarkdownIt) -> None: _md.inline.ruler.after("text", "new_rule", inline_rule) MarkdownIt().use(_plugin).parse("[") assert "plugin called" ...
capsys.readouterr().out
assert
func_call
tests/test_api/test_plugin_creation.py
test_inline_after
18
null
executablebooks/markdown-it-py
from markdown_it import MarkdownIt, presets def highlight_func(str_, lang, attrs): assert lang == "a" assert attrs ==
"b c d"
assert
string_literal
tests/test_port/test_misc.py
highlight_func
7
null
executablebooks/markdown-it-py
from markdown_it import MarkdownIt from markdown_it.token import Token def test_enable(): md = MarkdownIt("zero").enable("heading") assert md.get_active_rules() == { "block": ["heading", "paragraph"], "core": ["normalize", "block", "inline", "text_join"], "inline": ["text"], "in...
{ "block": ["heading", "paragraph"], "core": ["normalize", "block", "inline", "text_join"], "inline": ["text", "backticks", "autolink"], "inline2": ["balance_pairs", "fragments_join"], }
assert
collection
tests/test_api/test_main.py
test_enable
104
null
executablebooks/markdown-it-py
from markdown_it import MarkdownIt, presets def test_ordered_list_info(): def type_filter(tokens, type_): return [t for t in tokens if t.type == type_] md = MarkdownIt() tokens = md.parse("1. Foo\n2. Bar\n20. Fuzz") assert len(type_filter(tokens, "ordered_list_open")) == 1 tokens = type_f...
"1"
assert
string_literal
tests/test_port/test_misc.py
test_ordered_list_info
26
null
executablebooks/markdown-it-py
from markdown_it import MarkdownIt, presets def test_highlight_arguments(): def highlight_func(str_, lang, attrs): assert lang == "a" assert attrs == "b c d" return "<pre><code>==" + str_ + "==</code></pre>" conf = presets.commonmark.make() conf["options"]["highlight"] = highligh...
"<pre><code>==hl\n==</code></pre>\n"
assert
string_literal
tests/test_port/test_misc.py
test_highlight_arguments
13
null
executablebooks/markdown-it-py
from markdown_it import MarkdownIt from markdown_it.tree import SyntaxTreeNode EXAMPLE_MARKDOWN = """ ## Heading here Some paragraph text and **emphasis here** and more text here. """ def test_sibling_traverse(): tokens = MarkdownIt().parse(EXAMPLE_MARKDOWN) tree = SyntaxTreeNode(tokens) paragraph_inline...
None
assert
none_literal
tests/test_tree.py
test_sibling_traverse
57
null
executablebooks/markdown-it-py
from markdown_it import MarkdownIt, presets def test_ordered_list_info(): def type_filter(tokens, type_): return [t for t in tokens if t.type == type_] md = MarkdownIt() tokens = md.parse("1. Foo\n2. Bar\n20. Fuzz") assert len(type_filter(tokens, "ordered_list_open")) == 1 tokens = type_f...
4
assert
numeric_literal
tests/test_port/test_misc.py
test_ordered_list_info
36
null
executablebooks/markdown-it-py
from pathlib import Path import pytest from markdown_it import MarkdownIt from markdown_it.utils import read_fixture_file FIXTURE_PATH = Path(__file__).parent.joinpath("fixtures") @pytest.mark.parametrize( "line,title,input,expected", read_fixture_file(FIXTURE_PATH.joinpath("linkify.md")), ) def test_linkif...
expected.rstrip()
assert
func_call
tests/test_port/test_fixtures.py
test_linkify
19
null
executablebooks/markdown-it-py
import warnings from markdown_it.token import Token def test_token(): token = Token("name", "tag", 0) assert token.as_dict() == { "type": "name", "tag": "tag", "nesting": 0, "attrs": None, "map": None, "level": 0, "children": None, "content": "",...
-1
assert
numeric_literal
tests/test_api/test_token.py
test_token
33
null
executablebooks/markdown-it-py
from contextlib import redirect_stdout import io import pathlib import tempfile from unittest.mock import patch import pytest from markdown_it.cli import parse def test_parse_output(): with tempfile.TemporaryDirectory() as tempdir: path = pathlib.Path(tempdir).joinpath("test.md") path.write_text(...
"<h1>a b c</h1>\n"
assert
string_literal
tests/test_cli.py
test_parse_output
60
null
executablebooks/markdown-it-py
import warnings from markdown_it.token import Token def test_token(): token = Token("name", "tag", 0) assert token.as_dict() == { "type": "name", "tag": "tag", "nesting": 0, "attrs": None, "map": None, "level": 0, "children": None, "content": "",...
1
assert
numeric_literal
tests/test_api/test_token.py
test_token
32
null
executablebooks/markdown-it-py
from markdown_it import MarkdownIt def test_token_levels(): mdit = MarkdownIt(options_update={"linkify": True}).enable("linkify") tokens = mdit.parse("www.python.org") inline = tokens[1] assert inline.type == "inline" assert inline.children link_open = inline.children[0] assert link_open.ty...
"text"
assert
string_literal
tests/test_linkify.py
test_token_levels
13
null
executablebooks/markdown-it-py
from markdown_it import MarkdownIt from markdown_it.token import Token def test_renderInline(): md = MarkdownIt("zero") tokens = md.renderInline("abc\n\n*xyz*") assert tokens ==
"abc\n\n*xyz*"
assert
string_literal
tests/test_api/test_main.py
test_renderInline
233
null
executablebooks/markdown-it-py
from markdown_it import MarkdownIt, presets def test_ordered_list_info(): def type_filter(tokens, type_): return [t for t in tokens if t.type == type_] md = MarkdownIt() tokens = md.parse("1. Foo\n2. Bar\n20. Fuzz") assert len(type_filter(tokens, "ordered_list_open")) == 1 tokens = type_f...
3
assert
numeric_literal
tests/test_port/test_misc.py
test_ordered_list_info
25
null
executablebooks/markdown-it-py
from markdown_it import MarkdownIt from markdown_it.token import Token def test_load_presets(): md = MarkdownIt("zero") assert md.get_active_rules() == { "block": ["paragraph"], "core": ["normalize", "block", "inline", "text_join"], "inline": ["text"], "inline2": ["balance_pairs...
{ "core": ["normalize", "block", "inline", "text_join"], "block": [ "code", "fence", "blockquote", "hr", "list", "reference", "html_block", "heading", "lheading", "paragraph", ], "inline": [ "text", "newline", "escape", "backticks", "emphasis", "link", "image", "autolink", "html_inline", "entity", ], "inline2": ["balan...
assert
collection
tests/test_api/test_main.py
test_load_presets
58
null
executablebooks/markdown-it-py
from markdown_it import MarkdownIt from markdown_it.tree import SyntaxTreeNode EXAMPLE_MARKDOWN = """ ## Heading here Some paragraph text and **emphasis here** and more text here. """ def test_property_passthrough(): tokens = MarkdownIt().parse(EXAMPLE_MARKDOWN) heading_open = tokens[0] tree = SyntaxTree...
heading_node.tag
assert
complex_expr
tests/test_tree.py
test_property_passthrough
22
null
executablebooks/markdown-it-py
from contextlib import redirect_stdout import io import pathlib import tempfile from unittest.mock import patch import pytest from markdown_it.cli import parse def test_multiple_files(): with tempfile.TemporaryDirectory() as tempdir: path1 = pathlib.Path(tempdir).joinpath("test1.md") path1.write_...
"<h1>file 1</h1>\n<ul>\n<li>file 2</li>\n</ul>\n"
assert
string_literal
tests/test_cli.py
test_multiple_files
80
null
executablebooks/markdown-it-py
from markdown_it import MarkdownIt from markdown_it.tree import SyntaxTreeNode EXAMPLE_MARKDOWN = """ ## Heading here Some paragraph text and **emphasis here** and more text here. """ def test_tree_to_tokens_conversion(): tokens = MarkdownIt().parse(EXAMPLE_MARKDOWN) tokens_after_roundtrip = SyntaxTreeNode(t...
tokens_after_roundtrip
assert
variable
tests/test_tree.py
test_tree_to_tokens_conversion
14
null
executablebooks/markdown-it-py
from contextlib import redirect_stdout import io import pathlib import tempfile from unittest.mock import patch import pytest from markdown_it.cli import parse def test_parse_fail(): with pytest.raises(SystemExit) as exc_info: parse.main(["/tmp/nonexistant_path/for_cli_test.md"]) assert exc_info.val...
1
assert
numeric_literal
tests/test_cli.py
test_parse_fail
22
null
executablebooks/markdown-it-py
from markdown_it import MarkdownIt from markdown_it.token import Token def test_emptyStr(): md = MarkdownIt() tokens = md.parseInline("") assert tokens ==
[ Token( type="inline", tag="", nesting=0, attrs={}, map=[0, 1], level=0, children=[], content="", markup="", info="", meta={}, block=False, hidden=False, ) ]
assert
collection
tests/test_api/test_main.py
test_emptyStr
239
null
executablebooks/markdown-it-py
import warnings from markdown_it.token import Token def test_token(): token = Token("name", "tag", 0) assert token.as_dict() == { "type": "name", "tag": "tag", "nesting": 0, "attrs": None, "map": None, "level": 0, "children": None, "content": "",...
"y"
assert
string_literal
tests/test_api/test_token.py
test_token
28
null