ganyariya / gym-md

MiniDungeons for OpenAI Gym
MIT License
3 stars 2 forks source link

`tests/envs/test_read_holmgard_gym.py` test fails on **linux** based filesystems #18

Closed LJArendse closed 2 years ago

LJArendse commented 2 years ago

Overview

The _tests/envs/test_read_holmgardgym.py test fails on linux based filesystems. This is because linux based filesystems are "file-name case-sensitive".

Most Unix-style operating systems are case sensitive, meaning that a file called File1.txt is entirely distinct from one called file1.txt, and both can happily exist in the same folder (see source).

Mac OS X, like the classic Mac OS before it, is not case sensitive; it doesn't care whether you said File1.txt or file1.txt. (see source).

Windows file system treats file and directory names as case-insensitive. FOO.txt and foo.txt will be treated as equivalent files. Linux file system treats file and directory names as case-sensitive. FOO.txt and foo.txt will be treated as distinct files (see source).

The failing test error: FileNotFoundError: [Errno 2] No such file or directory: '/home/***/***/gym-md/gym_md/envs/props/holmgard_0.json' is expected since the file name holmgard_0.json is not the same as the actual file name Holmgard_0.json. Currently when the Setting(stage_name) object is created it takes in the _stagename which is used to load the respective .json props file. Thus if the _stagename is lowercase it will result in the lower-cased holmgard_0.json which results in the below error.

Failing test output

============================= test session starts ==============================
platform linux -- Python 3.8.10, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
rootdir: /home/***/***/gym-md
collected 20 items                                                             

tests/envs/test_change_rewards.py .                                      [  5%]
tests/envs/test_config.py ...                                            [ 20%]
tests/envs/test_grid.py .                                                [ 25%]
tests/envs/test_gym.py ..                                                [ 35%]
tests/envs/test_path.py ..                                               [ 45%]
tests/envs/test_random.py .                                              [ 50%]
tests/envs/test_read_holmgard_gym.py F..                                 [ 65%]
tests/envs/test_setting.py .                                             [ 70%]
tests/envs/agents/test_agent.py ......                                   [100%]

=================================== FAILURES ===================================
____________________________ test_read_holmgard_gym ____________________________

    def test_read_holmgard_gym() -> None:
        for i in range(11):
>           env: MdEnvBase = gym.make(f'md-holmgard_{i}-v0')

tests/envs/test_read_holmgard_gym.py:9: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../.local/share/virtualenvs/gym-md-axGU-N6U/lib/python3.8/site-packages/gym/envs/registration.py:235: in make
    return registry.make(id, **kwargs)
../../.local/share/virtualenvs/gym-md-axGU-N6U/lib/python3.8/site-packages/gym/envs/registration.py:129: in make
    env = spec.make(**kwargs)
../../.local/share/virtualenvs/gym-md-axGU-N6U/lib/python3.8/site-packages/gym/envs/registration.py:90: in make
    env = cls(**_kwargs)
gym_md/envs/md_env_list.py:132: in __init__
    super(Holmgard0MdEnv, self).__init__(stage_name=stage_name)
gym_md/envs/md_env.py:29: in __init__
    self.setting: Final[Setting] = Setting(self.stage_name)
gym_md/envs/setting.py:57: in __init__
    props_config = Setting.read_settings(stage_name)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

stage_name = 'holmgard_0'

    @staticmethod
    def read_settings(stage_name: str) -> PropsConfig:
        """Read setting corresponding to stage name.

        ステージ名にあった設定を読み込む
        Pydantic で読み込む

        Parameters
        ----------
        stage_name: str

        Returns
        -------
        PropsConfig

        """
        file_dir = path.dirname(__file__)
        json_path = path.join(file_dir, "props", f"{stage_name}.json")
>       with open(json_path, "r") as f:
E       FileNotFoundError: [Errno 2] No such file or directory: '/home/***/***/gym-md/gym_md/envs/props/holmgard_0.json'

gym_md/envs/setting.py:102: FileNotFoundError
=========================== short test summary info ============================
FAILED tests/envs/test_read_holmgard_gym.py::test_read_holmgard_gym - FileNot...
======================== 1 failed, 19 passed in 13.84s =========================

Possible solutions