Guest User

Untitled

a guest
Jun 17th, 2025
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.93 KB | None | 0 0
  1. ERROR: Coverage failure: total of 99 is less than fail-under=100
  2. [100%]
  3. ================================================================== ERRORS ==================================================================
  4. ____________________________________________________ ERROR collecting tests/conftest.py ____________________________________________________
  5. import file mismatch:
  6. imported module 'conftest' has this __file__ attribute:
  7. /home/alexeev/Desktop/Projects/wemake-python-styleguide/tests/test_visitors/conftest.py
  8. which is not the same as the test file we want to collect:
  9. /home/alexeev/Desktop/Projects/wemake-python-styleguide/tests/conftest.py
  10. HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules
  11. _____________________________________________ ERROR collecting tests/test_visitors/conftest.py _____________________________________________
  12. import file mismatch:
  13. imported module 'conftest' has this __file__ attribute:
  14. /home/alexeev/Desktop/Projects/wemake-python-styleguide/tests/test_logic/test_complexity/test_cognitive/conftest.py
  15. which is not the same as the test file we want to collect:
  16. /home/alexeev/Desktop/Projects/wemake-python-styleguide/tests/test_visitors/conftest.py
  17. HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules
  18. ================================================================= FAILURES =================================================================
  19. ___________________ test_untrivial_try_blocks[\ntry:\n ...\nexcept:\n ...\nfinally:\n ...\n ...\n ...\n] ____________________
  20. [gw7] linux -- Python 3.13.2 /home/alexeev/Desktop/Projects/wemake-python-styleguide/.venv/bin/python
  21.  
  22. assert_errors = <function assert_errors.<locals>.factory at 0x7f5bef50d3a0>
  23. parse_ast_tree = <function parse_ast_tree.<locals>.factory at 0x7f5bef50d6c0>
  24. code = '\ntry:\n ...\nexcept:\n ...\nfinally:\n ...\n ...\n ...\n'
  25. 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)
  26.  
  27. @pytest.mark.parametrize(
  28. 'code',
  29. [
  30. untrivial_logic_example1,
  31. ],
  32. )
  33. def test_untrivial_try_blocks(
  34. assert_errors,
  35. parse_ast_tree,
  36. code,
  37. default_options,
  38. ):
  39. """Violations are raised when finally blocks exceed default line limit."""
  40. tree = parse_ast_tree(code)
  41.  
  42. visitor = UntrivialFinallyBlocksVisitor(default_options, tree=tree)
  43. visitor.run()
  44.  
  45. > assert_errors(visitor, [ComplexFinallyViolation])
  46.  
  47. tests/test_visitors/test_ast/test_exceptions/test_untrivial_finally_blocks.py:86:
  48. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  49.  
  50. visitor = <wemake_python_styleguide.visitors.ast.complexity.complex_continue.UntrivialFinallyBlocksVisitor object at 0x7f5bef55a7b0>
  51. expected_errors = [<class 'wemake_python_styleguide.violations.complexity.ComplexFinallyViolation'>]
  52.  
  53. def factory(
  54. visitor: BaseVisitor,
  55. expected_errors: Sequence[str],
  56. *,
  57. ignored_types: _IgnoredTypes = None,
  58. ) -> None:
  59. if ignored_types:
  60. real_errors = [
  61. error
  62. for error in visitor.violations
  63. if not isinstance(error, ignored_types)
  64. ]
  65. else:
  66. real_errors = visitor.violations
  67.  
  68. > assert len(real_errors) == len(expected_errors), _produce_error_message(
  69. visitor,
  70. )
  71. E AssertionError:
  72. E try:
  73. E ...
  74. E except:
  75. E ...
  76. E finally:
  77. E ...
  78. E ...
  79. E ...
  80. E assert 0 == 1
  81. E + where 0 = len([])
  82. E + and 1 = len([<class 'wemake_python_styleguide.violations.complexity.ComplexFinallyViolation'>])
  83.  
  84. tests/test_visitors/conftest.py:52: AssertionError
  85. ___________ test_custom_untrivial_try_blocks[\ntry:\n ...\nexcept:\n ...\nfinally:\n ...\n ...\n ...\n ...\n] ____________
  86. [gw7] linux -- Python 3.13.2 /home/alexeev/Desktop/Projects/wemake-python-styleguide/.venv/bin/python
  87.  
  88. assert_errors = <function assert_errors.<locals>.factory at 0x7f5bef50d3a0>
  89. parse_ast_tree = <function parse_ast_tree.<locals>.factory at 0x7f5bef50d6c0>
  90. code = '\ntry:\n ...\nexcept:\n ...\nfinally:\n ...\n ...\n ...\n ...\n'
  91. options = <function options.<locals>.factory at 0x7f5bef50db20>
  92.  
  93. @pytest.mark.parametrize(
  94. 'code',
  95. [untrivial_logic_custom_example1],
  96. )
  97. def test_custom_untrivial_try_blocks(
  98. assert_errors,
  99. parse_ast_tree,
  100. code,
  101. options,
  102. ):
  103. """Violations are raised when finally blocks exceed custom line limit."""
  104. tree = parse_ast_tree(code)
  105.  
  106. option_values = options(max_lines_in_finally=3)
  107. visitor = UntrivialFinallyBlocksVisitor(option_values, tree=tree)
  108. visitor.run()
  109.  
  110. > assert_errors(visitor, [ComplexFinallyViolation])
  111.  
  112. tests/test_visitors/test_ast/test_exceptions/test_untrivial_finally_blocks.py:106:
  113. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  114.  
  115. visitor = <wemake_python_styleguide.visitors.ast.complexity.complex_continue.UntrivialFinallyBlocksVisitor object at 0x7f5bef58d040>
  116. expected_errors = [<class 'wemake_python_styleguide.violations.complexity.ComplexFinallyViolation'>]
  117.  
  118. def factory(
  119. visitor: BaseVisitor,
  120. expected_errors: Sequence[str],
  121. *,
  122. ignored_types: _IgnoredTypes = None,
  123. ) -> None:
  124. if ignored_types:
  125. real_errors = [
  126. error
  127. for error in visitor.violations
  128. if not isinstance(error, ignored_types)
  129. ]
  130. else:
  131. real_errors = visitor.violations
  132.  
  133. > assert len(real_errors) == len(expected_errors), _produce_error_message(
  134. visitor,
  135. )
  136. E AssertionError:
  137. E try:
  138. E ...
  139. E except:
  140. E ...
  141. E finally:
  142. E ...
  143. E ...
  144. E ...
  145. E ...
  146. E assert 0 == 1
  147. E + where 0 = len([])
  148. E + and 1 = len([<class 'wemake_python_styleguide.violations.complexity.ComplexFinallyViolation'>])
  149.  
  150. tests/test_visitors/conftest.py:52: AssertionError
  151. __________________________________________________ test_all_visitors_contained_in_checker __________________________________________________
  152. [gw6] linux -- Python 3.13.2 /home/alexeev/Desktop/Projects/wemake-python-styleguide/.venv/bin/python
  153.  
  154. 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'>, ...}
  155.  
  156. def test_all_visitors_contained_in_checker(all_visitors):
  157. """Ensures that all visitors are contained in a checker."""
  158. checker_visitors = {
  159. klass.__qualname__
  160. for klass in Checker._visitors # noqa: SLF001
  161. if not klass.__qualname__.startswith('_')
  162. }
  163.  
  164. for visitor in all_visitors:
  165. > assert visitor.__qualname__ in checker_visitors
  166. E AssertionError: assert 'UntrivialFinallyBlocksVisitor' in {'AccessVisitor', 'AfterBlockVariablesVisitor', 'AnnotationComplexityVisitor', 'AssignmentPatternsVisitor', 'BooleanConditionVisitor', 'BuggySuperCallVisitor', ...}
  167. E + where 'UntrivialFinallyBlocksVisitor' = <class 'wemake_python_styleguide.visitors.ast.complexity.complex_continue.UntrivialFinallyBlocksVisitor'>.__qualname__
  168.  
  169. tests/test_checker/test_presets.py:72: AssertionError
  170. ___________________________________________ test_noqa_fixture_disabled[noqa.py-violations0-True] ___________________________________________
  171. [gw0] linux -- Python 3.13.2 /home/alexeev/Desktop/Projects/wemake-python-styleguide/.venv/bin/python
  172.  
  173. absolute_path = <function absolute_path.<locals>.factory at 0x7fa7d7eb8ae0>
  174. all_violations = [<class 'wemake_python_styleguide.violations.system.InternalErrorViolation'>, <class 'wemake_python_styleguide.violati...s.naming.WrongVariableNameViolation'>, <class 'wemake_python_styleguide.violations.naming.TooShortNameViolation'>, ...]
  175. filename = 'noqa.py'
  176. 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})
  177. run_condition = True
  178.  
  179. @pytest.mark.parametrize(
  180. ('filename', 'violations', 'run_condition'),
  181. [
  182. ('noqa.py', SHOULD_BE_RAISED, ALWAYS),
  183. ('noqa313.py', SHOULD_BE_RAISED3_13, PY313),
  184. ],
  185. )
  186. def test_noqa_fixture_disabled(
  187. absolute_path, all_violations, filename, violations, run_condition
  188. ):
  189. """End-to-End test to check that all violations are present."""
  190. if not run_condition: # pragma: no cover
  191. return
  192. process = subprocess.Popen(
  193. [
  194. 'flake8',
  195. '--ignore',
  196. ','.join(IGNORED_VIOLATIONS),
  197. '--disable-noqa',
  198. '--isolated',
  199. '--select',
  200. 'WPS',
  201. absolute_path('fixtures', 'noqa', filename),
  202. ],
  203. stdout=subprocess.PIPE,
  204. stderr=subprocess.PIPE,
  205. universal_newlines=True,
  206. encoding='utf8',
  207. )
  208. stdout, stderr = process.communicate()
  209.  
  210. assert stdout
  211. assert not stderr.count('WPS')
  212. > _assert_errors_count_in_output(
  213. stdout, violations, all_violations, total=filename == 'noqa.py'
  214. )
  215.  
  216. tests/test_checker/test_noqa.py:377:
  217. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  218.  
  219. 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'
  220. 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})
  221. all_violations = [<class 'wemake_python_styleguide.violations.system.InternalErrorViolation'>, <class 'wemake_python_styleguide.violati...s.naming.WrongVariableNameViolation'>, <class 'wemake_python_styleguide.violations.naming.TooShortNameViolation'>, ...]
  222.  
  223. def _assert_errors_count_in_output(
  224. output,
  225. errors,
  226. all_violations,
  227. *,
  228. total: bool = True,
  229. ):
  230. found_errors = Counter(
  231. (match.group(0) for match in ERROR_PATTERN.finditer(output)),
  232. )
  233.  
  234. if total: # pragma: no cover
  235. for violation in all_violations:
  236. key = f'WPS{str(violation.code).zfill(3)}' # noqa: WPS237
  237. assert key in errors, 'Unlisted #noqa violation'
  238.  
  239. for found_error, found_count in found_errors.items():
  240. assert found_error in errors, 'Violation without a #noqa count'
  241. assert found_count == errors.get(found_error), found_error
  242.  
  243. > assert set(found_errors.keys()) == set(
  244. filter(lambda key: errors[key] != 0, errors), # expected
  245. )
  246. E AssertionError: assert {'WPS110', 'W...'WPS116', ...} == {'WPS110', 'W...'WPS116', ...}
  247. E
  248. E Extra items in the right set:
  249. E 'WPS243'
  250. E Use -v to get more diff
  251.  
  252. tests/test_checker/test_noqa.py:331: AssertionError
  253. ============================================================== tests coverage ==============================================================
  254. _____________________________________________ coverage: platform linux, python 3.13.2-final-0 ______________________________________________
  255.  
  256. Name Stmts Miss Branch BrPart Cover Missing
  257. ------------------------------------------------------------------------------------------------------------------
  258. tests/test_checker/test_presets.py 34 1 4 1 95% 74
  259. wemake_python_styleguide/logic/naming/constants.py 5 1 2 1 71% 25
  260. wemake_python_styleguide/logic/naming/duplicates.py 3 1 0 0 67% 11
  261. wemake_python_styleguide/logic/naming/logical.py 21 1 10 2 90% 120, 125->128
  262. wemake_python_styleguide/logic/naming/name_nodes.py 38 1 22 1 97% 109
  263. wemake_python_styleguide/visitors/ast/complexity/complex_continue.py 20 12 8 0 29% 14-15, 19-33
  264. ------------------------------------------------------------------------------------------------------------------
  265. TOTAL 12027 17 1650 5 99%
  266.  
  267. 383 files skipped due to complete coverage.
  268. Coverage HTML written to dir htmlcov
  269. Coverage XML written to file coverage.xml
  270. FAIL Required test coverage of 100% not reached. Total coverage: 99.78%
  271. ========================================================= short test summary info ==========================================================
  272. 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:
  273. 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:
  274. FAILED tests/test_checker/test_presets.py::test_all_visitors_contained_in_checker - AssertionError: assert 'UntrivialFinallyBlocksVisitor' in {'AccessVisitor', 'AfterBlockVariablesVisitor', 'AnnotationComplexityVisitor'...
  275. FAILED tests/test_checker/test_noqa.py::test_noqa_fixture_disabled[noqa.py-violations0-True] - AssertionError: assert {'WPS110', 'W...'WPS116', ...} == {'WPS110', 'W...'WPS116', ...}
  276. ERROR tests/conftest.py
  277. ERROR tests/test_visitors/conftest.py
  278. ==================================== 4 failed, 27116 passed, 20 skipped, 2 errors in 113.68s (0:01:53) =====================================
Advertisement
Add Comment
Please, Sign In to add comment