@@ -942,3 +942,49 @@ def test_dotnet_hook(tempdir_factory, store, repo):
942942 tempdir_factory , store , repo ,
943943 'dotnet example hook' , [], b'Hello from dotnet!\n ' ,
944944 )
945+
946+
947+ def test_non_installable_hook_error_for_language_version (store , caplog ):
948+ config = {
949+ 'repo' : 'local' ,
950+ 'hooks' : [{
951+ 'id' : 'system-hook' ,
952+ 'name' : 'system-hook' ,
953+ 'language' : 'system' ,
954+ 'entry' : 'python3 -c "import sys; print(sys.version)"' ,
955+ 'language_version' : 'python3.10' ,
956+ }],
957+ }
958+ with pytest .raises (SystemExit ) as excinfo :
959+ _get_hook (config , store , 'system-hook' )
960+ assert excinfo .value .code == 1
961+
962+ msg , = caplog .messages
963+ assert msg == (
964+ 'The hook `system-hook` specifies `language_version` but is using '
965+ 'language `system` which does not install an environment. '
966+ 'Perhaps you meant to use a specific language?'
967+ )
968+
969+
970+ def test_non_installable_hook_error_for_additional_dependencies (store , caplog ):
971+ config = {
972+ 'repo' : 'local' ,
973+ 'hooks' : [{
974+ 'id' : 'system-hook' ,
975+ 'name' : 'system-hook' ,
976+ 'language' : 'system' ,
977+ 'entry' : 'python3 -c "import sys; print(sys.version)"' ,
978+ 'additional_dependencies' : ['astpretty' ],
979+ }],
980+ }
981+ with pytest .raises (SystemExit ) as excinfo :
982+ _get_hook (config , store , 'system-hook' )
983+ assert excinfo .value .code == 1
984+
985+ msg , = caplog .messages
986+ assert msg == (
987+ 'The hook `system-hook` specifies `additional_dependencies` but is '
988+ 'using language `system` which does not install an environment. '
989+ 'Perhaps you meant to use a specific language?'
990+ )
0 commit comments