@@ -233,3 +233,54 @@ def test_language_versioned_python_hook(tmp_path):
233233 return_value = False ,
234234 ):
235235 assert run_language (tmp_path , python , 'myexe' ) == (0 , b'ohai\n ' )
236+
237+
238+ def _make_hello_hello (tmp_path ):
239+ setup_py = '''\
240+ from setuptools import setup
241+
242+ setup(
243+ name='socks',
244+ version='0.0.0',
245+ py_modules=['socks'],
246+ entry_points={'console_scripts': ['socks = socks:main']},
247+ )
248+ '''
249+
250+ main_py = '''\
251+ import sys
252+
253+ def main():
254+ print(repr(sys.argv[1:]))
255+ print('hello hello')
256+ return 0
257+ '''
258+ tmp_path .joinpath ('setup.py' ).write_text (setup_py )
259+ tmp_path .joinpath ('socks.py' ).write_text (main_py )
260+
261+
262+ def test_simple_python_hook (tmp_path ):
263+ _make_hello_hello (tmp_path )
264+
265+ ret = run_language (tmp_path , python , 'socks' , [os .devnull ])
266+ assert ret == (0 , f'[{ os .devnull !r} ]\n hello hello\n ' .encode ())
267+
268+
269+ def test_simple_python_hook_default_version (tmp_path ):
270+ # make sure that this continues to work for platforms where default
271+ # language detection does not work
272+ with mock .patch .object (
273+ python ,
274+ 'get_default_version' ,
275+ return_value = C .DEFAULT ,
276+ ):
277+ test_simple_python_hook (tmp_path )
278+
279+
280+ def test_python_hook_weird_setup_cfg (tmp_path ):
281+ _make_hello_hello (tmp_path )
282+ setup_cfg = '[install]\n install_scripts=/usr/sbin'
283+ tmp_path .joinpath ('setup.cfg' ).write_text (setup_cfg )
284+
285+ ret = run_language (tmp_path , python , 'socks' , [os .devnull ])
286+ assert ret == (0 , f'[{ os .devnull !r} ]\n hello hello\n ' .encode ())
0 commit comments