Skip to content
New issue

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

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

Already on GitHub? # to your account

Error running tests.sh on Ubuntu 20.04.06 LTS #5

Open
hbonnavaud opened this issue Aug 28, 2023 · 1 comment
Open

Error running tests.sh on Ubuntu 20.04.06 LTS #5

hbonnavaud opened this issue Aug 28, 2023 · 1 comment

Comments

@hbonnavaud
Copy link

hbonnavaud commented Aug 28, 2023

While running test I have two tests failure :
============================================================================= short test summary info =============================================================================
FAILED tests/test_mazeexplorer.py::test_generate_video - FileNotFoundError: The directory '/tmp/pytest-of-user/pytest-22/test_generate_video0/record' does not exist
FAILED tests/test_mazeexplorer.py::test_generate_with_seed - assert 1 == 10

I investigate the first error and found the reason, in MazeExplorer/mazeexplorer/mazeexplorer.py line 85 and 86:
shutil.rmtree(self.mazes_path, ignore_errors=True)
os.mkdir(self.mazes_path)

In the test called "tests/test_mazeexplorer.py::test_generate_video", at these lines self.mazes_path = '/tmp/pytest-of-user/pytest-22/test_generate_video0/'. Before to create the env, the sub directory 'record' is created :
test_mazeexplorer.py lines 58/59
record_path = tmpdir.mkdir("record")
env = MazeExplorer(mazes_path=tmpdir.strpath)

But calling "shutil.rmtree" on tmpdir.strpath then re-create "tmpdir.strpath" in the MazeExplorer class obviously remove the previously created sub directory 'record', so trying to store a video inside it raise an error.

I don't goes deeper in the second one ...

Are these tests important to use the code ? Can you fix it in the repository ? Because I don't think the first one can pass on any machine...

@hbonnavaud
Copy link
Author

hbonnavaud commented Aug 28, 2023

For test 2, I solved it by adding "number_maps=" before the "10" in each MazeExplorer init call
Before:

def test_generate_with_seed(tmpdir):
    env = MazeExplorer(10, seed=5, mazes_path=tmpdir.mkdir("maze_1").strpath)
    assert len(set(env.mazes)) == 10

    same_env = MazeExplorer(10, seed=5, mazes_path=tmpdir.mkdir("maze_2").strpath)
    assert set(env.mazes) == set(same_env.mazes)

    different_env = MazeExplorer(10, seed=42, mazes_path=tmpdir.mkdir("maze_3").strpath)
    assert len(set(env.mazes) - set(different_env.mazes)) == 10

Then:

def test_generate_with_seed(tmpdir):
    env = MazeExplorer(number_maps=10, seed=5, mazes_path=tmpdir.mkdir("maze_1").strpath)
    assert len(set(env.mazes)) == 10

    same_env = MazeExplorer(number_maps=10, seed=5, mazes_path=tmpdir.mkdir("maze_2").strpath)
    assert set(env.mazes) == set(same_env.mazes)

    different_env = MazeExplorer(number_maps=10, seed=42, mazes_path=tmpdir.mkdir("maze_3").strpath)
    assert len(set(env.mazes) - set(different_env.mazes)) == 10

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant