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 |
|---|---|---|---|---|---|---|---|---|---|
scanapi/scanapi | from pytest import fixture, mark, raises
from scanapi.settings import settings
def mock_load_config_file(mocker):
return mocker.patch("scanapi.settings.load_config_file")
def mock_has_local_config_file(mocker):
return mocker.patch(
"scanapi.settings.Settings.has_local_config_file",
mocker.Pro... | None | assert | none_literal | tests/unit/test_settings.py | test_should_init_with_default_values | TestInit | 41 | null |
scanapi/scanapi | from pytest import mark
from scanapi.tree import EndpointNode
class TestDelay:
@mark.context("when parent node spec has a delay defined")
@mark.it("should set delay attribute the same as the parent's one")
def test_when_parent_has_delay(self):
node = EndpointNode(
{"name": "node"},
... | 2 | assert | numeric_literal | tests/unit/tree/endpoint_node/test_delay.py | test_when_parent_has_delay | TestDelay | 28 | null |
scanapi/scanapi | from pytest import mark
from scanapi.tree import EndpointNode
class TestPropagateSpecVars:
test_data = [
({"spec_var": "value"}, None, {"spec_var": "value"}),
(
{"spec_var": "${{ response }}"},
{"response": "value"},
{"spec_var": "value"},
),
]
... | {**node_vars, **existing_parent_var} | assert | collection | tests/unit/tree/endpoint_node/test_propagate_spec_vars.py | test_var_with_existing_name | TestPropagateSpecVars | 48 | null |
scanapi/scanapi | from pytest import fixture, mark
from scanapi.tree import EndpointNode, RequestNode
class TestHeaders:
def mock_evaluate(self, mocker):
mock_func = mocker.patch(
"scanapi.evaluators.spec_evaluator.SpecEvaluator.evaluate"
)
mock_func.return_value = ""
return mock_func
... | calls) | assert_* | variable | tests/unit/tree/request_node/test_headers.py | test_calls_evaluate | TestHeaders | 91 | null |
scanapi/scanapi | from pytest import fixture, mark, raises
from scanapi.evaluators.spec_evaluator import SpecEvaluator
from scanapi.tree import EndpointNode
def mock_string_evaluate(mocker):
return mocker.patch(
"scanapi.evaluators.spec_evaluator.StringEvaluator.evaluate"
)
def spec_evaluator():
parent = EndpointN... | "{}" | assert | string_literal | tests/unit/evaluators/test_spec_evaluator.py | test_when_registry_is_empty | TestRepr | 187 | null |
scanapi/scanapi | import requests
from pytest import fixture, mark
from scanapi.hide_utils import _hide, _override_info, hide_sensitive_info
def response(requests_mock):
requests_mock.get("http://test.com", text="data")
return requests.get("http://test.com")
class TestOverrideInfo:
@mark.it("should overrides params")
... | "http://test.com/users/details?test=SENSITIVE_INFORMATION&test2=test&test=SENSITIVE_INFORMATION" | assert | string_literal | tests/unit/test_hide_utils.py | test_overrides_params | TestOverrideInfo | 128 | null |
scanapi/scanapi | from pytest import fixture, mark, raises
from scanapi.settings import settings
def mock_load_config_file(mocker):
return mocker.patch("scanapi.settings.load_config_file")
def mock_has_local_config_file(mocker):
return mocker.patch(
"scanapi.settings.Settings.has_local_config_file",
mocker.Pro... | "my_config_file.yaml") | assert_* | string_literal | tests/unit/test_settings.py | test_should_save_preferences | TestSaveConfigFilePreferences | 62 | null |
scanapi/scanapi | from random import randrange
from pytest import mark, raises
from scanapi.session import Session
class TestExit:
@mark.it("should exit with proper error")
@mark.parametrize(
"failures, errors, error_code",
[(0, 0, 0), (1, 0, 1), (0, 1, 2), (1, 1, 2)],
)
def test_exit_with_proper_error... | error_code | assert | variable | tests/unit/test_session.py | test_exit_with_proper_error | TestExit | 62 | null |
scanapi/scanapi | import pathlib
from freezegun.api import FakeDatetime
from pytest import fixture, mark
from scanapi.reporter import Reporter
fake_results = [
{"response": "foo", "tests_results": [], "no_failure": True},
{"response": "bar", "tests_results": [], "no_failure": False},
]
def mock_version(mocker):
return mo... | False) | assert_* | bool_literal | tests/unit/test_reporter.py | test_should_write_to_default_output | TestWrite | 107 | null |
scanapi/scanapi | import logging
from pytest import fixture, mark
from httpx import HTTPError
from scanapi.exit_code import ExitCode
from scanapi.tree import EndpointNode
log = logging.getLogger(__name__)
class TestRun:
def mock_run_request(self, mocker):
return mocker.patch("scanapi.tree.request_node.RequestNode.run")
... | 1 | assert | numeric_literal | tests/unit/tree/endpoint_node/test_run.py | test_when_request_fails | TestRun | 97 | null |
scanapi/scanapi | from pytest import fixture, mark
from scanapi.tree import EndpointNode, RequestNode
class TestFullPathUrl:
def mock_evaluate(self, mocker):
mock_func = mocker.patch(
"scanapi.evaluators.spec_evaluator.SpecEvaluator.evaluate"
)
mock_func.return_value = ""
return mock_f... | "http://foo.com/foo-bar" | assert | string_literal | tests/unit/tree/request_node/test_full_path_url.py | test_with_path_custom_var | TestFullPathUrl | 85 | null |
scanapi/scanapi | from datetime import timedelta
from unittest.mock import MagicMock
from pytest import fixture, mark
from scanapi.console import (
write_report_path,
write_result,
write_results,
write_summary,
)
def mocked__console(mocker):
return mocker.patch("scanapi.console.console")
class TestWriteSummary:
... | "[bright_green]1 passed, [bright_red]1 failed, [bright_red]0 errors in 3.0s") | assert_* | string_literal | tests/unit/test_console.py | test_write_failures | TestWriteSummary | 159 | null |
scanapi/scanapi | from pytest import mark, raises
from scanapi.errors import InvalidKeyError
from scanapi.tree import EndpointNode
class TestOptions:
@mark.context("when node spec has and invalid options key defined")
@mark.it("should raise an exception")
def test_when_request_option_has_invalid_key(self):
node = ... | expected | assert | variable | tests/unit/tree/endpoint_node/test_options.py | test_when_request_option_has_invalid_key | TestOptions | 66 | null |
scanapi/scanapi | from pytest import mark, raises
from scanapi.config_loader import load_config_file
from scanapi.errors import BadConfigIncludeError, EmptyConfigFileError
class TestLoadConfigFile:
@mark.context("include file does not exist")
@mark.it("should raise an exception")
def test_should_raise_exception_3(self):
... | str(excinfo.value) | assert | func_call | tests/unit/test_config_loader.py | test_should_raise_exception_3 | TestLoadConfigFile | 65 | null |
scanapi/scanapi | from pytest import mark
from scanapi.tree import EndpointNode
class TestGetAllVars:
@mark.it("should not alter the content of spec_vars")
def test_do_not_alter_spec_var(self):
parent = EndpointNode({"name": "parent"})
parent_key = "parent_key"
parent_value = "parent_value"
par... | {node_key: node_value} | assert | collection | tests/unit/tree/endpoint_node/test_get_all_vars.py | test_do_not_alter_spec_var | TestGetAllVars | 46 | null |
scanapi/scanapi | import requests
from pytest import fixture, mark, raises
from scanapi.errors import InvalidPythonCodeError
from scanapi.evaluators import CodeEvaluator
class TestErrorMessages:
test_data = [
("${{1/0}}", "1/0"),
("${{undefined_var}}", "undefined_var"),
("${{invalid syntax here}}", "invali... | error.expression | assert | complex_expr | tests/unit/evaluators/test_code_evaluator.py | test_error_includes_offending_code | TestErrorMessages | 282 | null |
scanapi/scanapi | import requests
from pytest import fixture, mark
from scanapi.hide_utils import _hide, _override_info, hide_sensitive_info
def response(requests_mock):
requests_mock.get("http://test.com", text="data")
return requests.get("http://test.com")
class TestOverrideInfo:
@mark.it("should overrides body and emp... | b"{}" | assert | string_literal | tests/unit/test_hide_utils.py | test_overrides_body_and_empty_content | TestOverrideInfo | 172 | null |
scanapi/scanapi | from pytest import fixture, mark
from scanapi.tree import EndpointNode
class TestPath:
def mock_evaluate(self, mocker):
mock_func = mocker.patch(
"scanapi.tree.endpoint_node.SpecEvaluator.evaluate"
)
mock_func.return_value = ""
return mock_func
@mark.it("should c... | calls) | assert_* | variable | tests/unit/tree/endpoint_node/test_path.py | test_calls_evaluate | TestPath | 92 | null |
scanapi/scanapi | from pytest import mark
from scanapi.tree import EndpointNode
class TestParams:
@mark.context("when parent has params")
@mark.context(
"when both node and parent specs have a params attribute defined"
)
@mark.it(
"should set params attribute the result of merging "
"the node's... | {"abc": "def", "xxx": "www"} | assert | collection | tests/unit/tree/endpoint_node/test_params.py | test_when_parent_has_params | TestParams | 40 | null |
scanapi/scanapi | from pytest import mark
from scanapi.tree import EndpointNode, RequestNode
class TestDelay:
@mark.context("when request spec has no delay defined")
@mark.it("should set delay as 0")
def test_when_request_has_no_delay(self):
request = RequestNode(
{"name": "foo"}, endpoint=EndpointNode(... | 0 | assert | numeric_literal | tests/unit/tree/request_node/test_delay.py | test_when_request_has_no_delay | TestDelay | 15 | null |
scanapi/scanapi | import requests
from pytest import fixture, mark, raises
from scanapi.errors import InvalidKeyError, MissingMandatoryKeyError
from scanapi.utils import join_urls, session_with_retry, validate_keys
def response(requests_mock):
requests_mock.get("http://test.com", text="data")
return requests.get("http://test.c... | "Invalid key 'key2' at 'endpoint' scope. Available keys are: ('key1', 'key3')" | assert | string_literal | tests/unit/test_utils.py | test_should_raise_an_exception | TestValidateKeys | 81 | null |
scanapi/scanapi | from pytest import fixture, mark
from scanapi.tree import EndpointNode, RequestNode
class TestFullPathUrl:
def mock_evaluate(self, mocker):
mock_func = mocker.patch(
"scanapi.evaluators.spec_evaluator.SpecEvaluator.evaluate"
)
mock_func.return_value = ""
return mock_f... | path | assert | variable | tests/unit/tree/request_node/test_full_path_url.py | test_when_endpoint_has_no_url | TestFullPathUrl | 28 | null |
scanapi/scanapi | from pytest import fixture, mark
from scanapi.tree import EndpointNode, RequestNode
class TestBody:
def mock_evaluate(self, mocker):
mock_func = mocker.patch(
"scanapi.evaluators.spec_evaluator.SpecEvaluator.evaluate"
)
mock_func.return_value = ""
return mock_func
... | {"abc": "def"} | assert | collection | tests/unit/tree/request_node/test_body.py | test_when_request_has_body | TestBody | 38 | null |
scanapi/scanapi | import logging
from pytest import fixture, mark
from httpx import HTTPError
from scanapi.exit_code import ExitCode
from scanapi.tree import EndpointNode
log = logging.getLogger(__name__)
class TestRun:
def mock_run_request(self, mocker):
return mocker.patch("scanapi.tree.request_node.RequestNode.run")
... | ["foo", "bar"] | assert | collection | tests/unit/tree/endpoint_node/test_run.py | test_when_requests_are_successful | TestRun | 60 | null |
scanapi/scanapi | from pytest import fixture, mark
from scanapi.tree import EndpointNode, RequestNode, tree_keys
class TestValidate:
def mock_validate_keys(self, mocker):
return mocker.patch("scanapi.tree.request_node.validate_keys")
@mark.it("should call the validate_keys method")
def test_should_call_validate_k... | keys | assert | variable | tests/unit/tree/request_node/test_validate.py | test_should_call_validate_keys | TestValidate | 45 | null |
scanapi/scanapi | import pathlib
from freezegun.api import FakeDatetime
from pytest import fixture, mark
from scanapi.reporter import Reporter
fake_results = [
{"response": "foo", "tests_results": [], "no_failure": True},
{"response": "bar", "tests_results": [], "no_failure": False},
]
def mock_version(mocker):
return mo... | None | assert | none_literal | tests/unit/test_reporter.py | test_init_output_path_and_template | TestInit | 34 | null |
scanapi/scanapi | import logging
import yaml
from click.testing import CliRunner
from pytest import mark
from scanapi.cli import run
log = logging.getLogger(__name__)
runner = CliRunner()
def yaml_error(*args, **kwargs):
raise yaml.YAMLError("error foo")
class TestRun:
@mark.context("when something wrong happens")
@mar... | caplog.text | assert | complex_expr | tests/unit/test_main.py | test_should_log_error | TestRun | 54 | null |
scanapi/scanapi | from random import randrange
from pytest import mark, raises
from scanapi.session import Session
class TestInit:
def test_init_successes_and_failures(self):
session = Session()
assert session.successes == | 0 | assert | numeric_literal | tests/unit/test_session.py | test_init_successes_and_failures | TestInit | 14 | null |
scanapi/scanapi | from datetime import timedelta
from unittest.mock import MagicMock
from pytest import fixture, mark
from scanapi.console import (
write_report_path,
write_result,
write_results,
write_summary,
)
def mocked__console(mocker):
return mocker.patch("scanapi.console.console")
class TestWriteResult:
... | "[bright_green] [PASSED] [white]should_be_success") | assert_* | string_literal | tests/unit/test_console.py | test_write_success | TestWriteResult | 63 | null |
scanapi/scanapi | from pytest import fixture, mark
from scanapi.tree import EndpointNode, tree_keys
class TestValidate:
def mock_validate_keys(self, mocker):
return mocker.patch("scanapi.tree.endpoint_node.validate_keys")
@mark.it("should call the validate_keys method")
def test_should_call_validate_keys(self, mo... | keys | assert | variable | tests/unit/tree/endpoint_node/test_validate.py | test_should_call_validate_keys | TestValidate | 42 | null |
scanapi/scanapi | from pytest import mark, raises
from scanapi.config_loader import load_config_file
from scanapi.errors import BadConfigIncludeError, EmptyConfigFileError
class TestLoadConfigFile:
@mark.context("file is empty")
@mark.it("should raise an exception")
def test_should_raise_exception_2(self):
with ra... | "File 'tests/data/empty.yaml' is empty." | assert | string_literal | tests/unit/test_config_loader.py | test_should_raise_exception_2 | TestLoadConfigFile | 56 | null |
scanapi/scanapi | from pytest import fixture, mark, raises
from scanapi.errors import InvalidKeyError
from scanapi.tree import EndpointNode, RequestNode
class TestOptions:
def mock_evaluate(self, mocker):
mock_func = mocker.patch(
"scanapi.tree.request_node.SpecEvaluator.evaluate"
)
mock_func.r... | options | assert | variable | tests/unit/tree/request_node/test_options.py | test_when_request_has_options | TestOptions | 28 | null |
scanapi/scanapi | from pytest import mark
from scanapi.tree import EndpointNode
class TestHeaders:
@mark.context(
"when both node and parent specs have a headers attribute defined"
)
@mark.it(
"should set headers attribute the result of merging "
"the node's and the parent's headers"
)
def ... | {"abc": "def", "xxx": "www"} | assert | collection | tests/unit/tree/endpoint_node/test_headers.py | test_when_parent_has_headers | TestHeaders | 39 | null |
scanapi/scanapi | from pytest import fixture, mark
from scanapi.tree import EndpointNode, RequestNode
class TestRun:
def mock_session_with_retry(self, mocker):
return mocker.patch("scanapi.tree.request_node.session_with_retry")
def mock_run_tests(self, mocker):
return mocker.patch("scanapi.tree.request_node.R... | { "response": mock_session_with_retry().__enter__().request(), "tests_results": test_results, "no_failure": expected_no_failure, "request_node_name": "request_name", "options": {}, } | assert | collection | tests/unit/tree/request_node/test_run.py | test_build_result | TestRun | 251 | null |
scanapi/scanapi | import pathlib
from freezegun.api import FakeDatetime
from pytest import fixture, mark
from scanapi.reporter import Reporter
fake_results = [
{"response": "foo", "tests_results": [], "no_failure": True},
{"response": "bar", "tests_results": [], "no_failure": False},
]
def mock_version(mocker):
return mo... | 1 | assert | numeric_literal | tests/unit/test_reporter.py | test_should_open_report_in_browser | TestWrite | 165 | null |
scanapi/scanapi | from pytest import fixture, mark, raises
from scanapi.evaluators.spec_evaluator import SpecEvaluator
from scanapi.tree import EndpointNode
def mock_string_evaluate(mocker):
return mocker.patch(
"scanapi.evaluators.spec_evaluator.StringEvaluator.evaluate"
)
def spec_evaluator():
parent = EndpointN... | { "app_id": "foo", "token": "bar", } | assert | collection | tests/unit/evaluators/test_spec_evaluator.py | test_return_evaluated_dict | TestEvaluateDict | 141 | null |
scanapi/scanapi | import requests
from pytest import fixture, mark, raises
from scanapi.errors import InvalidKeyError, MissingMandatoryKeyError
from scanapi.utils import join_urls, session_with_retry, validate_keys
def response(requests_mock):
requests_mock.get("http://test.com", text="data")
return requests.get("http://test.c... | "Missing 'key2' key(s) at 'endpoint' scope" | assert | string_literal | tests/unit/test_utils.py | test_should_raise_an_exception_2 | TestValidateKeys | 97 | null |
scanapi/scanapi | from pytest import fixture, mark
from scanapi.tree import EndpointNode, RequestNode
class TestRun:
def mock_session_with_retry(self, mocker):
return mocker.patch("scanapi.tree.request_node.session_with_retry")
def mock_run_tests(self, mocker):
return mocker.patch("scanapi.tree.request_node.R... | request.full_url_path) | assert_* | complex_expr | tests/unit/tree/request_node/test_run.py | test_calls_request | TestRun | 51 | null |
scanapi/scanapi | from pytest import mark
from scanapi.tree import EndpointNode
class TestGetAllVars:
@mark.it("should not alter the content of spec_vars")
def test_do_not_alter_spec_var(self):
parent = EndpointNode({"name": "parent"})
parent_key = "parent_key"
parent_value = "parent_value"
par... | {parent_key: parent_value} | assert | collection | tests/unit/tree/endpoint_node/test_get_all_vars.py | test_do_not_alter_spec_var | TestGetAllVars | 45 | null |
scanapi/scanapi | from pytest import mark, raises
from scanapi.config_loader import load_config_file
from scanapi.errors import BadConfigIncludeError, EmptyConfigFileError
class TestLoadConfigFile:
@mark.context("when it is an YAML file")
@mark.it("should load")
def test_should_load_yaml(self):
data = load_config_f... | { "endpoints": [ { "name": "scanapi-demo", "path": "${BASE_URL}", "requests": [{"name": "health", "path": "/health/"}], } ] } | assert | collection | tests/unit/test_config_loader.py | test_should_load_yaml | TestLoadConfigFile | 14 | null |
scanapi/scanapi | from pytest import fixture, mark
from scanapi.tree import EndpointNode
class TestPath:
def mock_evaluate(self, mocker):
mock_func = mocker.patch(
"scanapi.tree.endpoint_node.SpecEvaluator.evaluate"
)
mock_func.return_value = ""
return mock_func
@mark.context("whe... | "http://foo.com/2" | assert | string_literal | tests/unit/tree/endpoint_node/test_path.py | test_with_path_not_string | TestPath | 74 | null |
scanapi/scanapi | import logging
from pytest import fixture, mark
from httpx import HTTPError
from scanapi.exit_code import ExitCode
from scanapi.tree import EndpointNode
log = logging.getLogger(__name__)
class TestRun:
def mock_run_request(self, mocker):
return mocker.patch("scanapi.tree.request_node.RequestNode.run")
... | 2 | assert | numeric_literal | tests/unit/tree/endpoint_node/test_run.py | test_when_requests_are_successful | TestRun | 58 | null |
scanapi/scanapi | from pytest import fixture, mark, raises
from scanapi.settings import settings
def mock_load_config_file(mocker):
return mocker.patch("scanapi.settings.load_config_file")
def mock_has_local_config_file(mocker):
return mocker.patch(
"scanapi.settings.Settings.has_local_config_file",
mocker.Pro... | { "spec_path": "path/spec-path", "output_path": "path/output-path", "template": None, "no_report": False, "open_browser": False, "config_path": "path/config-path", } | assert | collection | tests/unit/test_settings.py | test_should_clean_and_save_preferences | TestSaveClickPreferences | 154 | null |
scanapi/scanapi | import errno
import logging
import os
import requests
import yaml
from pytest import fixture, mark, raises
from scanapi.errors import EmptyConfigFileError, InvalidKeyError
from scanapi.scan import scan
log = logging.getLogger(__name__)
def file_not_found(*args, **kwargs):
raise FileNotFoundError(
errno.... | False) | assert_* | bool_literal | tests/unit/test_scan.py | test_should_call_reporter_write_call_console_write_summary_and_exit | TestScan | 153 | null |
scanapi/scanapi | from pytest import fixture, mark
from scanapi.tree import EndpointNode, RequestNode
class TestBody:
def mock_evaluate(self, mocker):
mock_func = mocker.patch(
"scanapi.evaluators.spec_evaluator.SpecEvaluator.evaluate"
)
mock_func.return_value = ""
return mock_func
... | calls) | assert_* | variable | tests/unit/tree/request_node/test_body.py | test_calls_evaluate | TestBody | 54 | null |
scanapi/scanapi | from pytest import fixture, mark, raises
from scanapi.evaluators.spec_evaluator import SpecEvaluator
from scanapi.tree import EndpointNode
def mock_string_evaluate(mocker):
return mocker.patch(
"scanapi.evaluators.spec_evaluator.StringEvaluator.evaluate"
)
def spec_evaluator():
parent = EndpointN... | None | assert | none_literal | tests/unit/evaluators/test_spec_evaluator.py | test_should_return_none | TestGet | 29 | null |
dynaconf/dynaconf | from __future__ import annotations
from collections import namedtuple
import pytest
from dynaconf.utils.boxing import DynaBox
from dynaconf.vendor.box import BoxList
pytestmark = pytest.mark.skip("To be removed")
DBDATA = namedtuple("DbData", ["server", "port"])
box = DynaBox(
{
"server": {
... | 2 | assert | numeric_literal | tests/test_dynabox.py | test_access_lowercase | 50 | null | |
dynaconf/dynaconf | from __future__ import annotations
import os
import sys
import pytest
from dynaconf import Dynaconf
from dynaconf import LazySettings
from dynaconf import ValidationError
from dynaconf import Validator
from dynaconf.loaders import toml_loader
from dynaconf.loaders import yaml_loader
from dynaconf.nodes import DataDi... | 2 | assert | numeric_literal | tests/test_base.py | test_update__validate_on_update_is_str_all | 1,509 | null | |
dynaconf/dynaconf | from __future__ import annotations
import click
from dynaconf import settings
@click.command()
@click.option("--host", default=settings.HOST, help="Host")
@click.option("--port", default=settings.PORT, help="Port")
@click.option("--env", default=settings.current_env, help="Env")
def app(host, port, env):
"""Simp... | settings.current_env | assert | complex_expr | tests_functional/legacy/click_override_strict/app.py | app | 23 | null | |
dynaconf/dynaconf | import os
import sys
from typing import Annotated
from typing import Optional
from typing import Union
import pytest
from dynaconf.typed import DictValue
from dynaconf.typed import Dynaconf
from dynaconf.typed import DynaconfSchemaError
from dynaconf.typed import ItemsValidator
from dynaconf.typed import NotRequired
... | 3 | assert | numeric_literal | tests/test_typed.py | test_default_based_on_type_annotation | 539 | null | |
dynaconf/dynaconf | from __future__ import annotations
import copy
from collections import namedtuple
import pytest
from dynaconf.base import DynaconfCore
from dynaconf.nodes import DataDict
from dynaconf.nodes import DataList
from dynaconf.nodes import DynaconfNotInitialized
from dynaconf.nodes import get_core
from dynaconf.nodes impo... | 2 | assert | numeric_literal | tests/test_nodes.py | test_access_lowercase | 60 | null | |
dynaconf/dynaconf | from __future__ import annotations
import pytest
from dynaconf import LazySettings
from dynaconf.loaders.ini_loader import load
from dynaconf.strategies.filtering import PrefixFilter
settings = LazySettings(environments=True, ENV_FOR_DYNACONF="PRODUCTION")
INI = """
a = 'a,b'
[default]
password = '@int 99999'
host ... | "a,b" | assert | string_literal | tests/test_ini_loader.py | test_envless | 192 | null | |
dynaconf/dynaconf | import asyncio
import pytest
from dynaconf import Dynaconf
@pytest.mark.asyncio
async def test_contextvars_async_no_state_leakage():
"""Test that async tasks don't leak state between each other."""
results = []
async def task(task_id):
settings = Dynaconf()
settings.set("NESTED", "@forma... | expected | assert | variable | tests/test_async_safety.py | test_contextvars_async_no_state_leakage | 97 | null | |
dynaconf/dynaconf | from __future__ import annotations
import argparse
from dynaconf import settings
def main(argv=None):
parser = argparse.ArgumentParser(
description="Simple argparse example for overwrite dynaconf settings"
)
parser.add_argument("--env", default=settings.current_env)
parser.add_argument("--ho... | settings.current_env | assert | complex_expr | tests_functional/legacy/cli_override_argparse/app.py | main | 27 | null | |
dynaconf/dynaconf | from __future__ import annotations
import pytest
from dynaconf import Dynaconf
from dynaconf.hooking import Action
from dynaconf.hooking import EagerValue
from dynaconf.hooking import get_hooks
from dynaconf.hooking import Hook
from dynaconf.hooking import hookable
from dynaconf.hooking import HookableSettings
from d... | 1 | assert | numeric_literal | tests/test_hooking.py | test_hook_dynaconf_class_after_get | 103 | null | |
dynaconf/dynaconf | from __future__ import annotations
from collections import namedtuple
import pytest
from flask import Flask
from dynaconf.contrib import FlaskDynaconf
from tests_functional.legacy.flask_with_dotenv.app import app as flask_app
DBDATA = namedtuple("DbData", ["server", "port"])
def test_dynamic_load_exts(settings):
... | True | assert | bool_literal | tests/test_flask.py | test_dynamic_load_exts | 43 | null | |
dynaconf/dynaconf | from __future__ import annotations
import os
import sys
from collections import OrderedDict
from os import environ
import pytest
from dynaconf import settings # noqa
from dynaconf.loaders.env_loader import load
from dynaconf.loaders.env_loader import load_from_env
from dynaconf.loaders.env_loader import write
envi... | 1 | assert | numeric_literal | tests/test_env_loader.py | test_dotenv_loader | 100 | null | |
dynaconf/dynaconf | from __future__ import annotations
import json
import os
import sys
from collections import namedtuple
from pathlib import Path
from textwrap import dedent
import pytest
from dynaconf import add_converter
from dynaconf import default_settings
from dynaconf import Dynaconf
from dynaconf import DynaconfFormatError
fro... | 42 | assert | numeric_literal | tests/test_utils.py | test_disable_cast | 198 | null | |
dynaconf/dynaconf | from __future__ import annotations
import os
from collections.abc import Iterator
from typing import TYPE_CHECKING
import pytest
from dynaconf import LazySettings
from dynaconf.loaders.vault_loader import list_envs
from dynaconf.loaders.vault_loader import load
from dynaconf.loaders.vault_loader import write
from dy... | [] | assert | collection | tests/test_vault.py | test_list_envs_in_vault | 68 | null | |
dynaconf/dynaconf | from __future__ import annotations
from django.conf import settings
from django.test import TestCase
from django.test.utils import override_settings
class TestMerge(TestCase):
def test_merge(self):
self.assertEqual(
settings.LOGGING.loggers[""].handlers,
["console"],
)
... | "DEBUG") | self.assertEqual | string_literal | tests_functional/legacy/django_example/polls/tests.py | test_merge | TestMerge | 129 | null |
dynaconf/dynaconf | from __future__ import annotations
from collections import namedtuple
import pytest
from dynaconf.utils.boxing import DynaBox
from dynaconf.vendor.box import BoxList
pytestmark = pytest.mark.skip("To be removed")
DBDATA = namedtuple("DbData", ["server", "port"])
box = DynaBox(
{
"server": {
... | 1 | assert | numeric_literal | tests/test_dynabox.py | test_access_lowercase | 49 | null | |
dynaconf/dynaconf | from __future__ import annotations
import pytest
from dynaconf.base import LazySettings
TOML = """
[default]
dynaconf_include = ["plugin1.toml", "plugin2.toml", "plugin2.toml"]
DEBUG = false
SERVER = "base.example.com"
PORT = 6666
[development]
DEBUG = false
SERVER = "dev.example.com"
[production]
DEBUG = false
SE... | 4 | assert | numeric_literal | tests/test_nested_loading.py | test_load_nested_different_types_with_merge | 291 | null | |
dynaconf/dynaconf | from __future__ import annotations
import os
from collections.abc import Iterator
from typing import TYPE_CHECKING
import pytest
from dynaconf import LazySettings
from dynaconf.loaders.vault_loader import list_envs
from dynaconf.loaders.vault_loader import load
from dynaconf.loaders.vault_loader import write
from dy... | "prod" | assert | string_literal | tests/test_vault.py | test_vault_has_proper_source_metadata | 132 | null | |
dynaconf/dynaconf | from __future__ import annotations
from collections import namedtuple
import pytest
from dynaconf.utils.boxing import DynaBox
from dynaconf.vendor.box import BoxList
pytestmark = pytest.mark.skip("To be removed")
DBDATA = namedtuple("DbData", ["server", "port"])
box = DynaBox(
{
"server": {
... | None | assert | none_literal | tests/test_dynabox.py | test_get | 87 | null | |
dynaconf/dynaconf | from __future__ import annotations
from django.conf import settings
from django.test import TestCase
from django.test.utils import override_settings
class TestNoOverride(TestCase):
def test_settings(self):
self.assertEqual(settings.TEST_VALUE, | "a") | self.assertEqual | string_literal | tests_functional/legacy/django_example/polls/tests.py | test_settings | TestNoOverride | 96 | null |
dynaconf/dynaconf | from __future__ import annotations
import copy
from collections import namedtuple
import pytest
from dynaconf.base import DynaconfCore
from dynaconf.nodes import DataDict
from dynaconf.nodes import DataList
from dynaconf.nodes import DynaconfNotInitialized
from dynaconf.nodes import get_core
from dynaconf.nodes impo... | 1 | assert | numeric_literal | tests/test_nodes.py | test_access_lowercase | 59 | null | |
dynaconf/dynaconf | from __future__ import annotations
import pytest
from dynaconf import LazySettings
from dynaconf.loaders.ini_loader import load
from dynaconf.strategies.filtering import PrefixFilter
settings = LazySettings(environments=True, ENV_FOR_DYNACONF="PRODUCTION")
INI = """
a = 'a,b'
[default]
password = '@int 99999'
host ... | False | assert | bool_literal | tests/test_ini_loader.py | test_load_single_key | 123 | null | |
dynaconf/dynaconf | from __future__ import annotations
import copy
import os
from textwrap import dedent
import pytest
from dynaconf import Dynaconf
from dynaconf.utils.inspect import _ensure_serializable
from dynaconf.utils.inspect import _get_data_by_key
from dynaconf.utils.inspect import EnvNotFoundError
from dynaconf.utils.inspect ... | "A" | assert | string_literal | tests/test_inspect.py | test_get_data_by_key | 75 | null | |
dynaconf/dynaconf | from __future__ import annotations
import os
from collections.abc import Iterator
from typing import TYPE_CHECKING
import pytest
from dynaconf import LazySettings
from dynaconf.loaders.vault_loader import list_envs
from dynaconf.loaders.vault_loader import load
from dynaconf.loaders.vault_loader import write
from dy... | "dev" | assert | string_literal | tests/test_vault.py | test_vault_has_proper_source_metadata | 130 | null | |
dynaconf/dynaconf | from __future__ import annotations
from collections import namedtuple
import pytest
from dynaconf.utils.boxing import DynaBox
from dynaconf.vendor.box import BoxList
pytestmark = pytest.mark.skip("To be removed")
DBDATA = namedtuple("DbData", ["server", "port"])
box = DynaBox(
{
"server": {
... | "foo" | assert | string_literal | tests/test_dynabox.py | test_get | 88 | null | |
dynaconf/dynaconf | from __future__ import annotations
import pytest
from dynaconf.base import LazySettings
TOML = """
[default]
dynaconf_include = ["plugin1.toml", "plugin2.toml", "plugin2.toml"]
DEBUG = false
SERVER = "base.example.com"
PORT = 6666
[development]
DEBUG = false
SERVER = "dev.example.com"
[production]
DEBUG = false
SE... | 5 | assert | numeric_literal | tests/test_nested_loading.py | test_load_nested_different_types_with_merge | 293 | null | |
dynaconf/dynaconf | from __future__ import annotations
from django.conf import settings
from django.test import TestCase
from django.test.utils import override_settings
class TestOverrideClassDecoratorAndManager(TestCase):
def test_modified_settings(self):
with self.settings(TEST_VALUE="b"):
self.assertEqual(se... | "b") | self.assertEqual | string_literal | tests_functional/legacy/django_example/polls/tests.py | test_modified_settings | TestOverrideClassDecoratorAndManager | 91 | null |
dynaconf/dynaconf | from __future__ import annotations
from textwrap import dedent
import pytest
from dynaconf import Dynaconf
def create_file(filename: str, data: str) -> str:
"""Utility to create files"""
with open(filename, "w") as file:
file.write(dedent(data))
return filename
def test_file_scope_merge_false(t... | [9999] | assert | collection | tests_functional/issues/835_926_enable-merge-equal-false/app_test.py | test_file_scope_merge_false | 232 | null | |
dynaconf/dynaconf | from __future__ import annotations
from textwrap import dedent
import pytest
from dynaconf import Dynaconf
def create_file(filename: str, data: str) -> str:
"""Utility to create files"""
with open(filename, "w") as file:
file.write(dedent(data))
return filename
def test_local_scope_merge_false(... | {"database_url": "sqlite://"} | assert | collection | tests_functional/issues/835_926_enable-merge-equal-false/app_test.py | test_local_scope_merge_false | 183 | null | |
dynaconf/dynaconf | from __future__ import annotations
import os
from types import MappingProxyType
import pytest
from dynaconf import Dynaconf
from dynaconf import LazySettings
from dynaconf import ValidationError
from dynaconf import Validator
from dynaconf.validator import ValidatorList
TOML = """
[default]
EXAMPLE = true
MYSQL_HOS... | True | assert | bool_literal | tests/test_validators.py | test_default_eq_env_lvl_1 | 778 | null | |
dynaconf/dynaconf | from __future__ import annotations
import pytest
from dynaconf import Dynaconf
from dynaconf.hooking import Action
from dynaconf.hooking import EagerValue
from dynaconf.hooking import get_hooks
from dynaconf.hooking import Hook
from dynaconf.hooking import hookable
from dynaconf.hooking import HookableSettings
from d... | False | assert | bool_literal | tests/test_hooking.py | try_to_get_from_database | 178 | null | |
dynaconf/dynaconf | from __future__ import annotations
import json
import os
from pathlib import Path
from textwrap import dedent
from unittest import mock
import pytest
from dynaconf import default_settings
from dynaconf import LazySettings
from dynaconf.cli import EXTS
from dynaconf.cli import main
from dynaconf.cli import read_file_... | "foo" | assert | string_literal | tests/test_cli.py | test_list_prints_json | 261 | null | |
dynaconf/dynaconf | from __future__ import annotations
import pytest
from dynaconf.base import LazySettings
TOML = """
[default]
dynaconf_include = ["plugin1.toml", "plugin2.toml", "plugin2.toml"]
DEBUG = false
SERVER = "base.example.com"
PORT = 6666
[development]
DEBUG = false
SERVER = "dev.example.com"
[production]
DEBUG = false
SE... | 1 | assert | numeric_literal | tests/test_nested_loading.py | test_load_nested_different_types_with_merge | 288 | null | |
dynaconf/dynaconf | from __future__ import annotations
import click
from dynaconf import settings
@click.command()
@click.option("--host", default=settings.HOST, help="Host")
@click.option("--port", default=settings.PORT, help="Port")
@click.option("--env", default=settings.current_env, help="Env")
def app(**options):
"""Simple cli... | settings.current_env | assert | complex_expr | tests_functional/legacy/click_override_generic/app.py | app | 23 | null | |
dynaconf/dynaconf | from __future__ import annotations
import os
import sys
import pytest
from dynaconf import Dynaconf
from dynaconf import LazySettings
from dynaconf import ValidationError
from dynaconf import Validator
from dynaconf.loaders import toml_loader
from dynaconf.loaders import yaml_loader
from dynaconf.nodes import DataDi... | 123 | assert | numeric_literal | tests/test_base.py | test_deleted_raise | 42 | null | |
dynaconf/dynaconf | from __future__ import annotations
import pytest
from dynaconf import LazySettings
from dynaconf.loaders.ini_loader import load
from dynaconf.strategies.filtering import PrefixFilter
settings = LazySettings(environments=True, ENV_FOR_DYNACONF="PRODUCTION")
INI = """
a = 'a,b'
[default]
password = '@int 99999'
host ... | "hello" | assert | string_literal | tests/test_ini_loader.py | test_load_single_key | 127 | null | |
dynaconf/dynaconf | from __future__ import annotations
import json
import os
import sys
from collections import namedtuple
from pathlib import Path
from textwrap import dedent
import pytest
from dynaconf import add_converter
from dynaconf import default_settings
from dynaconf import Dynaconf
from dynaconf import DynaconfFormatError
fro... | 5 | assert | numeric_literal | tests/test_utils.py | test_merge_quoted_value_with_comma | 1,088 | null | |
dynaconf/dynaconf | from __future__ import annotations
import argparse
from dynaconf import settings
def main(argv=None):
parser = argparse.ArgumentParser(
description="Simple argparse example for overwrite dynaconf settings"
)
parser.add_argument("--env", default=settings.current_env)
parser.add_argument("--ho... | settings.HOST | assert | complex_expr | tests_functional/legacy/cli_override_argparse/app.py | main | 25 | null | |
dynaconf/dynaconf | from __future__ import annotations
import os
def test_boxed_data(settings):
assert settings.BOXED_DATA.host == "server.com"
assert settings.BOXED_DATA.port == 8080
assert settings.BOXED_DATA.params.username == "admin"
assert settings.BOXED_DATA.params.password == "secret"
assert settings.BOXED_DAT... | 2 | assert | numeric_literal | tests/test_endtoend.py | test_boxed_data | 58 | null | |
dynaconf/dynaconf | from __future__ import annotations
import os
def test_boxed_data(settings):
assert settings.BOXED_DATA.host == "server.com"
assert settings.BOXED_DATA.port == 8080
assert settings.BOXED_DATA.params.username == "admin"
assert settings.BOXED_DATA.params.password == | "secret" | assert | string_literal | tests/test_endtoend.py | test_boxed_data | 56 | null | |
dynaconf/dynaconf | from __future__ import annotations
import pytest
from config import settings
@pytest.fixture(scope="session", autouse=True)
def set_test_settings():
settings.configure(FORCE_ENV_FOR_DYNACONF="testing")
assert settings.current_env == | "testing" | assert | string_literal | tests_functional/issues/728_pytest/tests.py | set_test_settings | 10 | null | |
dynaconf/dynaconf | import os
import sys
from typing import Annotated
from typing import Optional
from typing import Union
import pytest
from dynaconf.typed import DictValue
from dynaconf.typed import Dynaconf
from dynaconf.typed import DynaconfSchemaError
from dynaconf.typed import ItemsValidator
from dynaconf.typed import NotRequired
... | 5 | assert | numeric_literal | tests/test_typed.py | test_default_based_on_type_annotation | 543 | null | |
dynaconf/dynaconf | from __future__ import annotations
import os
def test_359_jinja_interpolation():
from dynaconf import Dynaconf
data = {
"template": "hello",
"a": {
"main": "@jinja {{this.template}} world",
},
}
settings = Dynaconf(**data)
expected = {"main": "hello world"}
... | expected | assert | variable | tests/test_endtoend.py | test_359_jinja_interpolation | 83 | null | |
dynaconf/dynaconf | from __future__ import annotations
import os
from textwrap import dedent
from unittest import mock
import pytest
from dynaconf import Dynaconf
def create_file(filename: str, data: str):
"""Utility to help create tmp files"""
with open(filename, "w") as f:
f.write(dedent(data))
return filename
d... | "7" | assert | string_literal | tests_functional/issues/575_603_666_690__envvar_with_template_substitution/app_test.py | test_690_example | 126 | null | |
dynaconf/dynaconf | from __future__ import annotations
import pytest
from dynaconf import LazySettings
from dynaconf.loaders.ini_loader import load
from dynaconf.strategies.filtering import PrefixFilter
settings = LazySettings(environments=True, ENV_FOR_DYNACONF="PRODUCTION")
INI = """
a = 'a,b'
[default]
password = '@int 99999'
host ... | True | assert | bool_literal | tests/test_ini_loader.py | test_load_single_key | 122 | null | |
dynaconf/dynaconf | from __future__ import annotations
import os
import pytest
from dynaconf import default_settings
from dynaconf import LazySettings
from dynaconf.loaders.py_loader import load
from dynaconf.loaders.py_loader import try_to_load_from_py_module_name
from dynaconf.utils import DynaconfDict
def test_decorated_hooks(clean... | 43 | assert | numeric_literal | tests/test_py_loader.py | test_decorated_hooks | 180 | null | |
dynaconf/dynaconf | from __future__ import annotations
import pytest
from dynaconf import LazySettings
from dynaconf.loaders.ini_loader import load
from dynaconf.strategies.filtering import PrefixFilter
settings = LazySettings(environments=True, ENV_FOR_DYNACONF="PRODUCTION")
INI = """
a = 'a,b'
[default]
password = '@int 99999'
host ... | "blaz" | assert | string_literal | tests/test_ini_loader.py | test_load_single_key | 121 | null | |
dynaconf/dynaconf | from __future__ import annotations
import os
from textwrap import dedent
from unittest import mock
import pytest
from dynaconf import Dynaconf
def create_file(filename: str, data: str):
"""Utility to help create tmp files"""
with open(filename, "w") as f:
f.write(dedent(data))
return filename
d... | "9999" | assert | string_literal | tests_functional/issues/575_603_666_690__envvar_with_template_substitution/app_test.py | test_update_method_with_nesting | 79 | null | |
dynaconf/dynaconf | from __future__ import annotations
import os
import pytest
from dynaconf import LazySettings
from dynaconf.loaders.yaml_loader import load
from dynaconf.strategies.filtering import PrefixFilter
def settings():
return LazySettings(
environments=True,
ENV_FOR_DYNACONF="PRODUCTION",
# ROOT_... | 1 | assert | numeric_literal | tests/test_yaml_loader.py | test_load_from_yaml | 85 | null | |
dynaconf/dynaconf | from __future__ import annotations
import os
import sys
from collections import OrderedDict
from os import environ
import pytest
from dynaconf import settings # noqa
from dynaconf.loaders.env_loader import load
from dynaconf.loaders.env_loader import load_from_env
from dynaconf.loaders.env_loader import write
envi... | None | assert | none_literal | tests/test_env_loader.py | test_dotenv_loader | 105 | null | |
dynaconf/dynaconf | from __future__ import annotations
import pytest
from dynaconf.base import LazySettings
TOML = """
[default]
dynaconf_include = ["plugin1.toml", "plugin2.toml", "plugin2.toml"]
DEBUG = false
SERVER = "base.example.com"
PORT = 6666
[development]
DEBUG = false
SERVER = "dev.example.com"
[production]
DEBUG = false
SE... | True | assert | bool_literal | tests/test_nested_loading.py | test_load_nested_toml | 226 | null | |
dynaconf/dynaconf | from __future__ import annotations
from collections import namedtuple
import pytest
from flask import Flask
from dynaconf.contrib import FlaskDynaconf
from tests_functional.legacy.flask_with_dotenv.app import app as flask_app
DBDATA = namedtuple("DbData", ["server", "port"])
def test_compatibility_mode():
app ... | data | assert | variable | tests/test_flask.py | test_compatibility_mode | 174 | null | |
dynaconf/dynaconf | from __future__ import annotations
import pytest
from dynaconf.base import LazySettings
TOML = """
[default]
dynaconf_include = ["plugin1.toml", "plugin2.toml", "plugin2.toml"]
DEBUG = false
SERVER = "base.example.com"
PORT = 6666
[development]
DEBUG = false
SERVER = "dev.example.com"
[production]
DEBUG = false
SE... | 3 | assert | numeric_literal | tests/test_nested_loading.py | test_load_nested_different_types_with_merge | 290 | null | |
dynaconf/dynaconf | from __future__ import annotations
import click
from dynaconf import settings
@click.command()
@click.option("--host", default=settings.HOST, help="Host")
@click.option("--port", default=settings.PORT, help="Port")
@click.option("--env", default=settings.current_env, help="Env")
def app(**options):
"""Simple cli... | settings.PORT | assert | complex_expr | tests_functional/legacy/click_override_generic/app.py | app | 22 | null | |
dynaconf/dynaconf | from __future__ import annotations
import os
import sys
from collections import OrderedDict
from os import environ
import pytest
from dynaconf import settings # noqa
from dynaconf.loaders.env_loader import load
from dynaconf.loaders.env_loader import load_from_env
from dynaconf.loaders.env_loader import write
envi... | False | assert | bool_literal | tests/test_env_loader.py | test_dotenv_loader | 103 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.