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 |
|---|---|---|---|---|---|---|---|---|---|
sublimehq/package_control | import unittest
from ..clients.bitbucket_client import BitBucketClient
from ..clients.github_client import GitHubClient
from ..clients.gitlab_client import GitLabClient
from ..clients.pypi_client import PyPiClient
from ..clients.readme_client import ReadmeClient
from ..http_cache import HttpCache
from ._data_decorator... | client.download_info_from_branch(url, branch)) | self.assertEqual | func_call | package_control/tests/test_clients.py | download_info_from_branch | BitBucketClientTests | 255 | null |
sublimehq/package_control | import os
import sys
import tempfile
import unittest
from .. import distinfo
from .. import __version__
tmp_dir = tempfile.TemporaryDirectory
def _tag(version):
if sys.platform == "darwin":
if version == "3.3":
tag = "macosx_10_7_%s" % os.uname()[4]
elif version == "3.8":
... | len(paths)) | self.assertEqual | func_call | package_control/tests/test_distinfo.py | test_distinfo_top_level_paths | DistinfoTests | 349 | null |
sublimehq/package_control | import os
import sys
import tempfile
import unittest
from .. import distinfo
from .. import __version__
tmp_dir = tempfile.TemporaryDirectory
def _tag(version):
if sys.platform == "darwin":
if version == "3.3":
tag = "macosx_10_7_%s" % os.uname()[4]
elif version == "3.8":
... | len(modified)) | self.assertEqual | func_call | package_control/tests/test_distinfo.py | test_distinfo_verify_files | DistinfoTests | 406 | null |
sublimehq/package_control | import unittest
from ..selectors import is_compatible_version, is_compatible_platform
class PlatformSelectorTests(unittest.TestCase):
def test_is_compatible_platform_false(self):
platform_selectors = ["windows-x64", "windows", "*"]
self.assertFalse(is_compatible_platform("linux", platform_selecto... | is_compatible_platform(["linux"], platform_selectors)) | self.assertFalse | func_call | package_control/tests/test_selectors.py | test_is_compatible_platform_false | PlatformSelectorTests | 19 | null |
sublimehq/package_control | import unittest
from ..pep440 import (
PEP440InvalidVersionError,
PEP440Version,
)
from ._data_decorator import data_decorator, data
VERSIONS = [
# Implicit epoch of 0
"1.0.dev456",
"1.0a1",
"1.0a2.dev456",
"1.0a12.dev456",
"1.0a12",
"1.0b1.dev456",
"1.0b2",
"1.0b2.post345.... | PEP440InvalidVersionError) | self.assertRaises | variable | package_control/tests/test_pep440_version.py | invalid_versions | PEP440VersionTests | 210 | null |
marshmallow-code/apispec | import importlib.metadata
from datetime import datetime
import pytest
from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate
from packaging.version import Version
from apispec import APISpec, exceptions
from apispec.ext.marshmallow import MarshmallowPlugin, OpenAPIConverter
from .schemas import Cu... | 0 | assert | numeric_literal | tests/test_ext_marshmallow_openapi.py | test_fields_with_dump_only | TestMarshmallowFieldToOpenAPI | 43 | null |
marshmallow-code/apispec | import datetime as dt
import importlib.metadata
import re
from enum import Enum
import pytest
from marshmallow import Schema, fields, validate
from packaging.version import Version
from .schemas import CategorySchema, CustomIntegerField, CustomList, CustomStringField
from .utils import build_ref, get_schemas
MA_VERS... | 42 | assert | numeric_literal | tests/test_ext_marshmallow_field.py | test_field_with_default_and_load_default | 144 | null | |
marshmallow-code/apispec | import importlib.metadata
from datetime import datetime
import pytest
from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate
from packaging.version import Version
from apispec import APISpec, exceptions
from apispec.ext.marshmallow import MarshmallowPlugin, OpenAPIConverter
from .schemas import Cu... | None | assert | none_literal | tests/test_ext_marshmallow_openapi.py | test_openapi_tools_validate_v2 | 530 | null | |
marshmallow-code/apispec | import importlib.metadata
from datetime import datetime
import pytest
from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate
from packaging.version import Version
from apispec import APISpec, exceptions
from apispec.ext.marshmallow import MarshmallowPlugin, OpenAPIConverter
from .schemas import Cu... | True | assert | bool_literal | tests/test_ext_marshmallow_openapi.py | test_unknown_values_allow | TestMarshmallowSchemaToModelDefinition | 164 | null |
marshmallow-code/apispec | import importlib.metadata
import json
import pytest
from marshmallow import Schema
from marshmallow.fields import (
DateTime,
Dict,
Field,
Int,
List,
Nested,
String,
TimeDelta,
)
from packaging.version import Version
from apispec import APISpec
from apispec.exceptions import APISpecErr... | 1 | assert | numeric_literal | tests/test_ext_marshmallow.py | test_schema_v2 | TestOperationHelper | 426 | null |
marshmallow-code/apispec | import datetime as dt
import importlib.metadata
import re
from enum import Enum
import pytest
from marshmallow import Schema, fields, validate
from packaging.version import Version
from .schemas import CategorySchema, CustomIntegerField, CustomList, CustomStringField
from .utils import build_ref, get_schemas
MA_VERS... | ret | assert | variable | tests/test_ext_marshmallow_field.py | test_field_with_no_pattern | 403 | null | |
marshmallow-code/apispec | from apispec import utils
def test_build_reference():
assert utils.build_reference("schema", 2, "Test") == {"$ref": "#/definitions/Test"}
assert utils.build_reference("parameter", 2, "Test") == {
"$ref": "#/parameters/Test"
}
assert utils.build_reference("response", 2, "Test") == {"$ref": "#/re... | { "$ref": "#/components/schemas/Test" } | assert | collection | tests/test_utils.py | test_build_reference | 13 | null | |
marshmallow-code/apispec | import importlib.metadata
import json
import pytest
from marshmallow import Schema
from marshmallow.fields import (
DateTime,
Dict,
Field,
Int,
List,
Nested,
String,
TimeDelta,
)
from packaging.version import Version
from apispec import APISpec
from apispec.exceptions import APISpecErr... | 12 | assert | numeric_literal | tests/test_ext_marshmallow.py | test_schema_with_default_values | TestSchemaWithDefaultValues | 1,299 | null |
marshmallow-code/apispec | import importlib.metadata
from datetime import datetime
import pytest
from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate
from packaging.version import Version
from apispec import APISpec, exceptions
from apispec.ext.marshmallow import MarshmallowPlugin, OpenAPIConverter
from .schemas import Cu... | 1 | assert | numeric_literal | tests/test_ext_marshmallow_openapi.py | test_schema_body | TestMarshmallowSchemaToParameters | 334 | null |
marshmallow-code/apispec | import pytest
from apispec import yaml_utils
def test_dict_to_yaml_keys_are_not_sorted_by_default():
assert yaml_utils.dict_to_yaml({"herp": 1, "derp": 2}) == | "herp: 1\nderp: 2\n" | assert | string_literal | tests/test_yaml_utils.py | test_dict_to_yaml_keys_are_not_sorted_by_default | 38 | null | |
marshmallow-code/apispec | import copy
from http import HTTPStatus
import pytest
import yaml
from apispec import APISpec, BasePlugin
from apispec.exceptions import (
APISpecError,
DuplicateComponentNameError,
DuplicateParameterError,
InvalidParameterError,
)
from .utils import (
build_ref,
get_examples,
get_headers... | {} | assert | collection | tests/test_core.py | test_plugin_schema_helper_is_used | TestPlugins | 1,121 | null |
marshmallow-code/apispec | import pytest
from apispec import yaml_utils
def test_dict_to_yaml_unicode():
assert yaml_utils.dict_to_yaml({"가": "나"}) == '"\\uAC00": "\\uB098"\n'
assert yaml_utils.dict_to_yaml({"가": "나"}, {"allow_unicode": True}) == "가: | "가: 나\n" | assert | string_literal | tests/test_yaml_utils.py | test_dict_to_yaml_unicode | 34 | null | |
marshmallow-code/apispec | import copy
from http import HTTPStatus
import pytest
import yaml
from apispec import APISpec, BasePlugin
from apispec.exceptions import (
APISpecError,
DuplicateComponentNameError,
DuplicateParameterError,
InvalidParameterError,
)
from .utils import (
build_ref,
get_examples,
get_headers... | True | assert | bool_literal | tests/test_core.py | test_path_ensures_path_parameters_required | TestPath | 740 | null |
marshmallow-code/apispec | import pytest
from apispec import yaml_utils
@pytest.mark.parametrize("docstring", (None, "", "---"))
def test_load_yaml_from_docstring_empty_docstring(docstring):
assert yaml_utils.load_yaml_from_docstring(docstring) == | {} | assert | collection | tests/test_yaml_utils.py | test_load_yaml_from_docstring_empty_docstring | 24 | null | |
marshmallow-code/apispec | from apispec import utils
def test_build_reference():
assert utils.build_reference("schema", 2, "Test") == | {"$ref": "#/definitions/Test"} | assert | collection | tests/test_utils.py | test_build_reference | 5 | null | |
marshmallow-code/apispec | import pytest
from marshmallow import Schema, fields
from apispec.ext.marshmallow.common import (
get_fields,
get_unique_schema_name,
make_schema_key,
)
from .schemas import PetSchema, SampleSchema
class TestMakeSchemaKey:
def test_raise_if_schema_class_passed(self):
with pytest.raises( | TypeError, match="based on a Schema instance") | pytest.raises | complex_expr | tests/test_ext_marshmallow_common.py | test_raise_if_schema_class_passed | TestMakeSchemaKey | 15 | null |
marshmallow-code/apispec | import copy
from http import HTTPStatus
import pytest
import yaml
from apispec import APISpec, BasePlugin
from apispec.exceptions import (
APISpecError,
DuplicateComponentNameError,
DuplicateParameterError,
InvalidParameterError,
)
from .utils import (
build_ref,
get_examples,
get_headers... | "name" | assert | string_literal | tests/test_core.py | test_schema_discriminator | TestComponents | 235 | null |
marshmallow-code/apispec | from apispec import utils
def test_build_reference():
assert utils.build_reference("schema", 2, "Test") == {"$ref": "#/definitions/Test"}
assert utils.build_reference("parameter", 2, "Test") == | { "$ref": "#/parameters/Test" } | assert | collection | tests/test_utils.py | test_build_reference | 6 | null | |
marshmallow-code/apispec | import copy
from http import HTTPStatus
import pytest
import yaml
from apispec import APISpec, BasePlugin
from apispec.exceptions import (
APISpecError,
DuplicateComponentNameError,
DuplicateParameterError,
InvalidParameterError,
)
from .utils import (
build_ref,
get_examples,
get_headers... | 1 | assert | numeric_literal | tests/test_core.py | test_path_response_with_status_code_range | TestPath | 872 | null |
marshmallow-code/apispec | import importlib.metadata
from datetime import datetime
import pytest
from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate
from packaging.version import Version
from apispec import APISpec, exceptions
from apispec.ext.marshmallow import MarshmallowPlugin, OpenAPIConverter
from .schemas import Cu... | 2 | assert | numeric_literal | tests/test_ext_marshmallow_openapi.py | test_schema_query | TestMarshmallowSchemaToParameters | 372 | null |
marshmallow-code/apispec | import pytest
from apispec import yaml_utils
def test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs():
assert | "derp: 2\nherp: 1\n" | assert | string_literal | tests/test_yaml_utils.py | test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs | 42 | null | |
marshmallow-code/apispec | import datetime as dt
import importlib.metadata
import re
from enum import Enum
import pytest
from marshmallow import Schema, fields, validate
from packaging.version import Version
from .schemas import CategorySchema, CustomIntegerField, CustomList, CustomStringField
from .utils import build_ref, get_schemas
MA_VERS... | 6 | assert | numeric_literal | tests/test_ext_marshmallow_field.py | test_field_with_additional_metadata | 208 | null | |
marshmallow-code/apispec | import copy
from http import HTTPStatus
import pytest
import yaml
from apispec import APISpec, BasePlugin
from apispec.exceptions import (
APISpecError,
DuplicateComponentNameError,
DuplicateParameterError,
InvalidParameterError,
)
from .utils import (
build_ref,
get_examples,
get_headers... | p | assert | variable | tests/test_core.py | test_path_merges_paths | TestPath | 686 | null |
marshmallow-code/apispec | import importlib.metadata
import json
import pytest
from marshmallow import Schema
from marshmallow.fields import (
DateTime,
Dict,
Field,
Int,
List,
Nested,
String,
TimeDelta,
)
from packaging.version import Version
from apispec import APISpec
from apispec.exceptions import APISpecErr... | 2 | assert | numeric_literal | tests/test_ext_marshmallow.py | test_field_with_custom_props_passed_as_snake_case | TestFieldWithCustomProps | 1,291 | null |
marshmallow-code/apispec | import copy
from http import HTTPStatus
import pytest
import yaml
from apispec import APISpec, BasePlugin
from apispec.exceptions import (
APISpecError,
DuplicateComponentNameError,
DuplicateParameterError,
InvalidParameterError,
)
from .utils import (
build_ref,
get_examples,
get_headers... | header | assert | variable | tests/test_core.py | test_header | TestComponents | 299 | null |
marshmallow-code/apispec | import datetime as dt
import importlib.metadata
import re
from enum import Enum
import pytest
from marshmallow import Schema, fields, validate
from packaging.version import Version
from .schemas import CategorySchema, CustomIntegerField, CustomList, CustomStringField
from .utils import build_ref, get_schemas
MA_VERS... | res | assert | variable | tests/test_ext_marshmallow_field.py | test_field2property_no_type | 75 | null | |
marshmallow-code/apispec | from apispec import utils
def test_build_reference():
assert utils.build_reference("schema", 2, "Test") == {"$ref": "#/definitions/Test"}
assert utils.build_reference("parameter", 2, "Test") == {
"$ref": "#/parameters/Test"
}
assert utils.build_reference("response", 2, "Test") == | {"$ref": "#/responses/Test"} | assert | collection | tests/test_utils.py | test_build_reference | 9 | null | |
marshmallow-code/apispec | import datetime as dt
import importlib.metadata
import re
from enum import Enum
import pytest
from marshmallow import Schema, fields, validate
from packaging.version import Version
from .schemas import CategorySchema, CustomIntegerField, CustomList, CustomStringField
from .utils import build_ref, get_schemas
MA_VERS... | 1 | assert | numeric_literal | tests/test_ext_marshmallow_field.py | test_field_with_range_no_type | 331 | null | |
marshmallow-code/apispec | import pytest
from apispec import yaml_utils
def test_dict_to_yaml_unicode():
assert yaml_utils.dict_to_yaml({"가": "나"}) == '"\\ | '"\\uAC00": "\\uB098"\n' | assert | string_literal | tests/test_yaml_utils.py | test_dict_to_yaml_unicode | 33 | null | |
marshmallow-code/apispec | import pytest
from marshmallow import Schema, fields
from apispec.ext.marshmallow.common import (
get_fields,
get_unique_schema_name,
make_schema_key,
)
from .schemas import PetSchema, SampleSchema
class TestMakeSchemaKey:
def test_instances_with_different_modifiers_not_equal(self):
assert ... | make_schema_key(PetSchema(partial=True)) | assert | func_call | tests/test_ext_marshmallow_common.py | test_instances_with_different_modifiers_not_equal | TestMakeSchemaKey | 32 | null |
marshmallow-code/apispec | import pytest
from marshmallow import Schema, fields
from apispec.ext.marshmallow.common import (
get_fields,
get_unique_schema_name,
make_schema_key,
)
from .schemas import PetSchema, SampleSchema
class TestUniqueName:
def test_unique_name(self, spec):
properties = {
"id": {"type... | "Pet2" | assert | string_literal | tests/test_ext_marshmallow_common.py | test_unique_name | TestUniqueName | 57 | null |
marshmallow-code/apispec | import pytest
from marshmallow import Schema, fields
from apispec.ext.marshmallow.common import (
get_fields,
get_unique_schema_name,
make_schema_key,
)
from .schemas import PetSchema, SampleSchema
class TestMakeSchemaKey:
def test_same_schemas_instances_equal(self):
assert make_schema_key(... | make_schema_key(PetSchema()) | assert | func_call | tests/test_ext_marshmallow_common.py | test_same_schemas_instances_equal | TestMakeSchemaKey | 19 | null |
marshmallow-code/apispec | import importlib.metadata
import json
import pytest
from marshmallow import Schema
from marshmallow.fields import (
DateTime,
Dict,
Field,
Int,
List,
Nested,
String,
TimeDelta,
)
from packaging.version import Version
from apispec import APISpec
from apispec.exceptions import APISpecErr... | 42 | assert | numeric_literal | tests/test_ext_marshmallow.py | test_schema_with_default_values | TestSchemaWithDefaultValues | 1,300 | null |
marshmallow-code/apispec | from apispec import utils
def test_build_reference():
assert utils.build_reference("schema", 2, "Test") == {"$ref": "#/definitions/Test"}
assert utils.build_reference("parameter", 2, "Test") == {
"$ref": "#/parameters/Test"
}
assert utils.build_reference("response", 2, "Test") == {"$ref": "#/re... | { "$ref": "#/securityDefinitions/Test" } | assert | collection | tests/test_utils.py | test_build_reference | 10 | null | |
marshmallow-code/apispec | import copy
from http import HTTPStatus
import pytest
import yaml
from apispec import APISpec, BasePlugin
from apispec.exceptions import (
APISpecError,
DuplicateComponentNameError,
DuplicateParameterError,
InvalidParameterError,
)
from .utils import (
build_ref,
get_examples,
get_headers... | params | assert | variable | tests/test_core.py | test_parameter_is_chainable | TestComponents | 282 | null |
marshmallow-code/apispec | import importlib.metadata
import json
import pytest
from marshmallow import Schema
from marshmallow.fields import (
DateTime,
Dict,
Field,
Int,
List,
Nested,
String,
TimeDelta,
)
from packaging.version import Version
from apispec import APISpec
from apispec.exceptions import APISpecErr... | None | assert | none_literal | tests/test_ext_marshmallow.py | test_schema_global_state_untouched_2json | TestOperationHelper | 1,203 | null |
marshmallow-code/apispec | import pytest
from marshmallow import Schema, fields
from apispec.ext.marshmallow.common import (
get_fields,
get_unique_schema_name,
make_schema_key,
)
from .schemas import PetSchema, SampleSchema
class TestUniqueName:
def test_unique_name(self, spec):
properties = {
"id": {"type... | "Pet1" | assert | string_literal | tests/test_ext_marshmallow_common.py | test_unique_name | TestUniqueName | 50 | null |
marshmallow-code/apispec | import pytest
from marshmallow import Schema, fields
from apispec.ext.marshmallow.common import (
get_fields,
get_unique_schema_name,
make_schema_key,
)
from .schemas import PetSchema, SampleSchema
class TestUniqueName:
def test_unique_name(self, spec):
properties = {
"id": {"type... | "Pet" | assert | string_literal | tests/test_ext_marshmallow_common.py | test_unique_name | TestUniqueName | 43 | null |
marshmallow-code/apispec | import pytest
from apispec import yaml_utils
def test_load_yaml_from_docstring():
def f():
"""
Foo
bar
baz quux
---
herp: 1
derp: 2
"""
result = yaml_utils.load_yaml_from_docstring(f.__doc__)
assert result == | {"herp": 1, "derp": 2} | assert | collection | tests/test_yaml_utils.py | test_load_yaml_from_docstring | 19 | null | |
marshmallow-code/apispec | import datetime as dt
import importlib.metadata
import re
from enum import Enum
import pytest
from marshmallow import Schema, fields, validate
from packaging.version import Version
from .schemas import CategorySchema, CustomIntegerField, CustomList, CustomStringField
from .utils import build_ref, get_schemas
MA_VERS... | 100 | assert | numeric_literal | tests/test_ext_marshmallow_field.py | test_field_with_additional_metadata | 207 | null | |
fastapi-mvc/fastapi-mvc | import pytest
from fastapi_mvc.utils import ensure_permissions, require_fastapi_mvc_project, load_answers_file
from fastapi_mvc.constants import ANSWERS_FILE
class TestGeneratorEnsurePermissions:
def test_should_raise_when_path_does_not_exists(self):
# given / when / then
with pytest.raises( | SystemExit) | pytest.raises | variable | tests/unit/utils/test_generators.py | test_should_raise_when_path_does_not_exists | TestGeneratorEnsurePermissions | 52 | null |
fastapi-mvc/fastapi-mvc | import os
from tests.integration.conftest import assert_paths
from fastapi_mvc.generators import ControllerGenerator
class TestControllerGeneratorCli:
def test_should_generate_controller_using_given_arguments(self, cli_runner, default_project, monkeypatch):
# given / when
monkeypatch.chdir(defaul... | 0 | assert | numeric_literal | tests/integration/generators/test_controller.py | test_should_generate_controller_using_given_arguments | TestControllerGeneratorCli | 18 | null |
fastapi-mvc/fastapi-mvc | import os
import subprocess
from subprocess import CalledProcessError
from unittest import mock
import pytest
from fastapi_mvc.utils import get_git_user_info, run_shell, get_poetry_path
class TestRunShell:
def test_should_call_and_populate_defaults(self):
# given
cmd = ["/usr/bin/env", "true"]
... | cmd | assert | variable | tests/unit/utils/test_shell.py | test_should_call_and_populate_defaults | TestRunShell | 94 | null |
fastapi-mvc/fastapi-mvc | import os
import subprocess
from subprocess import CalledProcessError
from unittest import mock
import pytest
from fastapi_mvc.utils import get_git_user_info, run_shell, get_poetry_path
class TestGetGitUserInfo:
@mock.patch(
"fastapi_mvc.utils.shell.subprocess.check_output",
side_effect=CalledPro... | "example@email.com" | assert | string_literal | tests/unit/utils/test_shell.py | test_should_return_defaults_when_subprocess_error | TestGetGitUserInfo | 59 | null |
fastapi-mvc/fastapi-mvc | import copy
from unittest import mock
import pytest
from copier.errors import UserMessageError
from fastapi_mvc.cli.update import update
from fastapi_mvc.constants import ANSWERS_FILE, COPIER_PROJECT
class TestCliUpdateCommand:
def patched_update(self):
cmd = copy.deepcopy(update)
copier_patch = ... | 0 | assert | numeric_literal | tests/unit/cli/test_update.py | test_should_exit_zero_when_invoked_with_help | TestCliUpdateCommand | 29 | null |
fastapi-mvc/fastapi-mvc | import copy
from unittest import mock
from datetime import datetime
import pytest
from fastapi_mvc.generators import GeneratorGenerator
from fastapi_mvc.constants import COPIER_GENERATOR
class TestGeneratorGenerator:
def generator(self):
generator = copy.deepcopy(GeneratorGenerator)
copier_patch ... | 1 | assert | numeric_literal | tests/unit/generators/test_generator.py | test_should_exit_error_when_not_in_fastapi_mvc_project | TestGeneratorGenerator | 97 | null |
fastapi-mvc/fastapi-mvc | import logging
from fastapi_mvc.utils import global_except_hook
class TestGlobalExceptHook:
def test_should_format_issue_template(self, caplog):
# given
caplog.set_level(logging.DEBUG)
ex = Exception("Oh no! Something went wrong :(")
# when
global_except_hook(type(ex), ex... | caplog.records[1].message | assert | complex_expr | tests/unit/utils/test_excepthook.py | test_should_format_issue_template | TestGlobalExceptHook | 20 | null |
fastapi-mvc/fastapi-mvc | from unittest import mock
from fastapi_mvc.generators import load_generators
class TestLoadGenerators:
def test_should_load_custom_generators_from_default_path(self, monkeypatch, fake_project_with_generators):
# given
monkeypatch.chdir(fake_project_with_generators["root"])
# when
... | sorted( ["controller", "foobar", "generator", "my-controller", "script"] ) | assert | func_call | tests/unit/generators/test_loader.py | test_should_load_custom_generators_from_default_path | TestLoadGenerators | 16 | null |
fastapi-mvc/fastapi-mvc | import os
from copier.user_data import load_answersfile_data
from tests.integration.conftest import assert_paths
from fastapi_mvc.constants import ANSWERS_FILE
class TestCliNewCommand:
def test_should_generate_using_overriden_template(self, new_copy, cli_runner):
with cli_runner.isolated_filesystem() as ... | "82234c2" | assert | string_literal | tests/integration/cli/test_new.py | test_should_generate_using_overriden_template | TestCliNewCommand | 123 | null |
fastapi-mvc/fastapi-mvc | import copy
from unittest import mock
import pytest
from copier.errors import UserMessageError
from fastapi_mvc.cli.update import update
from fastapi_mvc.constants import ANSWERS_FILE, COPIER_PROJECT
class TestCliUpdateCommand:
def patched_update(self):
cmd = copy.deepcopy(update)
copier_patch = ... | result.output | assert | complex_expr | tests/unit/cli/test_update.py | test_should_exit_error_on_copier_error | TestCliUpdateCommand | 135 | null |
fastapi-mvc/fastapi-mvc | import copy
from unittest import mock
import pytest
from copier.errors import UserMessageError
from fastapi_mvc.cli.update import update
from fastapi_mvc.constants import ANSWERS_FILE, COPIER_PROJECT
class TestCliUpdateCommand:
def patched_update(self):
cmd = copy.deepcopy(update)
copier_patch = ... | 1 | assert | numeric_literal | tests/unit/cli/test_update.py | test_should_exit_error_when_not_in_fastapi_mvc_project | TestCliUpdateCommand | 123 | null |
fastapi-mvc/fastapi-mvc | import os
from fastapi_mvc.generators import GeneratorGenerator
from tests.integration.conftest import assert_paths
class TestGeneratorGeneratorCli:
def test_should_generate_generator_with_minimal_structure(self, cli_runner, default_project, monkeypatch):
# given
monkeypatch.chdir(default_project... | [ "lib/generators/minimal/flake.nix", "lib/generators/minimal/flake.lock", "lib/generators/minimal/.github/dependabot.yml", "lib/generators/minimal/.github/workflows/update-flake.yml" ]) | assert_* | collection | tests/integration/generators/test_generator.py | test_should_generate_generator_with_minimal_structure | TestGeneratorGeneratorCli | 43 | null |
fastapi-mvc/fastapi-mvc | import os
from fastapi_mvc.generators import GeneratorGenerator
from tests.integration.conftest import assert_paths
class TestGeneratorGeneratorCli:
def test_should_generate_generator_with_default_structure(self, cli_runner, default_project, monkeypatch):
# given
monkeypatch.chdir(default_project... | 0 | assert | numeric_literal | tests/integration/generators/test_generator.py | test_should_generate_generator_with_default_structure | TestGeneratorGeneratorCli | 15 | null |
fastapi-mvc/fastapi-mvc | import copy
from unittest import mock
from datetime import datetime
import pytest
from fastapi_mvc.generators import GeneratorGenerator
from fastapi_mvc.constants import COPIER_GENERATOR
class TestGeneratorGenerator:
def generator(self):
generator = copy.deepcopy(GeneratorGenerator)
copier_patch ... | caplog.text | assert | complex_expr | tests/unit/generators/test_generator.py | test_should_exit_error_when_not_in_fastapi_mvc_project | TestGeneratorGenerator | 99 | null |
fastapi-mvc/fastapi-mvc | import copy
from unittest import mock
import pytest
from copier.errors import UserMessageError
from fastapi_mvc.cli.update import update
from fastapi_mvc.constants import ANSWERS_FILE, COPIER_PROJECT
class TestCliUpdateCommand:
def patched_update(self):
cmd = copy.deepcopy(update)
copier_patch = ... | 2 | assert | numeric_literal | tests/unit/cli/test_update.py | test_should_exit_error_when_invoked_with_invalid_option | TestCliUpdateCommand | 36 | null |
fastapi-mvc/fastapi-mvc | import os
import subprocess
from subprocess import CalledProcessError
from unittest import mock
import pytest
from fastapi_mvc.utils import get_git_user_info, run_shell, get_poetry_path
class TestGetGitUserInfo:
@mock.patch(
"fastapi_mvc.utils.shell.shutil.which",
return_value=False,
)
@m... | "git") | assert_* | string_literal | tests/unit/utils/test_shell.py | test_should_return_defaults_when_no_git_present | TestGetGitUserInfo | 79 | null |
fastapi-mvc/fastapi-mvc | import os
import copy
import pytest
from click.testing import CliRunner
from fastapi_mvc.cli.new import new
from fastapi_mvc.cli.update import update
COPIER_PROJECT_RELEASES = {
"0.1.0",
"0.1.1",
"0.2.0",
"0.3.0",
"0.4.0",
"0.5.0",
"0.6.0",
"0.6.1",
}
def assert_paths(paths, condition... | 0 | assert | numeric_literal | tests/integration/conftest.py | default_project | 61 | null | |
fastapi-mvc/fastapi-mvc | import copy
from unittest import mock
import pytest
from fastapi_mvc.generators import ControllerGenerator
from fastapi_mvc.constants import COPIER_CONTROLLER
from fastapi_mvc.generators.controller import insert_router_import
router_content = """\
from fastapi import APIRouter
from fake_project.app.controllers import... | "fake_controller") | assert_* | string_literal | tests/unit/generators/test_controller.py | test_should_call_copier_using_default_values | TestControllerGenerator | 140 | null |
fastapi-mvc/fastapi-mvc | import copy
from unittest import mock
from subprocess import CalledProcessError
import pytest
from fastapi_mvc.cli.run import run
class TestCliRunCommand:
def patched_run(self):
cmd = copy.deepcopy(run)
with mock.patch("fastapi_mvc.cli.run.run_shell") as mck:
cmd.run_shell = mck
... | 1 | assert | numeric_literal | tests/unit/cli/test_run.py | test_should_exit_error_when_not_in_fastapi_mvc_project | TestCliRunCommand | 106 | null |
fastapi-mvc/fastapi-mvc | import pytest
from fastapi_mvc.utils import ensure_permissions, require_fastapi_mvc_project, load_answers_file
from fastapi_mvc.constants import ANSWERS_FILE
class TestLoadAnswersFile:
def test_should_return_loaded_answers_file_using_defaults(self, fake_project, monkeypatch):
# given
monkeypatch.... | "fake-project" | assert | string_literal | tests/unit/utils/test_generators.py | test_should_return_loaded_answers_file_using_defaults | TestLoadAnswersFile | 17 | null |
fastapi-mvc/fastapi-mvc | import os
from copier.user_data import load_answersfile_data
from tests.integration.conftest import assert_paths
from fastapi_mvc.constants import ANSWERS_FILE
class TestCliNewCommand:
def test_should_generate_using_overriden_template(self, new_copy, cli_runner):
with cli_runner.isolated_filesystem() as ... | "https://github.com/rszamszur/copier-project" | assert | string_literal | tests/integration/cli/test_new.py | test_should_generate_using_overriden_template | TestCliNewCommand | 124 | null |
fastapi-mvc/fastapi-mvc | import os
import subprocess
from subprocess import CalledProcessError
from unittest import mock
import pytest
from fastapi_mvc.utils import get_git_user_info, run_shell, get_poetry_path
class TestRunShell:
def test_should_raise_when_subprocess_failed_and_check_is_true(self):
# given
check = True
... | subprocess.CalledProcessError) | pytest.raises | complex_expr | tests/unit/utils/test_shell.py | test_should_raise_when_subprocess_failed_and_check_is_true | TestRunShell | 115 | null |
fastapi-mvc/fastapi-mvc | import os
from tests.integration.conftest import assert_paths
from fastapi_mvc.generators import ControllerGenerator
class TestControllerGeneratorCli:
def test_should_generate_controller_using_given_arguments(self, cli_runner, default_project, monkeypatch):
# given / when
monkeypatch.chdir(defaul... | [ f"{default_project}/default_project/app/controllers/stock_market.py", f"{default_project}/tests/unit/app/controllers/test_stock_market.py", ]) | assert_* | collection | tests/integration/generators/test_controller.py | test_should_generate_controller_using_given_arguments | TestControllerGeneratorCli | 19 | null |
fastapi-mvc/fastapi-mvc | import copy
from unittest import mock
import pytest
from fastapi_mvc.generators import ControllerGenerator
from fastapi_mvc.constants import COPIER_CONTROLLER
from fastapi_mvc.generators.controller import insert_router_import
router_content = """\
from fastapi import APIRouter
from fake_project.app.controllers import... | 2 | assert | numeric_literal | tests/unit/generators/test_controller.py | test_should_exit_error_when_invoked_with_invalid_option | TestControllerGenerator | 121 | null |
fastapi-mvc/fastapi-mvc | import os
import subprocess
from subprocess import CalledProcessError
from unittest import mock
import pytest
from fastapi_mvc.utils import get_git_user_info, run_shell, get_poetry_path
class TestRunShell:
def test_should_call_and_populate_defaults(self):
# given
cmd = ["/usr/bin/env", "true"]
... | 0 | assert | numeric_literal | tests/unit/utils/test_shell.py | test_should_call_and_populate_defaults | TestRunShell | 93 | null |
fastapi-mvc/fastapi-mvc | import copy
from unittest import mock
import pytest
from fastapi_mvc.generators import ControllerGenerator
from fastapi_mvc.constants import COPIER_CONTROLLER
from fastapi_mvc.generators.controller import insert_router_import
router_content = """\
from fastapi import APIRouter
from fake_project.app.controllers import... | 1 | assert | numeric_literal | tests/unit/generators/test_controller.py | test_should_exit_error_when_not_in_fastapi_mvc_project | TestControllerGenerator | 200 | null |
fastapi-mvc/fastapi-mvc | import os
import copy
from datetime import datetime
from unittest import mock
import pytest
from fastapi_mvc.constants import VERSION
from fastapi_mvc.cli.new import new
from fastapi_mvc.constants import ANSWERS_FILE, COPIER_PROJECT
DIR = os.getcwd()
class TestCliNewCommand:
def patched_new(self):
cmd =... | 0 | assert | numeric_literal | tests/unit/cli/test_new.py | test_should_exit_zero_when_invoked_with_help | TestCliNewCommand | 43 | null |
fastapi-mvc/fastapi-mvc | import logging
from fastapi_mvc.utils import global_except_hook
class TestGlobalExceptHook:
def test_should_format_issue_template(self, caplog):
# given
caplog.set_level(logging.DEBUG)
ex = Exception("Oh no! Something went wrong :(")
# when
global_except_hook(type(ex), ex... | "Unhandled exception occurred during RunTime." | assert | string_literal | tests/unit/utils/test_excepthook.py | test_should_format_issue_template | TestGlobalExceptHook | 18 | null |
fastapi-mvc/fastapi-mvc | import os
import subprocess
from subprocess import CalledProcessError
from unittest import mock
import pytest
from fastapi_mvc.utils import get_git_user_info, run_shell, get_poetry_path
class TestGetGitUserInfo:
@mock.patch(
"fastapi_mvc.utils.shell.subprocess.check_output",
side_effect=[
... | "Darth Vader" | assert | string_literal | tests/unit/utils/test_shell.py | test_should_return_git_username_and_email | TestGetGitUserInfo | 40 | null |
fastapi-mvc/fastapi-mvc | import pytest
from fastapi_mvc.utils import run_shell
def dirhash(path):
"""Calculate directory sha256sum using bash magic.
The bellow code will execute the following shell command:
``find . -type f ! -path "./.git/*" -print0 | xargs -0 sha256sum | sort | sha256sum``
"""
# First, find all the fil... | 0 | assert | numeric_literal | tests/integration/cli/test_update.py | test_should_update_outdated_project_to_given_version | TestCliUpdateCommand | 73 | null |
fastapi-mvc/fastapi-mvc | import copy
from unittest import mock
from subprocess import CalledProcessError
import pytest
from fastapi_mvc.cli.run import run
class TestCliRunCommand:
def patched_run(self):
cmd = copy.deepcopy(run)
with mock.patch("fastapi_mvc.cli.run.run_shell") as mck:
cmd.run_shell = mck
... | 2 | assert | numeric_literal | tests/unit/cli/test_run.py | test_should_exit_error_when_invoked_with_invalid_option | TestCliRunCommand | 31 | null |
fastapi-mvc/fastapi-mvc | import copy
from unittest import mock
import pytest
from fastapi_mvc.generators import ControllerGenerator
from fastapi_mvc.constants import COPIER_CONTROLLER
from fastapi_mvc.generators.controller import insert_router_import
router_content = """\
from fastapi import APIRouter
from fake_project.app.controllers import... | caplog.text | assert | complex_expr | tests/unit/generators/test_controller.py | test_should_exit_error_when_not_in_fastapi_mvc_project | TestControllerGenerator | 202 | null |
fastapi-mvc/fastapi-mvc | import os
from copier.user_data import load_answersfile_data
from tests.integration.conftest import assert_paths
from fastapi_mvc.constants import ANSWERS_FILE
class TestCliNewCommand:
def test_should_generate_new_project_with_default_structure(self, new_copy, cli_runner):
with cli_runner.isolated_filesy... | 0 | assert | numeric_literal | tests/integration/cli/test_new.py | test_should_generate_new_project_with_default_structure | TestCliNewCommand | 18 | null |
fastapi-mvc/fastapi-mvc | import logging
from fastapi_mvc.utils import global_except_hook
class TestGlobalExceptHook:
def test_should_format_issue_template(self, caplog):
# given
caplog.set_level(logging.DEBUG)
ex = Exception("Oh no! Something went wrong :(")
# when
global_except_hook(type(ex), ex... | 2 | assert | numeric_literal | tests/unit/utils/test_excepthook.py | test_should_format_issue_template | TestGlobalExceptHook | 17 | null |
fastapi-mvc/fastapi-mvc | import copy
from unittest import mock
from datetime import datetime
import pytest
from fastapi_mvc.generators import GeneratorGenerator
from fastapi_mvc.constants import COPIER_GENERATOR
class TestGeneratorGenerator:
def generator(self):
generator = copy.deepcopy(GeneratorGenerator)
copier_patch ... | 0 | assert | numeric_literal | tests/unit/generators/test_generator.py | test_should_exit_zero_when_invoked_with_help | TestGeneratorGenerator | 28 | null |
fastapi-mvc/fastapi-mvc | import os
from fastapi_mvc.cli.generate import get_generate_cmd
class TestCliGenerateCommand:
def test_should_generate_from_custom_generator(self, cli_runner, monkeypatch, default_project):
# given
monkeypatch.chdir(default_project)
# when
result = cli_runner.invoke(get_generate_... | 0 | assert | numeric_literal | tests/integration/cli/test_generate.py | test_should_generate_from_custom_generator | TestCliGenerateCommand | 17 | null |
fastapi-mvc/fastapi-mvc | import os
import subprocess
from subprocess import CalledProcessError
from unittest import mock
import pytest
from fastapi_mvc.utils import get_git_user_info, run_shell, get_poetry_path
class TestRunShell:
@pytest.mark.parametrize("env, expected", [
(
{
"SHELL": "/bin/bash",
... | ["make", "install"]) | assert_* | collection | tests/unit/utils/test_shell.py | test_should_remove_venv_from_path_if_activated | TestRunShell | 181 | null |
fastapi-mvc/fastapi-mvc | import copy
from unittest import mock
import pytest
from fastapi_mvc.generators import ScriptGenerator
from fastapi_mvc.constants import COPIER_SCRIPT
class TestScriptGenerator:
def script(self):
script = copy.deepcopy(ScriptGenerator)
copier_patch = mock.patch(
"fastapi_mvc.generator... | 2 | assert | numeric_literal | tests/unit/generators/test_script.py | test_should_exit_error_when_invoked_with_invalid_option | TestScriptGenerator | 34 | null |
fastapi-mvc/fastapi-mvc | import os
import subprocess
from subprocess import CalledProcessError
from unittest import mock
import pytest
from fastapi_mvc.utils import get_git_user_info, run_shell, get_poetry_path
class TestGetPoetryPath:
@pytest.mark.parametrize("variable, value, expected", [
("HOME", "/home/foobar", "/home/foobar... | expected | assert | variable | tests/unit/utils/test_shell.py | test_should_return_poetry_path_from_env | TestGetPoetryPath | 23 | null |
fastapi-mvc/fastapi-mvc | import copy
from unittest import mock
from datetime import datetime
import pytest
from fastapi_mvc.generators import GeneratorGenerator
from fastapi_mvc.constants import COPIER_GENERATOR
class TestGeneratorGenerator:
def generator(self):
generator = copy.deepcopy(GeneratorGenerator)
copier_patch ... | 2 | assert | numeric_literal | tests/unit/generators/test_generator.py | test_should_exit_error_when_invoked_with_invalid_option | TestGeneratorGenerator | 35 | null |
fastapi-mvc/fastapi-mvc | import os
import subprocess
from subprocess import CalledProcessError
from unittest import mock
import pytest
from fastapi_mvc.utils import get_git_user_info, run_shell, get_poetry_path
class TestGetGitUserInfo:
@mock.patch(
"fastapi_mvc.utils.shell.subprocess.check_output",
side_effect=[
... | [ mock.call(["git", "config", "--get", "user.name"]), mock.call(["git", "config", "--get", "user.email"]), ]) | assert_* | collection | tests/unit/utils/test_shell.py | test_should_return_git_username_and_email | TestGetGitUserInfo | 42 | null |
fastapi-mvc/fastapi-mvc | import copy
from unittest import mock
import pytest
from fastapi_mvc.generators import ControllerGenerator
from fastapi_mvc.constants import COPIER_CONTROLLER
from fastapi_mvc.generators.controller import insert_router_import
router_content = """\
from fastapi import APIRouter
from fake_project.app.controllers import... | router_expected | assert | variable | tests/unit/generators/test_controller.py | test_should_insert_router_import | TestGeneratorInsertRouterPath | 78 | null |
fastapi-mvc/fastapi-mvc | import os
import copy
from datetime import datetime
from unittest import mock
import pytest
from fastapi_mvc.constants import VERSION
from fastapi_mvc.cli.new import new
from fastapi_mvc.constants import ANSWERS_FILE, COPIER_PROJECT
DIR = os.getcwd()
class TestCliNewCommand:
def patched_new(self):
cmd =... | "make") | assert_* | string_literal | tests/unit/cli/test_new.py | test_should_exit_zero_and_call_copier_with_defaults | TestCliNewCommand | 64 | null |
fastapi-mvc/fastapi-mvc | import os
import pytest
from tests.integration.conftest import assert_paths
from fastapi_mvc.generators import ScriptGenerator
class TestScriptGeneratorCli:
@pytest.mark.parametrize("args", [
["my-script.sh"],
["--use-nix", "my-script.sh"]
])
def test_should_generate_script_using_given_ar... | 0 | assert | numeric_literal | tests/integration/generators/test_script.py | test_should_generate_script_using_given_arguments | TestScriptGeneratorCli | 20 | null |
fastapi-mvc/fastapi-mvc | import os
import subprocess
from subprocess import CalledProcessError
from unittest import mock
import pytest
from fastapi_mvc.utils import get_git_user_info, run_shell, get_poetry_path
class TestGetGitUserInfo:
@mock.patch(
"fastapi_mvc.utils.shell.subprocess.check_output",
side_effect=CalledPro... | "John Doe" | assert | string_literal | tests/unit/utils/test_shell.py | test_should_return_defaults_when_subprocess_error | TestGetGitUserInfo | 58 | null |
fastapi-mvc/fastapi-mvc | import pytest
from fastapi_mvc.utils import run_shell
def dirhash(path):
"""Calculate directory sha256sum using bash magic.
The bellow code will execute the following shell command:
``find . -type f ! -path "./.git/*" -print0 | xargs -0 sha256sum | sort | sha256sum``
"""
# First, find all the fil... | 2 | assert | numeric_literal | tests/integration/cli/test_update.py | test_should_not_update_when_git_dirty | TestCliUpdateCommand | 109 | null |
fastapi-mvc/fastapi-mvc | import copy
import pytest
from fastapi_mvc.cli.cli import cli
class TestCliRoot:
def test_should_exit_error_when_invoked_empty(self, cli_runner):
# given / when
result = cli_runner.invoke(cli)
# then
assert result.exit_code == | 2 | assert | numeric_literal | tests/unit/cli/test_cli.py | test_should_exit_error_when_invoked_empty | TestCliRoot | 14 | null |
fastapi-mvc/fastapi-mvc | import pytest
from fastapi_mvc.cli.generate import get_generate_cmd
class TestCliGenerateCommand:
def test_should_exit_error_when_invoked_with_invalid_option(self, cli_runner):
# given / when
result = cli_runner.invoke(get_generate_cmd(), ["--not_exists"])
# then
assert result.ex... | 2 | assert | numeric_literal | tests/unit/cli/test_generate.py | test_should_exit_error_when_invoked_with_invalid_option | TestCliGenerateCommand | 20 | null |
fastapi-mvc/fastapi-mvc | import os
import subprocess
from subprocess import CalledProcessError
from unittest import mock
import pytest
from fastapi_mvc.utils import get_git_user_info, run_shell, get_poetry_path
class TestGetGitUserInfo:
@mock.patch(
"fastapi_mvc.utils.shell.subprocess.check_output",
side_effect=[
... | "join@galactic.empire" | assert | string_literal | tests/unit/utils/test_shell.py | test_should_return_git_username_and_email | TestGetGitUserInfo | 41 | null |
fastapi-mvc/fastapi-mvc | from unittest import mock
from fastapi_mvc.generators import load_generators
class TestLoadGenerators:
@mock.patch("fastapi_mvc.generators.loader.spec_from_file_location")
def test_should_continue_on_import_error(self, importlib_mock, monkeypatch, fake_project_with_generators):
# given
monkey... | sorted( ["controller", "generator", "script"] ) | assert | func_call | tests/unit/generators/test_loader.py | test_should_continue_on_import_error | TestLoadGenerators | 32 | null |
fastapi-mvc/fastapi-mvc | import copy
from unittest import mock
from subprocess import CalledProcessError
import pytest
from fastapi_mvc.cli.run import run
class TestCliRunCommand:
def patched_run(self):
cmd = copy.deepcopy(run)
with mock.patch("fastapi_mvc.cli.run.run_shell") as mck:
cmd.run_shell = mck
... | result.output | assert | complex_expr | tests/unit/cli/test_run.py | test_should_exit_error_on_subprocess_error | TestCliRunCommand | 118 | null |
fastapi-mvc/fastapi-mvc | import copy
from unittest import mock
import pytest
from fastapi_mvc.generators import ControllerGenerator
from fastapi_mvc.constants import COPIER_CONTROLLER
from fastapi_mvc.generators.controller import insert_router_import
router_content = """\
from fastapi import APIRouter
from fake_project.app.controllers import... | 0 | assert | numeric_literal | tests/unit/generators/test_controller.py | test_should_exit_zero_when_invoked_with_help | TestControllerGenerator | 114 | 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_trigger_infinite_loop(self):
self.assertTrue( | adam.adam_2.trigger_infinite_loop()) | self.assertTrue | func_call | tests/resources/example_project/tests/test_adam.py | test_trigger_infinite_loop | Tests | 62 | null |
sixty-north/cosmic-ray | from cosmic_ray.mutating import mutate_code
from cosmic_ray.operators.binary_operator_replacement import (
ReplaceBinaryOperator_Add_Mul,
ReplaceBinaryOperator_BitOr_Add,
ReplaceBinaryOperator_Mul_Add,
ReplaceBinaryOperator_Sub_Add,
)
def test_pipe_operator_in_assignment_annotation_not_mutated_as_binar... | None | assert | none_literal | tests/unittests/operators/test_binary_operator_replacement.py | test_pipe_operator_in_assignment_annotation_not_mutated_as_binary_operator | 13 | 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():
data = FakeWorkDB()
exclude = ["Op1", "Op2", "Opregex[12]", r"(?:.[oO]m(?:p|P)lex).*"]
operators_filter.Operato... | data.expected_after_filter | assert | complex_expr | tests/tools/test_filter_operators.py | test_operators_filter | 97 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.