Move partial reach into regular subtest, instead of sub-sub-test
Confuses Pycharm less when running "only failed tests"
This commit is contained in:
parent
ecbb52a70d
commit
e4619276c6
|
@ -1,11 +1,11 @@
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from BaseClasses import CollectionState
|
from BaseClasses import CollectionState, World
|
||||||
from Items import ItemFactory
|
from Items import ItemFactory
|
||||||
|
|
||||||
|
|
||||||
class TestBase(unittest.TestCase):
|
class TestBase(unittest.TestCase):
|
||||||
|
world: World
|
||||||
_state_cache = {}
|
_state_cache = {}
|
||||||
|
|
||||||
def get_state(self, items):
|
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)
|
self.assertEqual(self.world.get_location(location, 1).can_reach(state), access)
|
||||||
|
|
||||||
|
|
||||||
#check for partial solution
|
#check for partial solution
|
||||||
if not all_except and access:# we are not supposed to be able to reach location with partial inventory
|
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]:
|
for missing_item in item_pool[0]:
|
||||||
with self.subTest(msg="Location reachable without required item", location=location, items=item_pool[0],
|
with self.subTest(msg="Location reachable without required item", location=location,
|
||||||
all_except=all_except, missing_item=missing_item):
|
items=item_pool[0], missing_item=missing_item):
|
||||||
new_items = item_pool[0].copy()
|
new_items = item_pool[0].copy()
|
||||||
new_items.remove(missing_item)
|
new_items.remove(missing_item)
|
||||||
items = ItemFactory(new_items, 1)
|
items = ItemFactory(new_items, 1)
|
||||||
state = self.get_state(items)
|
state = self.get_state(items)
|
||||||
self.assertEqual(self.world.get_location(location, 1).can_reach(state), False)
|
self.assertEqual(self.world.get_location(location, 1).can_reach(state), False)
|
||||||
|
|
||||||
def run_entrance_tests(self, access_pool):
|
def run_entrance_tests(self, access_pool):
|
||||||
for entrance, access, *item_pool in 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)
|
self.assertEqual(self.world.get_entrance(entrance, 1).can_reach(state), access)
|
||||||
|
|
||||||
#check for partial solution
|
#check for partial solution
|
||||||
if not all_except and access:# we are not supposed to be able to reach location with partial inventory
|
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]:
|
for missing_item in item_pool[0]:
|
||||||
with self.subTest(msg="Entrance reachable without required item", entrance=entrance, items=item_pool[0],
|
with self.subTest(msg="Entrance reachable without required item", entrance=entrance,
|
||||||
all_except=all_except, missing_item=missing_item):
|
items=item_pool[0], missing_item=missing_item):
|
||||||
new_items = item_pool[0].copy()
|
new_items = item_pool[0].copy()
|
||||||
new_items.remove(missing_item)
|
new_items.remove(missing_item)
|
||||||
items = ItemFactory(new_items, 1)
|
items = ItemFactory(new_items, 1)
|
||||||
state = self.get_state(items)
|
state = self.get_state(items)
|
||||||
self.assertEqual(self.world.get_entrance(entrance, 1).can_reach(state), False)
|
self.assertEqual(self.world.get_entrance(entrance, 1).can_reach(state), False)
|
Loading…
Reference in New Issue