Skip to content

Commit

Permalink
- Changed the tests a little bit to get rid of the <1% chance of failure
Browse files Browse the repository at this point in the history
- Made tests faster
  • Loading branch information
agilbert1412 committed Aug 26, 2023
1 parent a82b4bc commit fa42f5d
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions worlds/stardew_valley/test/TestItemLink.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -21,19 +24,22 @@ 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):
options = {options.ExcludeGingerIsland.internal_name: options.ExcludeGingerIsland.option_true,
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
Expand All @@ -43,18 +49,21 @@ 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):
options = {options.ExcludeGingerIsland.internal_name: options.ExcludeGingerIsland.option_false,
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
Expand All @@ -64,17 +73,20 @@ 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):
options = {options.ExcludeGingerIsland.internal_name: options.ExcludeGingerIsland.option_true,
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
Expand All @@ -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)

0 comments on commit fa42f5d

Please sign in to comment.