Compile and run pyinstaller-smoke.py using PyInstaller.
(mode, tmp_path)
| 11 | @pytest.mark.parametrize("mode", ["--onedir", "--onefile"]) |
| 12 | @pytest.mark.slow |
| 13 | def test_pyinstaller(mode, tmp_path): |
| 14 | """Compile and run pyinstaller-smoke.py using PyInstaller.""" |
| 15 | |
| 16 | pyinstaller_cli = pytest.importorskip("PyInstaller.__main__").run |
| 17 | |
| 18 | source = Path(__file__).with_name("pyinstaller-smoke.py").resolve() |
| 19 | args = [ |
| 20 | # Place all generated files in ``tmp_path``. |
| 21 | '--workpath', str(tmp_path / "build"), |
| 22 | '--distpath', str(tmp_path / "dist"), |
| 23 | '--specpath', str(tmp_path), |
| 24 | mode, |
| 25 | str(source), |
| 26 | ] |
| 27 | pyinstaller_cli(args) |
| 28 | |
| 29 | if mode == "--onefile": |
| 30 | exe = tmp_path / "dist" / source.stem |
| 31 | else: |
| 32 | exe = tmp_path / "dist" / source.stem / source.stem |
| 33 | |
| 34 | p = subprocess.run([str(exe)], check=True, stdout=subprocess.PIPE) |
| 35 | assert p.stdout.strip() == b"I made it!" |