| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -233,3 +233,54 @@ def test_language_versioned_python_hook(tmp_path): | |||
| 233 | 233 | return_value=False, | |
| 234 | 234 | ): | |
| 235 | 235 | 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}]\nhello 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]\ninstall_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}]\nhello hello\n'.encode()) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -82,35 +82,6 @@ def _test_hook_repo( | |||
| 82 | 82 | assert out == expected | |
| 83 | 83 | ||
| 84 | 84 | ||
| 85 | - def test_python_hook(tempdir_factory, store): | ||
| 86 | - _test_hook_repo( | ||
| 87 | - tempdir_factory, store, 'python_hooks_repo', | ||
| 88 | - 'foo', [os.devnull], | ||
| 89 | - f'[{os.devnull!r}]\nHello World\n'.encode(), | ||
| 90 | - ) | ||
| 91 | - | ||
| 92 | - | ||
| 93 | - def test_python_hook_default_version(tempdir_factory, store): | ||
| 94 | - # make sure that this continues to work for platforms where default | ||
| 95 | - # language detection does not work | ||
| 96 | - with mock.patch.object( | ||
| 97 | - python, | ||
| 98 | - 'get_default_version', | ||
| 99 | - return_value=C.DEFAULT, | ||
| 100 | - ): | ||
| 101 | - test_python_hook(tempdir_factory, store) | ||
| 102 | - | ||
| 103 | - | ||
| 104 | - def test_python_hook_weird_setup_cfg(in_git_dir, tempdir_factory, store): | ||
| 105 | - in_git_dir.join('setup.cfg').write('[install]\ninstall_scripts=/usr/sbin') | ||
| 106 | - | ||
| 107 | - _test_hook_repo( | ||
| 108 | - tempdir_factory, store, 'python_hooks_repo', | ||
| 109 | - 'foo', [os.devnull], | ||
| 110 | - f'[{os.devnull!r}]\nHello World\n'.encode(), | ||
| 111 | - ) | ||
| 112 | - | ||
| 113 | - | ||
| 114 | 85 | def test_python_venv_deprecation(store, caplog): | |
| 115 | 86 | config = { | |
| 116 | 87 | 'repo': 'local', | |
| Back | FazBrowse Home | New Git URL |
0 commit comments