Several unit tests are failing on macOS due to the usage of os.startfile, which is a Windows-specific function. The tests fail with an AttributeError: module 'os' has no attribute 'startfile'.
Affected Tests
The following tests are affected:
test_pyfepdf.py::test_mostrar_pdf
test_pyi25.py::test_main_mostrar
test_pyqr.py::test_main_mostrar
Suggested Fix
A possible fix is to create a platform-independent function that behaves like os.startfile on all platforms. On Windows, it can use os.startfile, and on macOS and Linux, it can use the open command via subprocess.call. This function can then be used to replace os.startfile during testing using mocker.patch.
Here's an example of how this function can look like:
def open_file(path):
if platform.system() == "Windows":
os.startfile(path)
else:
subprocess.call(["open", path])
Description
Several unit tests are failing on macOS due to the usage of
os.startfile
, which is a Windows-specific function. The tests fail with anAttributeError: module 'os' has no attribute 'startfile'
.Affected Tests
The following tests are affected:
test_pyfepdf.py::test_mostrar_pdf
test_pyi25.py::test_main_mostrar
test_pyqr.py::test_main_mostrar
Suggested Fix
A possible fix is to create a platform-independent function that behaves like
os.startfile
on all platforms. On Windows, it can useos.startfile
, and on macOS and Linux, it can use theopen
command viasubprocess.call
. This function can then be used to replaceos.startfile
during testing usingmocker.patch
.Here's an example of how this function can look like: