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
NewFuture/DDNS
from base_test import BaseProviderTestCase, unittest, patch, MagicMock from ddns.provider.edgeone_dns import EdgeOneDnsProvider class TestEdgeOneDnsProvider(BaseProviderTestCase): def setUp(self): """Set up test fixtures""" super(TestEdgeOneDnsProvider, self).setUp() self.provider = EdgeOn...
3)
self.assertEqual
numeric_literal
tests/test_provider_edgeone_dns.py
test_set_record_create_new
TestEdgeOneDnsProvider
270
null
NewFuture/DDNS
from base_test import unittest, BaseProviderTestCase from ddns.provider.aliesa import AliesaProvider class TestAliesaProvider(BaseProviderTestCase): def setUp(self): """Setup test provider with mock credentials""" super(TestAliesaProvider, self).setUp() self.provider = AliesaProvider(id="t...
record)
self.assertIsNotNone
variable
tests/test_provider_aliesa.py
test_record_query_logic
TestAliesaProvider
109
null
NewFuture/DDNS
from base_test import BaseProviderTestCase, unittest, MagicMock from ddns.provider._base import SimpleProvider, TYPE_FORM, encode_params class _TestableSimpleProviderClass(BaseProviderTestCase): def setUp(self): """Set up test fixtures""" super(_TestableSimpleProviderClass, self).setUp() def ...
str)
self.assertIsInstance
variable
tests/test_provider_base_simple.py
test_mask_sensitive_data_url_encoded
_TestableSimpleProviderClass
178
null
NewFuture/DDNS
from __init__ import unittest, patch import sys import io from ddns.config.cli import load_config class TestTaskSubcommand(unittest.TestCase): def setUp(self): encode = sys.stdout.encoding if encode is not None and encode.lower() != "utf-8" and hasattr(sys.stdout, "buffer"): # 兼容window...
"auto")
self.assertEqual
string_literal
tests/test_config_cli_task.py
test_task_subcommand_scheduler_default
TestTaskSubcommand
366
null
NewFuture/DDNS
from __init__ import unittest, patch, MagicMock, call import os import tempfile import shutil import json import sys import ddns.config from ddns.config import load_configs, Config from io import StringIO, BytesIO # For capturing stdout in Python2 and Python3 def capture_stdout_output(func, *args, **kwargs): """...
1)
self.assertEqual
numeric_literal
tests/test_config_init.py
test_load_config_parameter_validation_and_edge_cases
TestConfigInit
315
null
NewFuture/DDNS
import os import platform import subprocess from __init__ import unittest from ddns.scheduler import get_scheduler class TestSchedulerRealFunctionality(unittest.TestCase): def setUp(self): """Set up test environment""" self.current_system = platform.system().lower() self.scheduler = get_...
dict)
self.assertIsInstance
variable
tests/test_scheduler_init.py
test_windows_scheduler_real_calls
TestSchedulerRealFunctionality
163
null
NewFuture/DDNS
from __init__ import unittest, patch import sys import io from ddns.config.cli import load_config class TestTaskSubcommand(unittest.TestCase): def setUp(self): encode = sys.stdout.encoding if encode is not None and encode.lower() != "utf-8" and hasattr(sys.stdout, "buffer"): # 兼容window...
args[0])
self.assertIsNotNone
complex_expr
tests/test_config_cli_task.py
test_task_subcommand_scheduler_excluded_from_ddns_args
TestTaskSubcommand
453
null
NewFuture/DDNS
from __future__ import unicode_literals from __init__ import unittest import tempfile import shutil import os import json import logging import sys from ddns.config import load_configs class TestAllConfigFormatsIntegration(unittest.TestCase): def setUp(self): """Set up test fixtures""" self.temp_d...
3)
self.assertEqual
numeric_literal
tests/test_config_schema_v4_1.py
test_all_config_formats_integration
TestAllConfigFormatsIntegration
75
null
NewFuture/DDNS
import os import platform import sys from __init__ import patch, unittest from ddns.scheduler.launchd import LaunchdScheduler from ddns.util.try_run import try_run class TestLaunchdScheduler(unittest.TestCase): def setUp(self): """Set up test fixtures""" self.scheduler = LaunchdScheduler() ...
bool)
self.assertIsInstance
variable
tests/test_scheduler_launchd.py
test_real_launchd_integration
TestLaunchdScheduler
250
null
NewFuture/DDNS
import os import unittest from ddns.config.env import load_config class TestConfigEnv(unittest.TestCase): def setUp(self): """Set up test environment""" self._clear_env_prefix("DDNS_TEST_") self._clear_env_prefix("DDNS_") self._clear_standard_env() def tearDown(self): ...
{})
self.assertEqual
collection
tests/test_config_env.py
test_no_matching_environment_variables
TestConfigEnv
138
null
NewFuture/DDNS
from __future__ import unicode_literals from __init__ import unittest from ddns.util.comment import remove_comment class TestRemoveComment(unittest.TestCase): def test_remove_comment_empty_string(self): """测试空字符串""" result = remove_comment("") self.assertEqual(result,
"")
self.assertEqual
string_literal
tests/test_util_comment.py
test_remove_comment_empty_string
TestRemoveComment
18
null
NewFuture/DDNS
import os import platform import subprocess from __init__ import unittest from ddns.scheduler import get_scheduler class TestSchedulerRealFunctionality(unittest.TestCase): def setUp(self): """Set up test environment""" self.current_system = platform.system().lower() self.scheduler = get_...
list)
self.assertIsInstance
variable
tests/test_scheduler_init.py
test_windows_scheduler_real_calls
TestSchedulerRealFunctionality
172
null
NewFuture/DDNS
from base_test import BaseProviderTestCase, unittest, patch, MagicMock from ddns.provider.edgeone_dns import EdgeOneDnsProvider class TestEdgeOneDnsProviderIntegration(BaseProviderTestCase): def setUp(self): """Set up test fixtures""" super(TestEdgeOneDnsProviderIntegration, self).setUp() ...
0)
self.assertGreater
numeric_literal
tests/test_provider_edgeone_dns.py
test_api_error_handling
TestEdgeOneDnsProviderIntegration
415
null
NewFuture/DDNS
from base_test import BaseProviderTestCase, unittest, patch, MagicMock from ddns.provider.edgeone import EdgeOneProvider class TestEdgeOneProviderIntegration(BaseProviderTestCase): def setUp(self): """Set up test fixtures""" super(TestEdgeOneProviderIntegration, self).setUp() self.provider...
0)
self.assertGreater
numeric_literal
tests/test_provider_edgeone.py
test_api_error_handling
TestEdgeOneProviderIntegration
466
null
NewFuture/DDNS
from base_test import BaseProviderTestCase, unittest, patch, MagicMock from ddns.provider.tencentcloud import TencentCloudProvider class TestTencentCloudProvider(BaseProviderTestCase): def setUp(self): """Set up test fixtures""" super(TestTencentCloudProvider, self).setUp() self.provider =...
"A")
self.assertEqual
string_literal
tests/test_provider_tencentcloud.py
test_query_record_found
TestTencentCloudProvider
101
null
NewFuture/DDNS
from __init__ import patch, unittest import os import tempfile from time import sleep from ddns.cache import Cache # noqa: E402 class TestCache(unittest.TestCase): def setUp(self): """Set up test fixtures""" # Create a temporary directory for test cache files self.cache_file = tempfile.m...
2)
self.assertEqual
numeric_literal
tests/test_cache.py
test_setitem_and_getitem
TestCache
67
null
NewFuture/DDNS
from base_test import BaseProviderTestCase, unittest, MagicMock from ddns.provider._base import SimpleProvider, TYPE_FORM, encode_params class _TestableSimpleProviderClass(BaseProviderTestCase): def setUp(self): """Set up test fixtures""" super(_TestableSimpleProviderClass, self).setUp() def ...
data)
self.assertEqual
variable
tests/test_provider_base_simple.py
test_mask_sensitive_data_no_token
_TestableSimpleProviderClass
154
null
NewFuture/DDNS
from base_test import BaseProviderTestCase, patch, unittest from ddns.provider.cloudns import CloudnsProvider class TestCloudnsProvider(BaseProviderTestCase): def setUp(self): """Set up test fixtures""" super(TestCloudnsProvider, self).setUp() self.id = "1234" self.token = "test_p...
self.id)
self.assertEqual
complex_expr
tests/test_provider_cloudns.py
test_init
TestCloudnsProvider
31
null
NewFuture/DDNS
from __init__ import unittest from ddns.provider._signature import hmac_sha256_authorization, sha256_hash, hmac_sha256 class TestHmacSha256Authorization(unittest.TestCase): def test_hmac_sha256_basic_functionality(self): """测试 hmac_sha256 基础功能""" key = "test_key" message = "test_message" ...
bytes)
self.assertIsInstance
variable
tests/test_provider__signature.py
test_hmac_sha256_basic_functionality
TestHmacSha256Authorization
308
null
NewFuture/DDNS
from base_test import BaseProviderTestCase, unittest, patch from ddns.provider.dnscom import DnscomProvider class TestDnscomProvider(BaseProviderTestCase): def setUp(self): """Set up test fixtures""" super(TestDnscomProvider, self).setUp() self.id = "test_api_key" self.token = "tes...
"www")
self.assertEqual
string_literal
tests/test_provider_dnscom.py
test_query_record_success
TestDnscomProvider
156
null
NewFuture/DDNS
from __future__ import unicode_literals from __init__ import unittest import tempfile import shutil import os import json import io import sys from ddns.config.file import load_config, save_config FileNotFoundError = globals().get("FileNotFoundError", IOError) PermissionError = globals().get("PermissionError", IOError...
True)
self.assertEqual
bool_literal
tests/test_config_file.py
test_load_config_with_nested_objects_flattening
TestConfigFile
163
null
NewFuture/DDNS
from __init__ import unittest, patch import tempfile import json import os import sys from ddns.config import load_configs from ddns.config.file import load_config as load_file_config, _process_multi_providers class TestMultiConfig(unittest.TestCase): def setUp(self): self.temp_dir = tempfile.mkdtemp() ...
2)
self.assertEqual
numeric_literal
tests/test_config_init_multi.py
test_env_multiple_configs_integration
TestMultiConfig
94
null
NewFuture/DDNS
import sys from __init__ import unittest from ddns.config.cli import load_config # noqa: E402 class TestCliExtraFields(unittest.TestCase): def setUp(self): """Save original sys.argv""" self.original_argv = sys.argv def tearDown(self): """Restore original sys.argv""" sys.argv ...
"100")
self.assertEqual
string_literal
tests/test_config_cli_extra.py
test_cli_extra_numeric_values
TestCliExtraFields
97
null
NewFuture/DDNS
from base_test import BaseProviderTestCase, patch, unittest from ddns.provider.cloudflare import CloudflareProvider class TestCloudflareProvider(BaseProviderTestCase): def setUp(self): """Set up test fixtures""" super(TestCloudflareProvider, self).setUp() self.id = "test@example.com" ...
"")
self.assertEqual
string_literal
tests/test_provider_cloudflare.py
test_init_with_token_only
TestCloudflareProvider
38
null
NewFuture/DDNS
from base_test import BaseProviderTestCase, unittest from ddns.provider._base import BaseProvider, encode_params class TestBaseProvider(BaseProviderTestCase): def setUp(self): """测试初始化""" super(TestBaseProvider, self).setUp() self.provider = _TestProvider() def test_encode_dict(self):...
result)
self.assertIn
variable
tests/test_provider_base.py
test_encode_dict
TestBaseProvider
174
null
NewFuture/DDNS
from base_test import BaseProviderTestCase, unittest, patch from ddns.provider.alidns import AlidnsProvider class TestAlidnsProvider(BaseProviderTestCase): def setUp(self): """Set up test fixtures""" super(TestAlidnsProvider, self).setUp() self.id = "test_access_key_id" self.token ...
"123")
self.assertEqual
string_literal
tests/test_provider_alidns.py
test_query_record_success_single
TestAlidnsProvider
147
null
NewFuture/DDNS
from base_test import BaseProviderTestCase, patch, unittest from ddns.provider.cloudns import CloudnsProvider class TestCloudnsProvider(BaseProviderTestCase): def setUp(self): """Set up test fixtures""" super(TestCloudnsProvider, self).setUp() self.id = "1234" self.token = "test_p...
self.token)
self.assertEqual
complex_expr
tests/test_provider_cloudns.py
test_init
TestCloudnsProvider
32
null
NewFuture/DDNS
import sys from __init__ import unittest from ddns.config.cli import load_config # noqa: E402 class TestCliExtraFields(unittest.TestCase): def setUp(self): """Save original sys.argv""" self.original_argv = sys.argv def tearDown(self): """Restore original sys.argv""" sys.argv ...
"true")
self.assertEqual
string_literal
tests/test_config_cli_extra.py
test_cli_extra_single_field
TestCliExtraFields
28
null
NewFuture/DDNS
from __init__ import unittest, patch import sys import io from ddns.config.cli import load_config class TestTaskSubcommand(unittest.TestCase): def setUp(self): encode = sys.stdout.encoding if encode is not None and encode.lower() != "utf-8" and hasattr(sys.stdout, "buffer"): # 兼容window...
args)
self.assertIsNotNone
variable
tests/test_config_cli_task.py
test_task_subcommand_status
TestTaskSubcommand
78
null
NewFuture/DDNS
from __future__ import unicode_literals from __init__ import unittest, patch import tempfile import shutil import os import json import sys import socket from ddns.config.file import load_config from ddns.util.http import HttpResponse class TestRemoteConfigFile(unittest.TestCase): def setUp(self): """Set ...
list)
self.assertIsInstance
variable
tests/test_config_file_remote.py
test_load_config_remote_v41_providers_format
TestRemoteConfigFile
203
null
NewFuture/DDNS
from __future__ import unicode_literals from __init__ import unittest, sys import json import socket import random from ddns.util.http import HttpResponse, _decode_response_body, quote, USER_AGENT def to_bytes(s, encoding="utf-8"): if isinstance(s, text_type): return s.encode(encoding) return s def t...
dict)
self.assertIsInstance
variable
tests/test_util_http.py
test_basic_get_request_with_json_response
TestSendHttpRequest
292
null
NewFuture/DDNS
from __future__ import unicode_literals from __init__ import unittest import tempfile import shutil import os import json import logging import sys from ddns.config import load_configs class TestAllConfigFormatsIntegration(unittest.TestCase): def setUp(self): """Set up test fixtures""" self.temp_d...
"test")
self.assertEqual
string_literal
tests/test_config_schema_v4_1.py
test_v41_schema_reference
TestAllConfigFormatsIntegration
158
null
NewFuture/DDNS
import os import platform from __init__ import patch, unittest from ddns.scheduler.systemd import SystemdScheduler from ddns.util.try_run import try_run class TestSystemdScheduler(unittest.TestCase): def setUp(self): """Set up test fixtures""" self.scheduler = SystemdScheduler() @patch("ddn...
2)
self.assertEqual
numeric_literal
tests/test_scheduler_systemd.py
test_install_with_sudo_fallback
TestSystemdScheduler
84
null
NewFuture/DDNS
from base_test import BaseProviderTestCase, patch, unittest from ddns.provider.cloudflare import CloudflareProvider class TestCloudflareProvider(BaseProviderTestCase): def setUp(self): """Set up test fixtures""" super(TestCloudflareProvider, self).setUp() self.id = "test@example.com" ...
1)
self.assertEqual
numeric_literal
tests/test_provider_cloudflare.py
test_query_record_with_proxy_found_with_filter
TestCloudflareProvider
300
null
NewFuture/DDNS
from base_test import unittest, BaseProviderTestCase from ddns.provider.aliesa import AliesaProvider class TestAliesaProvider(BaseProviderTestCase): def setUp(self): """Setup test provider with mock credentials""" super(TestAliesaProvider, self).setUp() self.provider = AliesaProvider(id="t...
str)
self.assertIsInstance
variable
tests/test_provider_aliesa.py
test_record_type_validation
TestAliesaProvider
307
null
NewFuture/DDNS
from base_test import BaseProviderTestCase, unittest, patch, MagicMock from ddns.provider.tencentcloud import TencentCloudProvider class TestTencentCloudProvider(BaseProviderTestCase): def setUp(self): """Set up test fixtures""" super(TestTencentCloudProvider, self).setUp() self.provider =...
"/")
self.assertEqual
string_literal
tests/test_provider_tencentcloud.py
test_query_record_found
TestTencentCloudProvider
107
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.compat.constants import PY311 from wemake_python_styleguide.violations.complexity import ( TooManyExceptExceptionsViolation, ) from wemake_python_styleguide.visitors.ast.complexity.counts import ( TryExceptVisitor, ) except_four_exceptions1 = """ try: ... except...
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_counts/test_except_exceptions.py
test_exceptions_modified_count
104
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.complexity import ( TooManyPublicAttributesViolation, ) from wemake_python_styleguide.visitors.ast.complexity.classes import ( ClassComplexityVisitor, ) class_template = """ class Test: def __init__(self): {0} def other(self): {1}...
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_classes/test_public_attrs_count.py
test_correct_attributes
96
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.complexity import ( TooLongCallChainViolation, ) from wemake_python_styleguide.visitors.ast.complexity.calls import ( CallChainsVisitor, ) deep_call_chain = 'foo(a)(b)(c)(d)' call_chain = 'bar(a)(b)' long_call_chain = 'baz(a)(b)(c)' @pytest.mark.parame...
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_call_chains/test_call_chains.py
test_correct_cases
42
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.complexity import ( TooManyMatchCaseViolation, ) from wemake_python_styleguide.visitors.ast.complexity.pm import ( MatchCasesVisitor, ) match_cases1 = """ match x: case _: ... """ match_cases4 = """ match x: case 1: ... case 2: ... case 3...
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_pm/test_max_match_cases.py
test_match_cases_correct_count
88
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.options.defaults import NESTED_CLASSES_WHITELIST from wemake_python_styleguide.violations.best_practices import ( NestedClassViolation, ) from wemake_python_styleguide.visitors.ast.complexity.nested import ( NestedComplexityVisitor, ) nested_class_in_class = """ cla...
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_nested/test_nested_classes.py
test_whitelist_nested_classes
151
null
wemake-services/wemake-python-styleguide
from collections import Counter import pytest from wemake_python_styleguide.compat.constants import PY311 def test_violations_start_zero(all_module_violations): """Ensures that all violations start at zero.""" for index, module in enumerate(all_module_violations.keys()): starting_code = min( ...
index * 100
assert
complex_expr
tests/test_violations/test_codes.py
test_violations_start_zero
49
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.constants import MAGIC_METHODS_BLACKLIST from wemake_python_styleguide.violations.oop import BadMagicMethodViolation from wemake_python_styleguide.visitors.ast.classes.methods import ( WrongMethodVisitor, ) magic_method = """ class Example: def {0}(self): ... """ r...
[])
assert_*
collection
tests/test_visitors/test_ast/test_classes/test_methods/test_magic_methods.py
test_correct_magic_method_used
62
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.complexity import ( TooDeepAccessViolation, ) from wemake_python_styleguide.visitors.ast.complexity.access import ( AccessVisitor, ) subscript_access = 'my_matrix[0][0][0][0]' attribute_access = 'self.attr.inner.wrapper.value' mixed_access = 'self.attr[0]...
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_access/test_access.py
test_correct_access
47
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.compat.constants import PY311 from wemake_python_styleguide.violations.complexity import ( TooLongTryBodyViolation, ) from wemake_python_styleguide.visitors.ast.complexity.counts import ( TryExceptVisitor, ) try_without_except = """ try: {0} finally: ... """...
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_counts/test_try_body_length.py
test_try_body_count_custom_options
203
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.logic.naming import enums from wemake_python_styleguide.violations.naming import ( UpperCaseAttributeViolation, ) from wemake_python_styleguide.visitors.ast.naming.validation import ( WrongNameVisitor, ) static_attribute = """ class Test: {0} = None """ static_...
[])
assert_*
collection
tests/test_visitors/test_ast/test_naming/test_class_attributes.py
test_upper_case_enum_attributes
162
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.constants import MAX_LEN_TUPLE_OUTPUT from wemake_python_styleguide.violations.complexity import ( TooLongOutputTupleViolation, ) from wemake_python_styleguide.visitors.ast.complexity.counts import ( ReturnLikeStatementTupleVisitor, ) RETURN_LIKE_STATEMENTS = ('retu...
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_counts/test_output_length.py
test_output_length_normal
54
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.consistency import ( LocalFolderImportViolation, ) from wemake_python_styleguide.visitors.ast.imports import WrongImportVisitor same_level_relative_import = 'from . import some_thing' same_level_relative_import_sibling = 'from .some_thing import MyClass' pare...
[])
assert_*
collection
tests/test_visitors/test_ast/test_imports/test_relative_imports.py
test_regular_import
61
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.best_practices import ( LoopVariableDefinitionViolation, ) from wemake_python_styleguide.visitors.ast.loops import ( WrongLoopDefinitionVisitor, ) list_comprehension = """ def container(): nodes = [0 for {0} in some] """ generator_expression = """ de...
[])
assert_*
collection
tests/test_visitors/test_ast/test_loops/test_comprehensions/test_variable_definition_comprehensions.py
test_comprehension_without_bad_definitions
101
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.best_practices import FloatKeyViolation from wemake_python_styleguide.visitors.ast.builtins import ( WrongCollectionVisitor, ) dict_template1 = '{{ {0}: 1 }}' dict_template2 = '{{ {0}: {0} }}' dict_template3 = '{{ {0}: 1, **kwargs }}' dict_template4 = '{{ {0}...
[])
assert_*
collection
tests/test_visitors/test_ast/test_builtins/test_collection_hashes/test_float_keys.py
test_dict_with_regular
84
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.complexity import TooManyElifsViolation from wemake_python_styleguide.visitors.ast.complexity.counts import ElifVisitor module_with_one_elif = """ if 1 > 2: ... elif 2 > 3: ... else: ... """ module_with_two_elifs = """ if 1 > 2: ... elif 2 > 3: ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_counts/test_elifs.py
test_elif_correct_count
191
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.complexity import ( CognitiveComplexityViolation, CognitiveModuleComplexityViolation, ) from wemake_python_styleguide.visitors.ast.complexity.function import ( CognitiveComplexityVisitor, ) complex_function = """ def literal_eval(node): if isinsta...
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_function/test_cognitive/test_cognitive_score.py
test_complex_cognitive_default_options
136
null
wemake-services/wemake-python-styleguide
import subprocess import pytest def _popen_in_shell(args: str) -> tuple[subprocess.Popen, str, str]: """Run command in shell.""" # shell=True is needed for subprocess.Popen to # locate the installed wps command. process = subprocess.Popen( # noqa: S602 (insecure shell=True) args, stdo...
0
assert
numeric_literal
tests/test_cli/test_explain.py
test_command
26
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.consistency import ( MeaninglessBooleanOperationViolation, ) from wemake_python_styleguide.visitors.ast.operators import ( UselessOperatorsVisitor, ) @pytest.mark.parametrize( 'expression', [ 'value or True', 'value or False', ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_operators/test_useless_bool.py
test_useful_bool
78
null
wemake-services/wemake-python-styleguide
import subprocess import pytest def _popen_in_shell(args: str) -> tuple[subprocess.Popen, str, str]: """Run command in shell.""" # shell=True is needed for subprocess.Popen to # locate the installed wps command. process = subprocess.Popen( # noqa: S602 (insecure shell=True) args, stdo...
snapshot
assert
variable
tests/test_cli/test_explain.py
test_command
27
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.visitors.ast.complexity.jones import ( JonesComplexityVisitor, JonesScoreViolation, ) module_without_nodes = '' module_with_nodes = """ some_value = 1 + 2 other = some_value if some_value > 2 else some_value * 8 + 34 """ module_with_function = """ def some_function...
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_jones/test_module_complexity.py
test_module_score
53
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.best_practices import ( ListMultiplyViolation, ) from wemake_python_styleguide.visitors.ast.operators import ( WrongMathOperatorVisitor, ) usage_template = 'constant = {0}' @pytest.mark.parametrize( 'expression', [ '1 * 2', '() * ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_operators/test_list_multiply.py
test_correct_list_operation
60
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.refactoring import ( DuplicateIfConditionViolation, NegatedConditionsViolation, ) from wemake_python_styleguide.visitors.ast.conditions import IfStatementVisitor if_simple = """ if {0}: ... """ if_and_else = """ if {0}: ... else: ... """ if_...
code)
assert_*
variable
tests/test_visitors/test_ast/test_conditions/test_duplicated_if_conditions.py
test_same_conditions
170
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.cli.commands.explain import ( violation_loader, ) from wemake_python_styleguide.violations.best_practices import ( InitModuleHasLogicViolation, ) from wemake_python_styleguide.violations.naming import ( UpperCaseAttributeViolation, ) from wemake_python_styleguide...
expected_class.__doc__
assert
complex_expr
tests/test_cli/test_explain_internals.py
test_violation_getter
30
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.compat.constants import PY311 from wemake_python_styleguide.visitors.ast.complexity.offset import ( OffsetVisitor, TooDeepNestingViolation, ) nested_if = """ def container(): if True: ... # this needs to be an ellipsis for the test """ nested_if2 = """...
10 * 2)
assert_*
complex_expr
tests/test_visitors/test_ast/test_complexity/test_offset_visitor.py
test_real_nesting_config
242
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.compat.constants import PY312 from wemake_python_styleguide.violations.complexity import ( LineComplexityViolation, ) from wemake_python_styleguide.visitors.ast.complexity.jones import ( JonesComplexityVisitor, ) line_simple = 'x = 2' line_with_types = 'x: int = 2' ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_jones/test_line_complexity.py
test_regular_nodes
104
null
wemake-services/wemake-python-styleguide
import os import subprocess from pathlib import Path import pytest from wemake_python_styleguide.formatter import WemakeFormatter from wemake_python_styleguide.version import pkg_version def _safe_output(output: str) -> str: """ Removes version specific things from console output. So our formatter will ...
snapshot
assert
variable
tests/test_formatter/test_formatter_output.py
test_formatter
96
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.visitors.ast.conditions import IfStatementVisitor code_that_breaks = """ def is_prime(number: int): for i in range(2, number): if number % i == 0: return False else: if number != 1: return True return False """ code_that_...
[])
assert_*
collection
tests/test_visitors/test_ast/test_loops/test_loops/test_for_else.py
test_regression_for_else
61
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.refactoring import ( UselessLoopElseViolation, ) from wemake_python_styleguide.visitors.ast.loops import WrongLoopVisitor wrong_else_in_for_loop = """ def wrapper(): for x in '123': ... else: ... """ wrong_nested_else_in_for_loop = ""...
[])
assert_*
collection
tests/test_visitors/test_ast/test_loops/test_loops/test_loop_with_else.py
test_correct_else_in_for_loop
181
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.naming import ( TooShortNameViolation, TrailingUnderscoreViolation, ) from wemake_python_styleguide.visitors.ast.naming.validation import ( WrongNameVisitor, ) patterns = ( 'y', '_x', 'z_', ) @pytest.mark.parametrize('short_name', pattern...
[])
assert_*
collection
tests/test_visitors/test_ast/test_naming/test_naming_rules/test_short.py
test_short_foreign_name
66
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.naming import ( UnusedVariableIsUsedViolation, ) from wemake_python_styleguide.visitors.ast.naming.validation import ( WrongNameVisitor, ) from wemake_python_styleguide.visitors.ast.naming.variables import ( UnusedVariableUsageVisitor, ) annotation = ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_naming/test_unused/test_variable_usages.py
test_correct_variable_usage
124
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.consistency import ( UppercaseStringModifierViolation, ) from wemake_python_styleguide.visitors.tokenize.primitives import ( WrongStringTokenVisitor, ) @pytest.mark.parametrize( 'modifier', [ 'R', 'B', 'F', ], ) @pytest...
modifier)
assert_*
variable
tests/test_visitors/test_tokenize/test_primitives/test_string_tokens/test_string_modifier.py
test_uppercase_prefix
91
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.complexity import ( TooManyRaisesViolation, ) from wemake_python_styleguide.visitors.ast.complexity.function import ( FunctionComplexityVisitor, ) module_many_raises = """ if some: raise SomeException raise SomeOtherException """ lambda_many_raises =...
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_function/test_raises.py
test_asserts_correct_count1
74
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.complexity import ( TooComplexAnnotationViolation, ) from wemake_python_styleguide.visitors.ast.complexity.annotations import ( AnnotationComplexityVisitor, ) annassign_template = 'some: {0}' function_arg_template = """ def some(arg: {0}): ... """ f...
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_annotation_complexity/test_annotation_complexity_nesting.py
test_correct_annotations
92
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.consistency import ( InconsistentReturnViolation, ) from wemake_python_styleguide.visitors.ast.keywords import ( ConsistentReturningVisitor, ) correct_example1 = """ def function(): ... """ correct_example2 = """ def function(): return 'value' ""...
[])
assert_*
collection
tests/test_visitors/test_ast/test_keywords/test_consistency_returning/test_consistency_return.py
test_correct_return_statements
250
null
wemake-services/wemake-python-styleguide
from collections import Counter import pytest from wemake_python_styleguide.compat.constants import PY311 def test_all_unique_violation_codes(all_violations): """Ensures that all violations have unique violation codes.""" codes = [int(violation.code) for violation in all_violations] assert len(set(codes...
len(all_violations)
assert
func_call
tests/test_violations/test_codes.py
test_all_unique_violation_codes
11
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.best_practices import ( LeakingForLoopViolation, ) from wemake_python_styleguide.visitors.ast.conditions import ( LeakingForLoopVisitor, ) module_scope_code = """ for index in range(10): ... """ class_body_code = """ class ClassWithBody: for inde...
[])
assert_*
collection
tests/test_visitors/test_ast/test_conditions/test_leaking_for_loops.py
test_for_loop_with_del_no_violation
175
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.best_practices import ( HeterogeneousCompareViolation, ) from wemake_python_styleguide.visitors.ast.compares import CompareSanityVisitor @pytest.mark.parametrize( 'code', [ 'x == y == z', 'z != y != x', 'call() == other.prop', ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_compares/test_heterogenous_compare.py
test_correct_compare_operators
67
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.complexity import ( TooManyModuleMembersViolation, ) from wemake_python_styleguide.visitors.ast.complexity.counts import ( ModuleMembersVisitor, ) module_with_function_and_class = """ def first(): ... class Second: ... """ module_with_function_and_class...
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_counts/test_module_counts.py
test_module_counts_normal
148
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.compat.constants import PY311 from wemake_python_styleguide.violations.complexity import ( TooLongFinallyBodyViolation, ) from wemake_python_styleguide.visitors.ast.complexity.counts import ( TryExceptVisitor, ) try_finally_without_except = """ try: ... finally:...
'3')
assert_*
string_literal
tests/test_visitors/test_ast/test_complexity/test_counts/test_finally_body_length.py
test_finally_body_wrong_custom_options
126
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.consistency import ( WrongMethodOrderViolation, ) from wemake_python_styleguide.visitors.ast.classes.methods import ( ClassMethodOrderVisitor, ) correct_method_order = """ class Test: def __init_subclass__(cls): ... def __new__(self): ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_classes/test_method_order.py
test_correct_method_order
87
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.refactoring import ( DuplicateCasePatternViolation, ) from wemake_python_styleguide.visitors.ast.conditions import MatchVisitor match_single = """ match some_value: case {0}: ... """ match_after_match = """ match some_value: case {0}: ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_conditions/test_duplicated_case_patterns.py
test_always_correct_conditions
91
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.oop import ( MethodWithoutArgumentsViolation, StaticMethodViolation, ) from wemake_python_styleguide.visitors.ast.classes.methods import ( WrongMethodVisitor, ) method_inside_class = """ class Example: def some_name({0}): ... """ staticmethod_ins...
[])
assert_*
collection
tests/test_visitors/test_ast/test_classes/test_methods/test_method_without_arguments.py
test_function_without_arguments
54
null
wemake-services/wemake-python-styleguide
import io import tokenize import hypothesmith import pytest from hypothesis import HealthCheck, given, reject, settings from wemake_python_styleguide.checker import Checker settings.register_profile( 'slow', deadline=None, suppress_health_check=list(HealthCheck), ) settings.load_profile('slow') def _fix...
Checker
assert
variable
tests/test_checker/test_hypothesis.py
test_no_exceptions
79
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.constants import ( MODULE_METADATA_VARIABLES_BLACKLIST, ) from wemake_python_styleguide.violations.best_practices import ( WrongModuleMetadataViolation, ) from wemake_python_styleguide.visitors.ast.naming.variables import ( WrongModuleMetadataVisitor, ) module_m...
[])
assert_*
collection
tests/test_visitors/test_ast/test_naming/test_module_metadata.py
test_correct_metadata
87
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.refactoring import ( ImplicitEnumerateViolation, ) from wemake_python_styleguide.visitors.ast.functions import ( WrongFunctionCallContextVisitor, ) for_template = """ def function(): for list_item in {0}: ... """ wrong_samples = ( 'range(...
[])
assert_*
collection
tests/test_visitors/test_ast/test_functions/test_call_context/test_range_len.py
test_correct_range_len
54
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.complexity import ( TooManyReturnsViolation, ) from wemake_python_styleguide.visitors.ast.complexity.function import ( FunctionComplexityVisitor, ) function_without_returns = 'def function(): ...' function_with_returns = """ def function(): if 1 > 2:...
option_values.max_returns)
assert_*
complex_expr
tests/test_visitors/test_ast/test_complexity/test_function/test_returns.py
test_returns_wrong_count
84
null
wemake-services/wemake-python-styleguide
import subprocess import pytest def _popen_in_shell(args: str) -> tuple[subprocess.Popen, str, str]: """Run command in shell.""" # shell=True is needed for subprocess.Popen to # locate the installed wps command. process = subprocess.Popen( # noqa: S602 (insecure shell=True) args, stdo...
1
assert
numeric_literal
tests/test_cli/test_explain.py
test_command_on_not_found
42
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.consistency import ( SimplifiableMatchViolation, ) from wemake_python_styleguide.visitors.ast.conditions import ( SimplifiableMatchVisitor, ) simplifiable_match_match = """ match subject: case {0}{1}: pass case _: pass """ simplif...
[])
assert_*
collection
tests/test_visitors/test_ast/test_conditions/test_simplified_match_conditions.py
test_not_simplifiable_match_templates
189
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.consistency import ( MeaninglessNumberOperationViolation, UselessOperatorsViolation, ) from wemake_python_styleguide.visitors.ast.operators import ( UselessOperatorsVisitor, ) usage_template = 'constant {0}' @pytest.mark.parametrize( 'expression'...
[])
assert_*
collection
tests/test_visitors/test_ast/test_operators/test_useless_math.py
test_useful_math
106
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.visitors.ast.naming.validation import ( WrongNameVisitor, ) @pytest.mark.parametrize( 'correct_name', [ 'snake_case', '_protected', 'with_number5', ], ) def test_naming_correct( assert_errors, parse_ast_tree, naming_templa...
[])
assert_*
collection
tests/test_visitors/test_ast/test_naming/test_naming_rules/test_correct.py
test_naming_correct
30
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.oop import WrongBaseClassViolation from wemake_python_styleguide.visitors.ast.classes.classdef import ( WrongClassDefVisitor, ) class_with_base = """ class Meta({0}): '''Docs.''' """ @pytest.mark.parametrize( 'base', [ 'RawName', ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_classes/test_base_classes/test_expression_base_class.py
test_correct_base_classes
82
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.complexity import ( CognitiveComplexityViolation, CognitiveModuleComplexityViolation, ) from wemake_python_styleguide.visitors.ast.complexity.function import ( CognitiveComplexityVisitor, ) single_item = '{0}' multiple_items = """ def other(): ......
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_function/test_cognitive/test_cognitive_average.py
test_cognitive_average_default_options
147
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.refactoring import ( NestedTernaryViolation, ) from wemake_python_styleguide.visitors.ast.compares import ( WrongConditionalVisitor, ) wrong_compare1 = 'x > (a if b else c)' wrong_compare2 = '(a if b else c) > x' wrong_compare3 = 'x == (a if b else c)' wr...
[])
assert_*
collection
tests/test_visitors/test_ast/test_compares/test_nested_ternary.py
test_non_nested_ternary
118
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.naming import ( UpperCaseAttributeViolation, WrongVariableNameViolation, ) from wemake_python_styleguide.visitors.ast.naming.validation import ( WrongNameVisitor, ) patterns = ( 'value', 'no', 'data', 'SOME', 'Value', 'nO', ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_naming/test_naming_rules/test_wrong_names.py
test_allowed_wrong_variable_name_for_foreign
69
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.best_practices import ( MultipleAssignmentsViolation, ) from wemake_python_styleguide.visitors.ast.builtins import ( WrongAssignmentVisitor, ) single_assignment = 'constant = 1' tuple_assignment = 'first, second = (1, 2)' spread_assignment = 'first, *_, s...
[])
assert_*
collection
tests/test_visitors/test_ast/test_builtins/test_assign/test_multiple_assign.py
test_correct_assignments
42
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.refactoring import NestedTryViolation from wemake_python_styleguide.visitors.ast.exceptions import ( NestedTryBlocksVisitor, ) one_try_example = """ try: ... except SomeError: ... else: ... finally: ... """ two_tries_example = """ try: .....
[])
assert_*
collection
tests/test_visitors/test_ast/test_exceptions/test_nested_try_blocks.py
test_correct_try_blocks
126
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.consistency import ( OperationSignNegationViolation, ) from wemake_python_styleguide.visitors.ast.operators import ( WrongMathOperatorVisitor, ) usage_template = 'constant {0}' @pytest.mark.parametrize( 'expression', [ '- 1', '* -...
[])
assert_*
collection
tests/test_visitors/test_ast/test_operators/test_sign_negation.py
test_correct_operation
90
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.complexity import ( TooManyMatchSubjectsViolation, ) from wemake_python_styleguide.visitors.ast.complexity.pm import ( MatchSubjectsVisitor, ) match_call_expr = """ match some_call(): case 1: ... """ match_case_long_tuple = """ match some_call['a']: ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_pm/test_match_subjects.py
test_match_subjects_correct_count
67
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.best_practices import ( WrongKeywordConditionViolation, ) from wemake_python_styleguide.visitors.ast.keywords import ( ConstantKeywordVisitor, ) while_template = """ while {0}: ... """ assert_template = 'assert {0}' assert_with_message_template = 'as...
[])
assert_*
collection
tests/test_visitors/test_ast/test_keywords/test_keyword_condition.py
test_true_condition_keywords_while
144
null
wemake-services/wemake-python-styleguide
import re import subprocess import types from collections import Counter from typing import Final import pytest from wemake_python_styleguide.compat.constants import PY313 ERROR_PATTERN = re.compile(r'(WPS\d{3})') IGNORED_VIOLATIONS = ( 'WPS201', # it is a module level violation 'WPS202', # since our test...
errors
assert
variable
tests/test_checker/test_noqa.py
_assert_errors_count_in_output
332
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.oop import StaticMethodViolation from wemake_python_styleguide.visitors.ast.classes.methods import ( WrongMethodVisitor, ) decorated_method = """ class Example: @{0} def should_fail(arg1): ... """ @pytest.mark.parametrize( 'decorator', [ ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_classes/test_methods/test_staticmethod.py
test_regular_decorator_used
51
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.best_practices import ( SameElementsInConditionViolation, ) from wemake_python_styleguide.visitors.ast.conditions import ( BooleanConditionVisitor, ) @pytest.mark.parametrize( 'code', [ 'some or other', 'other and some', 'f...
[])
assert_*
collection
tests/test_visitors/test_ast/test_conditions/test_same_element.py
test_regular_conditions
34
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.consistency import ( IncorrectYieldFromTargetViolation, ) from wemake_python_styleguide.visitors.ast.keywords import ( GeneratorKeywordsVisitor, ) yield_from_template = """ def wrapper(): yield from {0} """ @pytest.mark.parametrize( 'code', [...
[])
assert_*
collection
tests/test_visitors/test_ast/test_keywords/test_generator_keywords/test_yield_from_type.py
test_yield_from_correct_type
69
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.best_practices import ( WrongKeywordViolation, ) from wemake_python_styleguide.visitors.ast.keywords import WrongKeywordVisitor pass_function = """ def function(): pass """ pass_class = """ class Test: pass """ pass_method = """ class Test: def ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_keywords/test_pass.py
test_pass_keyword_in_pattern_matching
93
null