Skip to content

Commit d3c0a66

Browse files
committed
move slowest python-specific tests out of repository_test
1 parent 950451e commit d3c0a66

File tree

2 files changed

+51
-29
lines changed

2 files changed

+51
-29
lines changed

tests/languages/python_test.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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}]\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())

tests/repository_test.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -82,35 +82,6 @@ def _test_hook_repo(
8282
assert out == expected
8383

8484

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-
11485
def test_python_venv_deprecation(store, caplog):
11586
config = {
11687
'repo': 'local',

0 commit comments

Comments
 (0)