| 1 |
""" |
| 2 |
PyTest testcases for the pyinstaller hook |
| 3 |
|
| 4 |
Instructions to run these tests: |
| 5 |
|
| 6 |
- Install PyInstaller with the hook_testing extra requirements: |
| 7 |
> pip install pyinstaller[hook_testing] |
| 8 |
|
| 9 |
- Run the tests using the provided utility by pyinstaller: |
| 10 |
> python -m PyInstaller.utils.run_tests --include_only usb1 |
| 11 |
|
| 12 |
""" |
| 13 |
|
| 14 |
import subprocess |
| 15 |
|
| 16 |
from PyInstaller import __main__ as pyi_main |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
def test_pyi_hooksample(tmp_path): |
| 21 |
app_name = "userapp" |
| 22 |
workpath = tmp_path / "build" |
| 23 |
distpath = tmp_path / "dist" |
| 24 |
app = tmp_path / (app_name + ".py") |
| 25 |
app.write_text("\n".join([ |
| 26 |
"import usb1", |
| 27 |
"print(usb1.getVersion())" |
| 28 |
])) |
| 29 |
args = [ |
| 30 |
|
| 31 |
'--workpath', str(workpath), |
| 32 |
'--distpath', str(distpath), |
| 33 |
'--specpath', str(tmp_path), |
| 34 |
str(app), |
| 35 |
] |
| 36 |
pyi_main.run(args) |
| 37 |
subprocess.run([str(distpath / app_name / app_name)], check=True) |