Skip to content

Commit

Permalink
some code review change
Browse files Browse the repository at this point in the history
  • Loading branch information
Jouramie committed Mar 18, 2024
1 parent 68462a6 commit 58ae787
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 4 additions & 4 deletions worlds/stardew_valley/stardew_rule/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,13 +435,13 @@ def get_difficulty(self):

def __str__(self):
if self.item not in self.other_rules:
return f"Has {self.item} {self.group} -> {MISSING_ITEM}"
return f"Has {self.item} {self.group}"
return f"Has {self.item} ({self.group}) -> {MISSING_ITEM}"
return f"Has {self.item} ({self.group})"

def __repr__(self):
if self.item not in self.other_rules:
return f"Has {self.item} {self.group} -> {MISSING_ITEM}"
return f"Has {self.item} {self.group} -> {repr(self.other_rules[self.item])}"
return f"Has {self.item} ({self.group}) -> {MISSING_ITEM}"
return f"Has {self.item} ({self.group}) -> {repr(self.other_rules[self.item])}"


class RepeatableChain(Iterable, Sized):
Expand Down
8 changes: 6 additions & 2 deletions worlds/stardew_valley/test/stability/TestStability.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
from BaseClasses import get_seed
from .. import SVTestCase

# There seems to be 4 bytes that appear at random at the end of the output, breaking the json... I don't know where they came from.
BYTES_TO_REMOVE = 4

# <function Location.<lambda> at 0x102ca98a0>
lambda_regex = re.compile(r"^<function Location\.<lambda> at (.*)>$")
# Python 3.10.2\r\n
Expand All @@ -26,8 +29,9 @@ def test_all_locations_and_items_are_the_same_between_two_generations(self):
output_a = subprocess.check_output([sys.executable, '-m', 'worlds.stardew_valley.test.stability.StabilityOutputScript', '--seed', str(seed)])
output_b = subprocess.check_output([sys.executable, '-m', 'worlds.stardew_valley.test.stability.StabilityOutputScript', '--seed', str(seed)])

result_a = json.loads(output_a[:-4])
result_b = json.loads(output_b[:-4])
#
result_a = json.loads(output_a[:-BYTES_TO_REMOVE])
result_b = json.loads(output_b[:-BYTES_TO_REMOVE])

for i, ((room_a, bundles_a), (room_b, bundles_b)) in enumerate(zip(result_a["bundles"].items(), result_b["bundles"].items())):
self.assertEqual(room_a, room_b, f"Bundle rooms at index {i} is different between both executions. Seed={seed}")
Expand Down

0 comments on commit 58ae787

Please sign in to comment.