88
99import pytest
1010
11- from pylint .checkers import similar
11+ from pylint .checkers import symilar
1212from pylint .constants import IS_PYPY , PY39_PLUS
1313from pylint .lint import PyLinter
1414from pylint .testutils import GenericTestReporter as Reporter
3131def test_ignore_comments () -> None :
3232 output = StringIO ()
3333 with redirect_stdout (output ), pytest .raises (SystemExit ) as ex :
34- similar .Run (["--ignore-comments" , SIMILAR1 , SIMILAR2 ])
34+ symilar .Run (["--ignore-comments" , SIMILAR1 , SIMILAR2 ])
3535 assert ex .value .code == 0
3636 assert (
3737 output .getvalue ().strip ()
@@ -60,7 +60,7 @@ def test_ignore_comments() -> None:
6060def test_ignore_docstrings () -> None :
6161 output = StringIO ()
6262 with redirect_stdout (output ), pytest .raises (SystemExit ) as ex :
63- similar .Run (["--ignore-docstrings" , SIMILAR1 , SIMILAR2 ])
63+ symilar .Run (["--ignore-docstrings" , SIMILAR1 , SIMILAR2 ])
6464 assert ex .value .code == 0
6565 assert (
6666 output .getvalue ().strip ()
@@ -95,7 +95,7 @@ def test_ignore_docstrings() -> None:
9595def test_ignore_imports () -> None :
9696 output = StringIO ()
9797 with redirect_stdout (output ), pytest .raises (SystemExit ) as ex :
98- similar .Run (["--ignore-imports" , SIMILAR1 , SIMILAR2 ])
98+ symilar .Run (["--ignore-imports" , SIMILAR1 , SIMILAR2 ])
9999 assert ex .value .code == 0
100100 assert (
101101 output .getvalue ().strip ()
@@ -108,7 +108,7 @@ def test_ignore_imports() -> None:
108108def test_multiline_imports () -> None :
109109 output = StringIO ()
110110 with redirect_stdout (output ), pytest .raises (SystemExit ) as ex :
111- similar .Run ([MULTILINE , MULTILINE ])
111+ symilar .Run ([MULTILINE , MULTILINE ])
112112 assert ex .value .code == 0
113113 assert (
114114 output .getvalue ().strip ()
@@ -138,7 +138,7 @@ def test_multiline_imports() -> None:
138138def test_ignore_multiline_imports () -> None :
139139 output = StringIO ()
140140 with redirect_stdout (output ), pytest .raises (SystemExit ) as ex :
141- similar .Run (["--ignore-imports" , MULTILINE , MULTILINE ])
141+ symilar .Run (["--ignore-imports" , MULTILINE , MULTILINE ])
142142 assert ex .value .code == 0
143143 assert (
144144 output .getvalue ().strip ()
@@ -151,7 +151,7 @@ def test_ignore_multiline_imports() -> None:
151151def test_ignore_signatures_fail () -> None :
152152 output = StringIO ()
153153 with redirect_stdout (output ), pytest .raises (SystemExit ) as ex :
154- similar .Run ([SIMILAR5 , SIMILAR6 ])
154+ symilar .Run ([SIMILAR5 , SIMILAR6 ])
155155 assert ex .value .code == 0
156156 assert (
157157 output .getvalue ().strip ()
@@ -189,7 +189,7 @@ def example():
189189def test_ignore_signatures_pass () -> None :
190190 output = StringIO ()
191191 with redirect_stdout (output ), pytest .raises (SystemExit ) as ex :
192- similar .Run (["--ignore-signatures" , SIMILAR5 , SIMILAR6 ])
192+ symilar .Run (["--ignore-signatures" , SIMILAR5 , SIMILAR6 ])
193193 assert ex .value .code == 0
194194 assert (
195195 output .getvalue ().strip ()
@@ -202,7 +202,7 @@ def test_ignore_signatures_pass() -> None:
202202def test_ignore_signatures_class_methods_fail () -> None :
203203 output = StringIO ()
204204 with redirect_stdout (output ), pytest .raises (SystemExit ) as ex :
205- similar .Run ([SIMILAR_CLS_B , SIMILAR_CLS_A ])
205+ symilar .Run ([SIMILAR_CLS_B , SIMILAR_CLS_A ])
206206 assert ex .value .code == 0
207207 assert (
208208 output .getvalue ().strip ()
@@ -248,7 +248,7 @@ def _internal_func(
248248def test_ignore_signatures_class_methods_pass () -> None :
249249 output = StringIO ()
250250 with redirect_stdout (output ), pytest .raises (SystemExit ) as ex :
251- similar .Run (["--ignore-signatures" , SIMILAR_CLS_B , SIMILAR_CLS_A ])
251+ symilar .Run (["--ignore-signatures" , SIMILAR_CLS_B , SIMILAR_CLS_A ])
252252 assert ex .value .code == 0
253253 assert (
254254 output .getvalue ().strip ()
@@ -261,7 +261,7 @@ def test_ignore_signatures_class_methods_pass() -> None:
261261def test_ignore_signatures_empty_functions_fail () -> None :
262262 output = StringIO ()
263263 with redirect_stdout (output ), pytest .raises (SystemExit ) as ex :
264- similar .Run ([EMPTY_FUNCTION_1 , EMPTY_FUNCTION_2 ])
264+ symilar .Run ([EMPTY_FUNCTION_1 , EMPTY_FUNCTION_2 ])
265265 assert ex .value .code == 0
266266 assert (
267267 output .getvalue ().strip ()
@@ -285,7 +285,7 @@ def test_ignore_signatures_empty_functions_fail() -> None:
285285def test_ignore_signatures_empty_functions_pass () -> None :
286286 output = StringIO ()
287287 with redirect_stdout (output ), pytest .raises (SystemExit ) as ex :
288- similar .Run (["--ignore-signatures" , EMPTY_FUNCTION_1 , EMPTY_FUNCTION_2 ])
288+ symilar .Run (["--ignore-signatures" , EMPTY_FUNCTION_1 , EMPTY_FUNCTION_2 ])
289289 assert ex .value .code == 0
290290 assert (
291291 output .getvalue ().strip ()
@@ -298,15 +298,15 @@ def test_ignore_signatures_empty_functions_pass() -> None:
298298def test_no_hide_code_with_imports () -> None :
299299 output = StringIO ()
300300 with redirect_stdout (output ), pytest .raises (SystemExit ) as ex :
301- similar .Run (["--ignore-imports" ] + 2 * [HIDE_CODE_WITH_IMPORTS ])
301+ symilar .Run (["--ignore-imports" ] + 2 * [HIDE_CODE_WITH_IMPORTS ])
302302 assert ex .value .code == 0
303303 assert "TOTAL lines=32 duplicates=0 percent=0.00" in output .getvalue ()
304304
305305
306306def test_ignore_nothing () -> None :
307307 output = StringIO ()
308308 with redirect_stdout (output ), pytest .raises (SystemExit ) as ex :
309- similar .Run ([SIMILAR1 , SIMILAR2 ])
309+ symilar .Run ([SIMILAR1 , SIMILAR2 ])
310310 assert ex .value .code == 0
311311 assert (
312312 output .getvalue ().strip ()
@@ -329,7 +329,7 @@ def test_ignore_nothing() -> None:
329329def test_lines_without_meaningful_content_do_not_trigger_similarity () -> None :
330330 output = StringIO ()
331331 with redirect_stdout (output ), pytest .raises (SystemExit ) as ex :
332- similar .Run ([SIMILAR3 , SIMILAR4 ])
332+ symilar .Run ([SIMILAR3 , SIMILAR4 ])
333333 assert ex .value .code == 0
334334 assert (
335335 output .getvalue ().strip ()
@@ -362,7 +362,7 @@ def test_help() -> None:
362362 output = StringIO ()
363363 with redirect_stdout (output ):
364364 try :
365- similar .Run (["--help" ])
365+ symilar .Run (["--help" ])
366366 except SystemExit as ex :
367367 assert ex .code == 0
368368 else :
@@ -373,18 +373,18 @@ def test_no_args() -> None:
373373 output = StringIO ()
374374 with redirect_stdout (output ):
375375 try :
376- similar .Run ([])
376+ symilar .Run ([])
377377 except SystemExit as ex :
378378 assert ex .code == 1
379379 else :
380380 pytest .fail ("not system exit" )
381381
382382
383383def test_get_map_data () -> None :
384- """Tests that a SimilarChecker can return and reduce mapped data."""
384+ """Tests that a SymilarChecker can return and reduce mapped data."""
385385 linter = PyLinter (reporter = Reporter ())
386386 # Add a parallel checker to ensure it can map and reduce
387- linter .register_checker (similar . SimilarChecker (linter ))
387+ linter .register_checker (symilar . SimilaritiesChecker (linter ))
388388 source_streams = (
389389 str (INPUT / "similar_lines_a.py" ),
390390 str (INPUT / "similar_lines_b.py" ),
@@ -473,7 +473,7 @@ def test_get_map_data() -> None:
473473
474474 # Manually perform a 'map' type function
475475 for source_fname in source_streams :
476- sim = similar . SimilarChecker (PyLinter ())
476+ sim = symilar . SimilaritiesChecker (PyLinter ())
477477 sim .linter .set_option ("ignore-imports" , False )
478478 sim .linter .set_option ("ignore-signatures" , False )
479479 with open (source_fname , encoding = "utf-8" ) as stream :
@@ -494,7 +494,7 @@ def test_get_map_data() -> None:
494494def test_set_duplicate_lines_to_zero () -> None :
495495 output = StringIO ()
496496 with redirect_stdout (output ), pytest .raises (SystemExit ) as ex :
497- similar .Run (["--duplicates=0" , SIMILAR1 , SIMILAR2 ])
497+ symilar .Run (["--duplicates=0" , SIMILAR1 , SIMILAR2 ])
498498 assert ex .value .code == 0
499499 assert output .getvalue () == ""
500500
@@ -504,7 +504,7 @@ def test_bad_equal_short_form_option(v: str) -> None:
504504 """Regression test for https://github.com/pylint-dev/pylint/issues/9343"""
505505 output = StringIO ()
506506 with redirect_stdout (output ), pytest .raises (SystemExit ) as ex :
507- similar .Run ([f"-{ v } =0" , SIMILAR1 , SIMILAR2 ])
507+ symilar .Run ([f"-{ v } =0" , SIMILAR1 , SIMILAR2 ])
508508 assert ex .value .code == 2
509509 assert "invalid literal for int() with base 10: '=0'" in output .getvalue ()
510510
@@ -514,7 +514,7 @@ def test_space_short_form_option(v: str) -> None:
514514 """Regression test for https://github.com/pylint-dev/pylint/issues/9343"""
515515 output = StringIO ()
516516 with redirect_stdout (output ), pytest .raises (SystemExit ) as ex :
517- similar .Run ([f"-{ v } 2" , SIMILAR1 , SIMILAR2 ])
517+ symilar .Run ([f"-{ v } 2" , SIMILAR1 , SIMILAR2 ])
518518 assert ex .value .code == 0
519519 assert "similar lines in" in output .getvalue ()
520520
@@ -523,6 +523,6 @@ def test_bad_short_form_option() -> None:
523523 """Regression test for https://github.com/pylint-dev/pylint/issues/9343"""
524524 output = StringIO ()
525525 with redirect_stdout (output ), pytest .raises (SystemExit ) as ex :
526- similar .Run (["-j=0" , SIMILAR1 , SIMILAR2 ])
526+ symilar .Run (["-j=0" , SIMILAR1 , SIMILAR2 ])
527527 assert ex .value .code == 2
528528 assert "option -j not recognized" in output .getvalue ()
0 commit comments