From 481bf3e71c089c3ae4fefc1c214238ac561ca9eb Mon Sep 17 00:00:00 2001 From: Darren Eberly Date: Sun, 26 Feb 2023 23:26:27 -0500 Subject: [PATCH] Actually fix world tests --- tests/test_world.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_world.py b/tests/test_world.py index 09024e5..1bed981 100644 --- a/tests/test_world.py +++ b/tests/test_world.py @@ -1,5 +1,6 @@ """Tests for worlds""" import importlib.util +import operator import os from pathlib import Path @@ -18,6 +19,10 @@ ALL_WORLD_TESTS = [ ] +def fix_world(world): + world.maps.sort(key=operator.attrgetter("map_file")) + + @pytest.mark.parametrize("world_test", ALL_WORLD_TESTS) def test_world_integration(world_test): # it's a PITA to import like this, don't do it @@ -32,4 +37,11 @@ def test_world_integration(world_test): casted_world = world.parse_world(raw_world_path) + # These fix calls sort the map list in the world by the map_file + # attribute because we don't actually care about the order of the list + # and it can vary between runs, but pytest will fail if it is + # not in the same order. + fix_world(casted_world) + fix_world(expected.EXPECTED) + assert casted_world == expected.EXPECTED