From e4619276c6ff23238877532e7a9b7528b12d265c Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Sat, 19 Dec 2020 21:13:35 +0100 Subject: [PATCH] Move partial reach into regular subtest, instead of sub-sub-test Confuses Pycharm less when running "only failed tests" --- test/TestBase.py | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/test/TestBase.py b/test/TestBase.py index 474285f2..060429b8 100644 --- a/test/TestBase.py +++ b/test/TestBase.py @@ -1,11 +1,11 @@ import unittest -from BaseClasses import CollectionState +from BaseClasses import CollectionState, World from Items import ItemFactory class TestBase(unittest.TestCase): - + world: World _state_cache = {} def get_state(self, items): @@ -35,16 +35,16 @@ class TestBase(unittest.TestCase): self.assertEqual(self.world.get_location(location, 1).can_reach(state), access) - #check for partial solution - if not all_except and access:# we are not supposed to be able to reach location with partial inventory - for missing_item in item_pool[0]: - with self.subTest(msg="Location reachable without required item", location=location, items=item_pool[0], - all_except=all_except, missing_item=missing_item): - new_items = item_pool[0].copy() - new_items.remove(missing_item) - items = ItemFactory(new_items, 1) - state = self.get_state(items) - self.assertEqual(self.world.get_location(location, 1).can_reach(state), False) + #check for partial solution + if not all_except and access:# we are not supposed to be able to reach location with partial inventory + for missing_item in item_pool[0]: + with self.subTest(msg="Location reachable without required item", location=location, + items=item_pool[0], missing_item=missing_item): + new_items = item_pool[0].copy() + new_items.remove(missing_item) + items = ItemFactory(new_items, 1) + state = self.get_state(items) + self.assertEqual(self.world.get_location(location, 1).can_reach(state), False) def run_entrance_tests(self, access_pool): for entrance, access, *item_pool in access_pool: @@ -61,13 +61,13 @@ class TestBase(unittest.TestCase): self.assertEqual(self.world.get_entrance(entrance, 1).can_reach(state), access) - #check for partial solution - if not all_except and access:# we are not supposed to be able to reach location with partial inventory - for missing_item in item_pool[0]: - with self.subTest(msg="Entrance reachable without required item", entrance=entrance, items=item_pool[0], - all_except=all_except, missing_item=missing_item): - new_items = item_pool[0].copy() - new_items.remove(missing_item) - items = ItemFactory(new_items, 1) - state = self.get_state(items) - self.assertEqual(self.world.get_entrance(entrance, 1).can_reach(state), False) \ No newline at end of file + #check for partial solution + if not all_except and access:# we are not supposed to be able to reach location with partial inventory + for missing_item in item_pool[0]: + with self.subTest(msg="Entrance reachable without required item", entrance=entrance, + items=item_pool[0], missing_item=missing_item): + new_items = item_pool[0].copy() + new_items.remove(missing_item) + items = ItemFactory(new_items, 1) + state = self.get_state(items) + self.assertEqual(self.world.get_entrance(entrance, 1).can_reach(state), False) \ No newline at end of file