Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests failing on macOS due to usage of os.startfile #147

Open
ABHISHEKSONI121 opened this issue Mar 19, 2024 · 0 comments
Open

Tests failing on macOS due to usage of os.startfile #147

ABHISHEKSONI121 opened this issue Mar 19, 2024 · 0 comments

Comments

@ABHISHEKSONI121
Copy link
Collaborator

ABHISHEKSONI121 commented Mar 19, 2024

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 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.

Screenshot 2024-03-19 at 1 20 15 AM

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])
        
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant