@@ -82,6 +82,21 @@ def test_failed_setup_command_does_not_unicode_error():
8282 lang_base .setup_cmd (Prefix ('.' ), (sys .executable , '-c' , script ))
8383
8484
85+ def test_environment_dir (tmp_path ):
86+ ret = lang_base .environment_dir (Prefix (tmp_path ), 'langenv' , 'default' )
87+ assert ret == f'{ tmp_path } { os .sep } langenv-default'
88+
89+
90+ def test_assert_version_default ():
91+ with pytest .raises (AssertionError ) as excinfo :
92+ lang_base .assert_version_default ('lang' , '1.2.3' )
93+ msg , = excinfo .value .args
94+ assert msg == (
95+ 'for now, pre-commit requires system-installed lang -- '
96+ 'you selected `language_version: 1.2.3`'
97+ )
98+
99+
85100def test_assert_no_additional_deps ():
86101 with pytest .raises (AssertionError ) as excinfo :
87102 lang_base .assert_no_additional_deps ('lang' , ['hmmm' ])
@@ -93,6 +108,14 @@ def test_assert_no_additional_deps():
93108 )
94109
95110
111+ def test_no_env_noop (tmp_path ):
112+ before = os .environ .copy ()
113+ with lang_base .no_env (Prefix (tmp_path ), '1.2.3' ):
114+ inside = os .environ .copy ()
115+ after = os .environ .copy ()
116+ assert before == inside == after
117+
118+
96119def test_target_concurrency_normal ():
97120 with mock .patch .object (multiprocessing , 'cpu_count' , return_value = 123 ):
98121 with mock .patch .dict (os .environ , {}, clear = True ):
@@ -133,3 +156,18 @@ def test_xargs_require_serial_is_not_shuffled():
133156 )
134157 assert ret == 0
135158 assert out .strip () == b'0 1 2 3 4 5 6 7 8 9'
159+
160+
161+ def test_basic_run_hook (tmp_path ):
162+ ret , out = lang_base .basic_run_hook (
163+ Prefix (tmp_path ),
164+ 'echo hi' ,
165+ ['hello' ],
166+ ['file' , 'file' , 'file' ],
167+ is_local = False ,
168+ require_serial = False ,
169+ color = False ,
170+ )
171+ assert ret == 0
172+ out = out .replace (b'\r \n ' , b'\n ' )
173+ assert out == b'hi hello file file file\n '
0 commit comments