paireks / dotbimpy

Python library for dotbim.
MIT License
45 stars 6 forks source link

Unit test fails on Linux due to hardcoded path separator `\` #10

Open krzysztofarendt opened 4 months ago

krzysztofarendt commented 4 months ago

Unit test fail on Linux due to hardcoded path separator \.

Input:

cd dotbimpy/tests/unittests/
pytest .

Output:

============================================================================================== test session starts ==============================================================================================
platform linux -- Python 3.10.12, pytest-8.2.1, pluggy-1.5.0
rootdir: /home/krza/code/dotbimpy
collected 94 items                                                                                                                                                                                              

test_color.py ........                                                                                                                                                                                    [  8%]
test_element.py ..................................                                                                                                                                                        [ 44%]
test_file.py .....................F...                                                                                                                                                                    [ 71%]
test_mesh.py .............                                                                                                                                                                                [ 85%]
test_rotation.py .......                                                                                                                                                                                  [ 92%]
test_vector.py .......                                                                                                                                                                                    [100%]

=================================================================================================== FAILURES ====================================================================================================
___________________________________________________________________________________________ test_create_plotly_figure ___________________________________________________________________________________________

    def test_create_plotly_figure():
>       bim_file = File.read(os.path.join(os.path.dirname(os.path.realpath(__file__)), "test_files\\MultipleMeshes.bim"))

test_file.py:383: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

path = '/home/krza/code/dotbimpy/dotbimpy/tests/unittests/test_files\\MultipleMeshes.bim'

    @staticmethod
    def read(path):
        if path[-4:] != ".bim":
            raise Exception("Path should end up with .bim extension")

>       with open(path, "r") as bim_file:
E       FileNotFoundError: [Errno 2] No such file or directory: '/home/krza/code/dotbimpy/dotbimpy/tests/unittests/test_files\\MultipleMeshes.bim'

../../file.py:94: FileNotFoundError
============================================================================================ short test summary info ============================================================================================
FAILED test_file.py::test_create_plotly_figure - FileNotFoundError: [Errno 2] No such file or directory: '/home/krza/code/dotbimpy/dotbimpy/tests/unittests/test_files\\MultipleMeshes.bim'
========================================================================================= 1 failed, 93 passed in 5.15s ==========================================================================================