PyAr / pyafipws

Interfases, tools and apps for Argentina's gov't. webservices (soap, com/dll simil-ocx, pdf, dbf, xml, json, etc.) #python
https://github.com/PyAr/pyafipws/wiki/PyAr-PSF-GSoC-2019-Final-Summary
GNU Lesser General Public License v3.0
2 stars 15 forks source link

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

Open ABHISHEKSONI121 opened 8 months ago

ABHISHEKSONI121 commented 8 months ago

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:

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])