Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ERROR: Coverage failure: total of 99 is less than fail-under=100
- [100%]
- ================================================================== ERRORS ==================================================================
- ____________________________________________________ ERROR collecting tests/conftest.py ____________________________________________________
- import file mismatch:
- imported module 'conftest' has this __file__ attribute:
- /home/alexeev/Desktop/Projects/wemake-python-styleguide/tests/test_visitors/conftest.py
- which is not the same as the test file we want to collect:
- /home/alexeev/Desktop/Projects/wemake-python-styleguide/tests/conftest.py
- HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules
- _____________________________________________ ERROR collecting tests/test_visitors/conftest.py _____________________________________________
- import file mismatch:
- imported module 'conftest' has this __file__ attribute:
- /home/alexeev/Desktop/Projects/wemake-python-styleguide/tests/test_logic/test_complexity/test_cognitive/conftest.py
- which is not the same as the test file we want to collect:
- /home/alexeev/Desktop/Projects/wemake-python-styleguide/tests/test_visitors/conftest.py
- HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules
- ================================================================= FAILURES =================================================================
- ___________________ test_untrivial_try_blocks[\ntry:\n ...\nexcept:\n ...\nfinally:\n ...\n ...\n ...\n] ____________________
- [gw7] linux -- Python 3.13.2 /home/alexeev/Desktop/Projects/wemake-python-styleguide/.venv/bin/python
- assert_errors = <function assert_errors.<locals>.factory at 0x7f5bef50d3a0>
- parse_ast_tree = <function parse_ast_tree.<locals>.factory at 0x7f5bef50d6c0>
- code = '\ntry:\n ...\nexcept:\n ...\nfinally:\n ...\n ...\n ...\n'
- default_options = options(min_name_length=2, max_name_length=45, max_noqa_comments=10, nested_classes_whitelist=('Meta', 'Params', 'Conf...ngth=4, max_type_params=6, max_match_subjects=7, max_match_cases=7, max_lines_in_finally=2, show_violation_links=False)
- @pytest.mark.parametrize(
- 'code',
- [
- untrivial_logic_example1,
- ],
- )
- def test_untrivial_try_blocks(
- assert_errors,
- parse_ast_tree,
- code,
- default_options,
- ):
- """Violations are raised when finally blocks exceed default line limit."""
- tree = parse_ast_tree(code)
- visitor = UntrivialFinallyBlocksVisitor(default_options, tree=tree)
- visitor.run()
- > assert_errors(visitor, [ComplexFinallyViolation])
- tests/test_visitors/test_ast/test_exceptions/test_untrivial_finally_blocks.py:86:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- visitor = <wemake_python_styleguide.visitors.ast.complexity.complex_continue.UntrivialFinallyBlocksVisitor object at 0x7f5bef55a7b0>
- expected_errors = [<class 'wemake_python_styleguide.violations.complexity.ComplexFinallyViolation'>]
- def factory(
- visitor: BaseVisitor,
- expected_errors: Sequence[str],
- *,
- ignored_types: _IgnoredTypes = None,
- ) -> None:
- if ignored_types:
- real_errors = [
- error
- for error in visitor.violations
- if not isinstance(error, ignored_types)
- ]
- else:
- real_errors = visitor.violations
- > assert len(real_errors) == len(expected_errors), _produce_error_message(
- visitor,
- )
- E AssertionError:
- E try:
- E ...
- E except:
- E ...
- E finally:
- E ...
- E ...
- E ...
- E assert 0 == 1
- E + where 0 = len([])
- E + and 1 = len([<class 'wemake_python_styleguide.violations.complexity.ComplexFinallyViolation'>])
- tests/test_visitors/conftest.py:52: AssertionError
- ___________ test_custom_untrivial_try_blocks[\ntry:\n ...\nexcept:\n ...\nfinally:\n ...\n ...\n ...\n ...\n] ____________
- [gw7] linux -- Python 3.13.2 /home/alexeev/Desktop/Projects/wemake-python-styleguide/.venv/bin/python
- assert_errors = <function assert_errors.<locals>.factory at 0x7f5bef50d3a0>
- parse_ast_tree = <function parse_ast_tree.<locals>.factory at 0x7f5bef50d6c0>
- code = '\ntry:\n ...\nexcept:\n ...\nfinally:\n ...\n ...\n ...\n ...\n'
- options = <function options.<locals>.factory at 0x7f5bef50db20>
- @pytest.mark.parametrize(
- 'code',
- [untrivial_logic_custom_example1],
- )
- def test_custom_untrivial_try_blocks(
- assert_errors,
- parse_ast_tree,
- code,
- options,
- ):
- """Violations are raised when finally blocks exceed custom line limit."""
- tree = parse_ast_tree(code)
- option_values = options(max_lines_in_finally=3)
- visitor = UntrivialFinallyBlocksVisitor(option_values, tree=tree)
- visitor.run()
- > assert_errors(visitor, [ComplexFinallyViolation])
- tests/test_visitors/test_ast/test_exceptions/test_untrivial_finally_blocks.py:106:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- visitor = <wemake_python_styleguide.visitors.ast.complexity.complex_continue.UntrivialFinallyBlocksVisitor object at 0x7f5bef58d040>
- expected_errors = [<class 'wemake_python_styleguide.violations.complexity.ComplexFinallyViolation'>]
- def factory(
- visitor: BaseVisitor,
- expected_errors: Sequence[str],
- *,
- ignored_types: _IgnoredTypes = None,
- ) -> None:
- if ignored_types:
- real_errors = [
- error
- for error in visitor.violations
- if not isinstance(error, ignored_types)
- ]
- else:
- real_errors = visitor.violations
- > assert len(real_errors) == len(expected_errors), _produce_error_message(
- visitor,
- )
- E AssertionError:
- E try:
- E ...
- E except:
- E ...
- E finally:
- E ...
- E ...
- E ...
- E ...
- E assert 0 == 1
- E + where 0 = len([])
- E + and 1 = len([<class 'wemake_python_styleguide.violations.complexity.ComplexFinallyViolation'>])
- tests/test_visitors/conftest.py:52: AssertionError
- __________________________________________________ test_all_visitors_contained_in_checker __________________________________________________
- [gw6] linux -- Python 3.13.2 /home/alexeev/Desktop/Projects/wemake-python-styleguide/.venv/bin/python
- all_visitors = {<class 'wemake_python_styleguide.visitors.ast.compares.InCompareSanityVisitor'>, <class 'wemake_python_styleguide.vis...gnitiveComplexityVisitor'>, <class 'wemake_python_styleguide.visitors.ast.classes.methods.BuggySuperCallVisitor'>, ...}
- def test_all_visitors_contained_in_checker(all_visitors):
- """Ensures that all visitors are contained in a checker."""
- checker_visitors = {
- klass.__qualname__
- for klass in Checker._visitors # noqa: SLF001
- if not klass.__qualname__.startswith('_')
- }
- for visitor in all_visitors:
- > assert visitor.__qualname__ in checker_visitors
- E AssertionError: assert 'UntrivialFinallyBlocksVisitor' in {'AccessVisitor', 'AfterBlockVariablesVisitor', 'AnnotationComplexityVisitor', 'AssignmentPatternsVisitor', 'BooleanConditionVisitor', 'BuggySuperCallVisitor', ...}
- E + where 'UntrivialFinallyBlocksVisitor' = <class 'wemake_python_styleguide.visitors.ast.complexity.complex_continue.UntrivialFinallyBlocksVisitor'>.__qualname__
- tests/test_checker/test_presets.py:72: AssertionError
- ___________________________________________ test_noqa_fixture_disabled[noqa.py-violations0-True] ___________________________________________
- [gw0] linux -- Python 3.13.2 /home/alexeev/Desktop/Projects/wemake-python-styleguide/.venv/bin/python
- absolute_path = <function absolute_path.<locals>.factory at 0x7fa7d7eb8ae0>
- all_violations = [<class 'wemake_python_styleguide.violations.system.InternalErrorViolation'>, <class 'wemake_python_styleguide.violati...s.naming.WrongVariableNameViolation'>, <class 'wemake_python_styleguide.violations.naming.TooShortNameViolation'>, ...]
- filename = 'noqa.py'
- violations = mappingproxy({'WPS000': 0, 'WPS100': 0, 'WPS101': 0, 'WPS102': 0, 'WPS110': 5, 'WPS111': 2, 'WPS112': 1, 'WPS113': 0, ..., 'WPS609': 0, 'WPS610': 1, 'WPS611': 1, 'WPS612': 1, 'WPS613': 1, 'WPS614': 1, 'WPS615': 2, 'WPS616': 1, 'WPS617': 1})
- run_condition = True
- @pytest.mark.parametrize(
- ('filename', 'violations', 'run_condition'),
- [
- ('noqa.py', SHOULD_BE_RAISED, ALWAYS),
- ('noqa313.py', SHOULD_BE_RAISED3_13, PY313),
- ],
- )
- def test_noqa_fixture_disabled(
- absolute_path, all_violations, filename, violations, run_condition
- ):
- """End-to-End test to check that all violations are present."""
- if not run_condition: # pragma: no cover
- return
- process = subprocess.Popen(
- [
- 'flake8',
- '--ignore',
- ','.join(IGNORED_VIOLATIONS),
- '--disable-noqa',
- '--isolated',
- '--select',
- 'WPS',
- absolute_path('fixtures', 'noqa', filename),
- ],
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- universal_newlines=True,
- encoding='utf8',
- )
- stdout, stderr = process.communicate()
- assert stdout
- assert not stderr.count('WPS')
- > _assert_errors_count_in_output(
- stdout, violations, all_violations, total=filename == 'noqa.py'
- )
- tests/test_checker/test_noqa.py:377:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- output = '/home/alexeev/Desktop/Projects/wemake-python-styleguide/tests/fixtures/noqa/noqa.py:7:1: WPS422 Found future import: ...esktop/Projects/wemake-python-styleguide/tests/fixtures/noqa/noqa.py:757:31: WPS478 Found non strict slice operation\n'
- errors = mappingproxy({'WPS000': 0, 'WPS100': 0, 'WPS101': 0, 'WPS102': 0, 'WPS110': 5, 'WPS111': 2, 'WPS112': 1, 'WPS113': 0, ..., 'WPS609': 0, 'WPS610': 1, 'WPS611': 1, 'WPS612': 1, 'WPS613': 1, 'WPS614': 1, 'WPS615': 2, 'WPS616': 1, 'WPS617': 1})
- all_violations = [<class 'wemake_python_styleguide.violations.system.InternalErrorViolation'>, <class 'wemake_python_styleguide.violati...s.naming.WrongVariableNameViolation'>, <class 'wemake_python_styleguide.violations.naming.TooShortNameViolation'>, ...]
- def _assert_errors_count_in_output(
- output,
- errors,
- all_violations,
- *,
- total: bool = True,
- ):
- found_errors = Counter(
- (match.group(0) for match in ERROR_PATTERN.finditer(output)),
- )
- if total: # pragma: no cover
- for violation in all_violations:
- key = f'WPS{str(violation.code).zfill(3)}' # noqa: WPS237
- assert key in errors, 'Unlisted #noqa violation'
- for found_error, found_count in found_errors.items():
- assert found_error in errors, 'Violation without a #noqa count'
- assert found_count == errors.get(found_error), found_error
- > assert set(found_errors.keys()) == set(
- filter(lambda key: errors[key] != 0, errors), # expected
- )
- E AssertionError: assert {'WPS110', 'W...'WPS116', ...} == {'WPS110', 'W...'WPS116', ...}
- E
- E Extra items in the right set:
- E 'WPS243'
- E Use -v to get more diff
- tests/test_checker/test_noqa.py:331: AssertionError
- ============================================================== tests coverage ==============================================================
- _____________________________________________ coverage: platform linux, python 3.13.2-final-0 ______________________________________________
- Name Stmts Miss Branch BrPart Cover Missing
- ------------------------------------------------------------------------------------------------------------------
- tests/test_checker/test_presets.py 34 1 4 1 95% 74
- wemake_python_styleguide/logic/naming/constants.py 5 1 2 1 71% 25
- wemake_python_styleguide/logic/naming/duplicates.py 3 1 0 0 67% 11
- wemake_python_styleguide/logic/naming/logical.py 21 1 10 2 90% 120, 125->128
- wemake_python_styleguide/logic/naming/name_nodes.py 38 1 22 1 97% 109
- wemake_python_styleguide/visitors/ast/complexity/complex_continue.py 20 12 8 0 29% 14-15, 19-33
- ------------------------------------------------------------------------------------------------------------------
- TOTAL 12027 17 1650 5 99%
- 383 files skipped due to complete coverage.
- Coverage HTML written to dir htmlcov
- Coverage XML written to file coverage.xml
- FAIL Required test coverage of 100% not reached. Total coverage: 99.78%
- ========================================================= short test summary info ==========================================================
- FAILED tests/test_visitors/test_ast/test_exceptions/test_untrivial_finally_blocks.py::test_untrivial_try_blocks[\ntry:\n ...\nexcept:\n ...\nfinally:\n ...\n ...\n ...\n] - AssertionError:
- FAILED tests/test_visitors/test_ast/test_exceptions/test_untrivial_finally_blocks.py::test_custom_untrivial_try_blocks[\ntry:\n ...\nexcept:\n ...\nfinally:\n ...\n ...\n ...\n ...\n] - AssertionError:
- FAILED tests/test_checker/test_presets.py::test_all_visitors_contained_in_checker - AssertionError: assert 'UntrivialFinallyBlocksVisitor' in {'AccessVisitor', 'AfterBlockVariablesVisitor', 'AnnotationComplexityVisitor'...
- FAILED tests/test_checker/test_noqa.py::test_noqa_fixture_disabled[noqa.py-violations0-True] - AssertionError: assert {'WPS110', 'W...'WPS116', ...} == {'WPS110', 'W...'WPS116', ...}
- ERROR tests/conftest.py
- ERROR tests/test_visitors/conftest.py
- ==================================== 4 failed, 27116 passed, 20 skipped, 2 errors in 113.68s (0:01:53) =====================================
Advertisement
Add Comment
Please, Sign In to add comment