2020
2121MOCK_PYPI_FORMAT = ("22.1.5" , ["22.1.5" , "22.1.4" , "20.1.8" , "20.1.7" , "18.1.8" ])
2222MOCK_PYPI_TIDY = ("21.1.6" , ["21.1.6" , "21.1.1" , "20.1.0" , "19.1.0.1" , "18.1.8" ])
23- MOCK_PYPI_INCLUDE_CLEANER = ("22.1.7" , ["22.1.7" , "22.1.5" ])
24- MOCK_PYPI_APPLY_REPLACEMENTS = ("17.0.6" , ["17.0.6" , "16.0.0" ])
2523
2624
2725def _pypi_side_effect (tool : str ):
2826 """Side-effect that maps tool names to canned PyPI responses."""
2927 mapping = {
3028 "clang-format" : MOCK_PYPI_FORMAT ,
3129 "clang-tidy" : MOCK_PYPI_TIDY ,
32- "clang-include-cleaner" : MOCK_PYPI_INCLUDE_CLEANER ,
33- "clang-apply-replacements" : MOCK_PYPI_APPLY_REPLACEMENTS ,
3430 }
3531 return mapping .get (tool , (None , []))
3632
@@ -105,8 +101,6 @@ def test_get_pypi_versions_all_prerelease():
105101 # No version → latest
106102 ("clang-format" , None , "22.1.5" ),
107103 ("clang-tidy" , None , "21.1.6" ),
108- ("clang-include-cleaner" , None , "22.1.7" ),
109- ("clang-apply-replacements" , None , "17.0.6" ),
110104 # Exact match
111105 ("clang-format" , "20.1.8" , "20.1.8" ),
112106 ("clang-tidy" , "19.1.0.1" , "19.1.0.1" ),
@@ -115,8 +109,6 @@ def test_get_pypi_versions_all_prerelease():
115109 ("clang-format" , "20.1" , "20.1.8" ),
116110 ("clang-tidy" , "21" , "21.1.6" ),
117111 ("clang-tidy" , "21.1" , "21.1.6" ),
118- ("clang-include-cleaner" , "22" , "22.1.7" ),
119- ("clang-apply-replacements" , "16" , "16.0.0" ),
120112 ],
121113)
122114def test_resolve_version_from_pypi_success (tool , user_input , expected ):
@@ -136,8 +128,6 @@ def test_resolve_version_from_pypi_success(tool, user_input, expected):
136128 ("clang-format" , "20.99" ),
137129 ("clang-tidy" , "99" ),
138130 ("clang-tidy" , "22.99" ),
139- ("clang-include-cleaner" , "99" ),
140- ("clang-apply-replacements" , "99" ),
141131 ],
142132)
143133def test_resolve_version_from_pypi_not_found (tool , user_input ):
@@ -487,154 +477,3 @@ def test_resolve_install_with_diagnostics_verbose_latest(capsys):
487477 "Using latest clang-format Python wheel version 22.1.5"
488478 in capsys .readouterr ().err
489479 )
490-
491-
492- # ═══════════════════════════════════════════════════════════════════════
493- # New wheel tools
494- # ═══════════════════════════════════════════════════════════════════════
495-
496-
497- @pytest .mark .benchmark
498- def test_resolve_install_include_cleaner ():
499- mock_path = "/usr/bin/clang-include-cleaner"
500- with (
501- patch ("shutil.which" , return_value = None ),
502- patch (
503- "cpp_linter_hooks.util._install_tool" , return_value = Path (mock_path )
504- ) as mock_install ,
505- patch (
506- "cpp_linter_hooks.util._get_pypi_versions" , side_effect = _pypi_side_effect
507- ),
508- ):
509- result = resolve_install ("clang-include-cleaner" , "22.1.7" )
510- assert Path (result ) == Path (mock_path )
511- mock_install .assert_called_once_with ("clang-include-cleaner" , "22.1.7" )
512-
513-
514- @pytest .mark .benchmark
515- def test_resolve_install_include_cleaner_default ():
516- with (
517- patch ("shutil.which" , return_value = None ),
518- patch (
519- "cpp_linter_hooks.util._install_tool" ,
520- return_value = Path ("/usr/bin/clang-include-cleaner" ),
521- ) as mock_install ,
522- patch (
523- "cpp_linter_hooks.util._get_pypi_versions" , side_effect = _pypi_side_effect
524- ),
525- ):
526- result = resolve_install ("clang-include-cleaner" , None )
527- assert result == Path ("/usr/bin/clang-include-cleaner" )
528- mock_install .assert_called_once_with ("clang-include-cleaner" , "22.1.7" )
529-
530-
531- @pytest .mark .benchmark
532- def test_resolve_install_include_cleaner_invalid ():
533- with (
534- patch ("shutil.which" , return_value = None ),
535- patch ("cpp_linter_hooks.util._install_tool" ) as mock_install ,
536- patch (
537- "cpp_linter_hooks.util._get_pypi_versions" , side_effect = _pypi_side_effect
538- ),
539- ):
540- result = resolve_install ("clang-include-cleaner" , "99.0.0" )
541- assert result is None
542- mock_install .assert_not_called ()
543-
544-
545- @pytest .mark .benchmark
546- def test_resolve_install_apply_replacements ():
547- mock_path = "/usr/bin/clang-apply-replacements"
548- with (
549- patch ("shutil.which" , return_value = None ),
550- patch (
551- "cpp_linter_hooks.util._install_tool" , return_value = Path (mock_path )
552- ) as mock_install ,
553- patch (
554- "cpp_linter_hooks.util._get_pypi_versions" , side_effect = _pypi_side_effect
555- ),
556- ):
557- result = resolve_install ("clang-apply-replacements" , "17.0.6" )
558- assert Path (result ) == Path (mock_path )
559- mock_install .assert_called_once_with ("clang-apply-replacements" , "17.0.6" )
560-
561-
562- @pytest .mark .benchmark
563- def test_resolve_install_apply_replacements_default ():
564- with (
565- patch ("shutil.which" , return_value = None ),
566- patch (
567- "cpp_linter_hooks.util._install_tool" ,
568- return_value = Path ("/usr/bin/clang-apply-replacements" ),
569- ) as mock_install ,
570- patch (
571- "cpp_linter_hooks.util._get_pypi_versions" , side_effect = _pypi_side_effect
572- ),
573- ):
574- result = resolve_install ("clang-apply-replacements" , None )
575- assert result == Path ("/usr/bin/clang-apply-replacements" )
576- mock_install .assert_called_once_with ("clang-apply-replacements" , "17.0.6" )
577-
578-
579- @pytest .mark .benchmark
580- def test_resolve_install_apply_replacements_invalid ():
581- with (
582- patch ("shutil.which" , return_value = None ),
583- patch ("cpp_linter_hooks.util._install_tool" ) as mock_install ,
584- patch (
585- "cpp_linter_hooks.util._get_pypi_versions" , side_effect = _pypi_side_effect
586- ),
587- ):
588- result = resolve_install ("clang-apply-replacements" , "99.0.0" )
589- assert result is None
590- mock_install .assert_not_called ()
591-
592-
593- @pytest .mark .benchmark
594- def test_resolve_install_with_diagnostics_include_cleaner_invalid ():
595- with patch (
596- "cpp_linter_hooks.util._get_pypi_versions" , side_effect = _pypi_side_effect
597- ):
598- path , error = resolve_install_with_diagnostics ("clang-include-cleaner" , "99" )
599-
600- assert path is None
601- assert error is not None
602- assert "Unsupported clang-include-cleaner version '99'" in error
603- assert "Latest stable version: 22.1.7" in error
604-
605-
606- @pytest .mark .benchmark
607- def test_resolve_install_with_diagnostics_apply_replacements_invalid ():
608- with patch (
609- "cpp_linter_hooks.util._get_pypi_versions" , side_effect = _pypi_side_effect
610- ):
611- path , error = resolve_install_with_diagnostics ("clang-apply-replacements" , "99" )
612-
613- assert path is None
614- assert error is not None
615- assert "Unsupported clang-apply-replacements version '99'" in error
616- assert "Latest stable version: 17.0.6" in error
617-
618-
619- @pytest .mark .benchmark
620- def test_resolve_install_with_diagnostics_include_cleaner_verbose (capsys ):
621- with (
622- patch ("shutil.which" , return_value = None ),
623- patch (
624- "cpp_linter_hooks.util._install_tool" ,
625- return_value = Path ("/usr/bin/clang-include-cleaner" ),
626- ),
627- patch (
628- "cpp_linter_hooks.util._get_pypi_versions" , side_effect = _pypi_side_effect
629- ),
630- ):
631- path , error = resolve_install_with_diagnostics (
632- "clang-include-cleaner" , "22" , True
633- )
634-
635- assert path == Path ("/usr/bin/clang-include-cleaner" )
636- assert error is None
637- assert (
638- "Resolved clang-include-cleaner --version=22 to Python wheel version 22.1.7"
639- in capsys .readouterr ().err
640- )
0 commit comments