Stardew Valley: Use classvar_matrix to split tests (#4762)
* Unroll tests for better parallelization * fix ut test * self review * bro it's the second time today I have to commit some garbage to have a github action rerun because messenger fails what is this * my god can the tests plz pass * code reviews * code reviews * move TestRandomWorlds out of long module
This commit is contained in:
@@ -1,61 +1,19 @@
|
||||
import unittest
|
||||
from itertools import combinations, product
|
||||
from itertools import combinations
|
||||
from typing import ClassVar
|
||||
|
||||
from BaseClasses import get_seed
|
||||
from .option_names import all_option_choices, get_option_choices
|
||||
from .. import SVTestCase
|
||||
from test.param import classvar_matrix
|
||||
from .. import SVTestCase, solo_multiworld, skip_long_tests
|
||||
from ..assertion import WorldAssertMixin, ModAssertMixin
|
||||
from ..options.option_names import all_option_choices
|
||||
from ... import options
|
||||
from ...mods.mod_data import ModNames
|
||||
|
||||
assert unittest
|
||||
from ...options.options import all_mods
|
||||
|
||||
|
||||
class TestGenerateModsOptions(WorldAssertMixin, ModAssertMixin, SVTestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls) -> None:
|
||||
super().setUpClass()
|
||||
if cls.skip_long_tests:
|
||||
raise unittest.SkipTest("Long tests disabled")
|
||||
|
||||
def test_given_mod_pairs_when_generate_then_basic_checks(self):
|
||||
for mod_pair in combinations(options.Mods.valid_keys, 2):
|
||||
world_options = {
|
||||
options.Mods: frozenset(mod_pair)
|
||||
}
|
||||
|
||||
with self.solo_world_sub_test(f"Mods: {mod_pair}", world_options, world_caching=False) as (multiworld, _):
|
||||
self.assert_basic_checks(multiworld)
|
||||
self.assert_stray_mod_items(list(mod_pair), multiworld)
|
||||
|
||||
def test_given_mod_names_when_generate_paired_with_other_options_then_basic_checks(self):
|
||||
for mod, (option, value) in product(options.Mods.valid_keys, all_option_choices):
|
||||
world_options = {
|
||||
option: value,
|
||||
options.Mods: mod
|
||||
}
|
||||
|
||||
with self.solo_world_sub_test(f"{option.internal_name}: {value}, Mod: {mod}", world_options, world_caching=False) as (multiworld, _):
|
||||
self.assert_basic_checks(multiworld)
|
||||
self.assert_stray_mod_items(mod, multiworld)
|
||||
|
||||
def test_given_no_quest_all_mods_when_generate_with_all_goals_then_basic_checks(self):
|
||||
for goal, (option, value) in product(get_option_choices(options.Goal), all_option_choices):
|
||||
if option is options.QuestLocations:
|
||||
continue
|
||||
|
||||
world_options = {
|
||||
options.Goal: goal,
|
||||
option: value,
|
||||
options.QuestLocations: -1,
|
||||
options.Mods: frozenset(options.Mods.valid_keys),
|
||||
}
|
||||
|
||||
with self.solo_world_sub_test(f"Goal: {goal}, {option.internal_name}: {value}", world_options, world_caching=False) as (multiworld, _):
|
||||
self.assert_basic_checks(multiworld)
|
||||
|
||||
@unittest.skip
|
||||
@unittest.skip
|
||||
class TestTroubleshootMods(WorldAssertMixin, ModAssertMixin, SVTestCase):
|
||||
def test_troubleshoot_option(self):
|
||||
seed = get_seed(78709133382876990000)
|
||||
|
||||
@@ -67,3 +25,60 @@ class TestGenerateModsOptions(WorldAssertMixin, ModAssertMixin, SVTestCase):
|
||||
with self.solo_world_sub_test(world_options=world_options, seed=seed, world_caching=False) as (multiworld, _):
|
||||
self.assert_basic_checks(multiworld)
|
||||
self.assert_stray_mod_items(world_options[options.Mods], multiworld)
|
||||
|
||||
|
||||
if skip_long_tests():
|
||||
raise unittest.SkipTest("Long tests disabled")
|
||||
|
||||
|
||||
@classvar_matrix(mod_pair=combinations(sorted(all_mods), 2))
|
||||
class TestGenerateModsPairs(WorldAssertMixin, ModAssertMixin, SVTestCase):
|
||||
mod_pair: ClassVar[tuple[str, str]]
|
||||
|
||||
def test_given_mod_pairs_when_generate_then_basic_checks(self):
|
||||
world_options = {
|
||||
options.Mods.internal_name: frozenset(self.mod_pair)
|
||||
}
|
||||
|
||||
with solo_multiworld(world_options, world_caching=False) as (multiworld, _):
|
||||
self.assert_basic_checks(multiworld)
|
||||
self.assert_stray_mod_items(list(self.mod_pair), multiworld)
|
||||
|
||||
|
||||
@classvar_matrix(mod=all_mods, option_and_choice=all_option_choices)
|
||||
class TestGenerateModAndOptionChoice(WorldAssertMixin, ModAssertMixin, SVTestCase):
|
||||
mod: ClassVar[str]
|
||||
option_and_choice: ClassVar[tuple[str, str]]
|
||||
|
||||
def test_given_mod_names_when_generate_paired_with_other_options_then_basic_checks(self):
|
||||
option, choice = self.option_and_choice
|
||||
|
||||
world_options = {
|
||||
option: choice,
|
||||
options.Mods.internal_name: self.mod
|
||||
}
|
||||
|
||||
with solo_multiworld(world_options, world_caching=False) as (multiworld, _):
|
||||
self.assert_basic_checks(multiworld)
|
||||
self.assert_stray_mod_items(self.mod, multiworld)
|
||||
|
||||
|
||||
@classvar_matrix(goal=options.Goal.options.keys(), option_and_choice=all_option_choices)
|
||||
class TestGenerateAllGoalAndAllOptionWithAllModsWithoutQuest(WorldAssertMixin, ModAssertMixin, SVTestCase):
|
||||
goal = ClassVar[str]
|
||||
option_and_choice = ClassVar[tuple[str, str]]
|
||||
|
||||
def test_given_no_quest_all_mods_when_generate_with_all_goals_then_basic_checks(self):
|
||||
option, choice = self.option_and_choice
|
||||
if option == options.QuestLocations.internal_name:
|
||||
self.skipTest("QuestLocations are disabled")
|
||||
|
||||
world_options = {
|
||||
options.Goal.internal_name: self.goal,
|
||||
option: choice,
|
||||
options.QuestLocations.internal_name: -1,
|
||||
options.Mods.internal_name: frozenset(options.Mods.valid_keys),
|
||||
}
|
||||
|
||||
with solo_multiworld(world_options, world_caching=False) as (multiworld, _):
|
||||
self.assert_basic_checks(multiworld)
|
||||
|
||||
Reference in New Issue
Block a user