From fa42f5d082e9b184d80b2ac6b4f354c52e970866 Mon Sep 17 00:00:00 2001 From: Alex Gilbert Date: Sat, 26 Aug 2023 15:30:03 -0400 Subject: [PATCH] - Changed the tests a little bit to get rid of the <1% chance of failure - Made tests faster --- worlds/stardew_valley/test/TestItemLink.py | 30 ++++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/worlds/stardew_valley/test/TestItemLink.py b/worlds/stardew_valley/test/TestItemLink.py index 867f1d12308e..f55ab8ca347d 100644 --- a/worlds/stardew_valley/test/TestItemLink.py +++ b/worlds/stardew_valley/test/TestItemLink.py @@ -1,16 +1,19 @@ from . import SVTestBase from .. import options, item_table, Group +max_iterations = 2000 + class TestItemLinksEverythingIncluded(SVTestBase): options = {options.ExcludeGingerIsland.internal_name: options.ExcludeGingerIsland.option_false, options.TrapItems.internal_name: options.TrapItems.option_medium} def test_filler_of_all_types_generated(self): + max_number_filler = 115 filler_generated = [] at_least_one_trap = False at_least_one_island = False - for i in range(0, 1000): + for i in range(0, max_iterations): filler = self.multiworld.worlds[1].get_filler_item_name() if filler in filler_generated: continue @@ -21,9 +24,11 @@ def test_filler_of_all_types_generated(self): at_least_one_trap = True if Group.GINGER_ISLAND in item_table[filler].groups: at_least_one_island = True + if len(filler_generated) >= max_number_filler: + break self.assertTrue(at_least_one_trap) self.assertTrue(at_least_one_island) - self.assertGreaterEqual(len(filler_generated), 115) + self.assertGreaterEqual(len(filler_generated), max_number_filler) class TestItemLinksNoIsland(SVTestBase): @@ -31,9 +36,10 @@ class TestItemLinksNoIsland(SVTestBase): options.TrapItems.internal_name: options.TrapItems.option_medium} def test_filler_has_no_island_but_has_traps(self): + max_number_filler = 109 filler_generated = [] at_least_one_trap = False - for i in range(0, 1000): + for i in range(0, max_iterations): filler = self.multiworld.worlds[1].get_filler_item_name() if filler in filler_generated: continue @@ -43,8 +49,10 @@ def test_filler_has_no_island_but_has_traps(self): self.assertNotIn(Group.EXACTLY_TWO, item_table[filler].groups) if Group.TRAP in item_table[filler].groups: at_least_one_trap = True + if len(filler_generated) >= max_number_filler: + break self.assertTrue(at_least_one_trap) - self.assertGreaterEqual(len(filler_generated), 50) + self.assertGreaterEqual(len(filler_generated), max_number_filler) class TestItemLinksNoTraps(SVTestBase): @@ -52,9 +60,10 @@ class TestItemLinksNoTraps(SVTestBase): options.TrapItems.internal_name: options.TrapItems.option_no_traps} def test_filler_has_no_traps_but_has_island(self): + max_number_filler = 100 filler_generated = [] at_least_one_island = False - for i in range(0, 1000): + for i in range(0, max_iterations): filler = self.multiworld.worlds[1].get_filler_item_name() if filler in filler_generated: continue @@ -64,8 +73,10 @@ def test_filler_has_no_traps_but_has_island(self): self.assertNotIn(Group.EXACTLY_TWO, item_table[filler].groups) if Group.GINGER_ISLAND in item_table[filler].groups: at_least_one_island = True + if len(filler_generated) >= max_number_filler: + break self.assertTrue(at_least_one_island) - self.assertGreaterEqual(len(filler_generated), 50) + self.assertGreaterEqual(len(filler_generated), max_number_filler) class TestItemLinksNoTrapsAndIsland(SVTestBase): @@ -73,8 +84,9 @@ class TestItemLinksNoTrapsAndIsland(SVTestBase): options.TrapItems.internal_name: options.TrapItems.option_no_traps} def test_filler_generated_without_island_or_traps(self): + max_number_filler = 94 filler_generated = [] - for i in range(0, 1000): + for i in range(0, max_iterations): filler = self.multiworld.worlds[1].get_filler_item_name() if filler in filler_generated: continue @@ -83,4 +95,6 @@ def test_filler_generated_without_island_or_traps(self): self.assertNotIn(Group.TRAP, item_table[filler].groups) self.assertNotIn(Group.MAXIMUM_ONE, item_table[filler].groups) self.assertNotIn(Group.EXACTLY_TWO, item_table[filler].groups) - self.assertGreaterEqual(len(filler_generated), 50) + if len(filler_generated) >= max_number_filler: + break + self.assertGreaterEqual(len(filler_generated), max_number_filler)