Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: extend the multipackage tests with nested resources
Extend the multipackage test to verify references to nested resources (data files and extensions) within the shared package in the multipackage mode. For nested extension, the psutil package is used (as it contains one). Refactor the test scripts to use a common test function from a package to avoid duplicating test code. The extended tests shows that multipackage currently does not properly handle resources that are collected in subdirectories of _MEIPASS instead of _MEIPASS itself.
- Loading branch information
Showing
20 changed files
with
97 additions
and
80 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
tests/functional/specs/multipackage-scripts/extra-hooks/hook-multipackage_test_pkg.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#----------------------------------------------------------------------------- | ||
# Copyright (c) 2021, PyInstaller Development Team. | ||
# | ||
# Distributed under the terms of the GNU General Public License (version 2 | ||
# or later) with exception for distributing the bootloader. | ||
# | ||
# The full license is in the file COPYING.txt, distributed with this software. | ||
# | ||
# SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception) | ||
#----------------------------------------------------------------------------- | ||
|
||
from PyInstaller.utils.hooks import collect_data_files | ||
datas = collect_data_files('multipackage_test_pkg') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
tests/functional/specs/multipackage-scripts/multipackage_test_pkg/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#----------------------------------------------------------------------------- | ||
# Copyright (c) 2021, PyInstaller Development Team. | ||
# | ||
# Distributed under the terms of the GNU General Public License (version 2 | ||
# or later) with exception for distributing the bootloader. | ||
# | ||
# The full license is in the file COPYING.txt, distributed with this software. | ||
# | ||
# SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception) | ||
#----------------------------------------------------------------------------- | ||
|
||
def _test_basic_imports(): | ||
# import a very simple and rarely used pure-python lib ... | ||
import getopt # noqa: F401 | ||
# ... and a module importing a shared lib | ||
import ssl # noqa: F401 | ||
|
||
print('Hello World!') | ||
|
||
|
||
def _test_nested_data_file(): | ||
# try reading secret from a file in sub-directory | ||
import os | ||
|
||
secret_file = os.path.join(__path__[0], 'data', 'secret.txt') | ||
print("Reading secret from %s..." % (secret_file)) | ||
with open(secret_file, 'r') as fp: | ||
secret = fp.read().strip() | ||
print("Secret: %s" % (secret)) | ||
|
||
assert secret == 'Secret1234' | ||
|
||
|
||
def _test_nested_extensions(): | ||
# import psutil, which contains an extension in its package directory | ||
import psutil # noqa: F401 | ||
print("Successfully imported psutil!") | ||
|
||
|
||
def test_function(): | ||
# Main test function | ||
_test_basic_imports() | ||
_test_nested_data_file() | ||
_test_nested_extensions() |
1 change: 1 addition & 0 deletions
1
tests/functional/specs/multipackage-scripts/multipackage_test_pkg/data/secret.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Secret1234 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters