OXIESEC PANEL
- Current Dir:
/
/
usr
/
local
/
lib
/
python3.6
/
dist-packages
/
numpy
/
distutils
/
tests
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
10/28/2024 05:59:26 AM
rwxr-xr-x
📄
__init__.py
0 bytes
10/28/2024 05:59:24 AM
rw-r--r--
📁
__pycache__
-
10/28/2024 05:59:26 AM
rwxr-xr-x
📄
test_exec_command.py
7.13 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_fcompiler.py
1.25 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_fcompiler_gnu.py
2.09 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_fcompiler_intel.py
1.03 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_fcompiler_nagfor.py
1.08 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_from_template.py
1.08 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_mingw32ccompiler.py
1.57 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_misc_util.py
3.14 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_npy_pkg_config.py
2.5 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_shell_utils.py
1.91 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_system_info.py
9.48 KB
10/28/2024 05:59:24 AM
rw-r--r--
Editing: test_shell_utils.py
Close
import pytest import subprocess import json import sys from numpy.distutils import _shell_utils argv_cases = [ [r'exe'], [r'path/exe'], [r'path\exe'], [r'\\server\path\exe'], [r'path to/exe'], [r'path to\exe'], [r'exe', '--flag'], [r'path/exe', '--flag'], [r'path\exe', '--flag'], [r'path to/exe', '--flag'], [r'path to\exe', '--flag'], # flags containing literal quotes in their name [r'path to/exe', '--flag-"quoted"'], [r'path to\exe', '--flag-"quoted"'], [r'path to/exe', '"--flag-quoted"'], [r'path to\exe', '"--flag-quoted"'], ] @pytest.fixture(params=[ _shell_utils.WindowsParser, _shell_utils.PosixParser ]) def Parser(request): return request.param @pytest.fixture def runner(Parser): if Parser != _shell_utils.NativeParser: pytest.skip('Unable to run with non-native parser') if Parser == _shell_utils.WindowsParser: return lambda cmd: subprocess.check_output(cmd) elif Parser == _shell_utils.PosixParser: # posix has no non-shell string parsing return lambda cmd: subprocess.check_output(cmd, shell=True) else: raise NotImplementedError @pytest.mark.parametrize('argv', argv_cases) def test_join_matches_subprocess(Parser, runner, argv): """ Test that join produces strings understood by subprocess """ # invoke python to return its arguments as json cmd = [ sys.executable, '-c', 'import json, sys; print(json.dumps(sys.argv[1:]))' ] joined = Parser.join(cmd + argv) json_out = runner(joined).decode() assert json.loads(json_out) == argv @pytest.mark.parametrize('argv', argv_cases) def test_roundtrip(Parser, argv): """ Test that split is the inverse operation of join """ try: joined = Parser.join(argv) assert argv == Parser.split(joined) except NotImplementedError: pytest.skip("Not implemented")