()
| 49 | |
| 50 | @pytest.mark.e2e |
| 51 | def test_apip(): |
| 52 | # Test package taken from pip tests |
| 53 | # https://github.com/pypa/pip/tree/master/tests/data/packages |
| 54 | whl = Path(__file__).parent /'files' / 'simplewheel-1.0-py2.py3-none-any.whl' |
| 55 | |
| 56 | venv_dir = tempfile.mkdtemp(suffix="_pytest_aura_apip") |
| 57 | # print(f'Virtualenv created in {venv_dir}') |
| 58 | try: |
| 59 | # Create virtualenv |
| 60 | venv.create( |
| 61 | env_dir=venv_dir, |
| 62 | with_pip=True, |
| 63 | symlinks=True |
| 64 | ) |
| 65 | # Install apip |
| 66 | shutil.copy( |
| 67 | Path(__file__).parent.parent / 'aura' / 'apip.py', |
| 68 | f'{venv_dir}/bin/apip' |
| 69 | ) |
| 70 | |
| 71 | assert os.access(f'{venv_dir}/bin/apip', os.X_OK) is True |
| 72 | |
| 73 | stdout, ret = run_in_venv(venv_dir, ['which apip']) |
| 74 | assert stdout.startswith(venv_dir), stdout |
| 75 | |
| 76 | # Installation should fail/abort |
| 77 | stdout, ret = run_in_venv( |
| 78 | venv_dir, |
| 79 | [f'{venv_dir}/bin/apip install {whl}'], |
| 80 | # We can't use just "exit 1" here because that's a built-in shell command |
| 81 | aura_path='python -c "import sys;sys.exit(1)"' |
| 82 | ) |
| 83 | # print(stdout) |
| 84 | assert ret > 0, stdout |
| 85 | stdout, _ = run_in_venv(venv_dir, [f'{venv_dir}/bin/apip freeze']) |
| 86 | assert not stdout.strip(), stdout |
| 87 | |
| 88 | # Installation should proceed correctly in this case |
| 89 | stdout, _ = run_in_venv( |
| 90 | venv_dir, |
| 91 | [f'{venv_dir}/bin/apip install {whl}'], |
| 92 | aura_path='python -c "import sys;sys.exit(0)"' |
| 93 | ) |
| 94 | # print(stdout) |
| 95 | |
| 96 | stdout, _ = run_in_venv(venv_dir, [f'{venv_dir}/bin/apip freeze']) |
| 97 | # print(stdout) |
| 98 | assert 'simplewheel' in stdout, stdout |
| 99 | assert 'Flask' not in stdout, stdout |
| 100 | finally: |
| 101 | shutil.rmtree(venv_dir) |
| 102 | |
| 103 | |
| 104 | if __name__ == '__main__': |
no test coverage detected