Cockpit-Tischansicht: ein String-Eintrag im Schatten riss die ganze Ansicht leer (Spieler/Profit weg)
reads_je_sitz rief .get() auf antwort/anfrage ohne Typpruefung; war einer davon ein String (statt Dict), warf es AttributeError -> sitzen-Bereich 'nicht lesbar' -> keine Tische, keine Spieler, kein Profit im Cockpit. Jetzt uebersprungen wie alle anderen Schatten-Schleifen. Spec: tests/gegner_spec.py (2 Waechter).
This commit is contained in:
+4
-2
@@ -40,10 +40,12 @@ def reads_je_sitz(schatten, raum):
|
||||
for e in reversed(list(schatten or ())):
|
||||
if not isinstance(e, dict) or e.get("raum") != raum:
|
||||
continue
|
||||
reads = (e.get("antwort") or {}).get("reads")
|
||||
antwort = e.get("antwort")
|
||||
reads = antwort.get("reads") if isinstance(antwort, dict) else None
|
||||
if not isinstance(reads, list):
|
||||
continue
|
||||
sitze = (e.get("anfrage") or {}).get("_sitze") or {}
|
||||
anfrage = e.get("anfrage")
|
||||
sitze = (anfrage.get("_sitze") if isinstance(anfrage, dict) else None) or {}
|
||||
out = {}
|
||||
for r in reads:
|
||||
if isinstance(r, dict):
|
||||
|
||||
@@ -130,6 +130,22 @@ class Einschaetzung(unittest.TestCase):
|
||||
"antwort": {"reads": [{"seat": 2, "style": "regular", "foldChance": 0.45, "trust": 0.6}]}}
|
||||
self.assertEqual(gegner.reads_je_sitz([alt, neu], "T")[5]["stil"], "regular")
|
||||
|
||||
def test_antwort_oder_anfrage_als_text_kippt_nicht(self):
|
||||
"""6.11.: `antwort`/`anfrage` waren im Schatten teils ein String statt Dict - ein einziger
|
||||
solcher Eintrag warf AttributeError und riss die GANZE Tischansicht leer (keine Spieler, kein
|
||||
Profit). Der Leser muss solche Brocken ueberspringen, nicht daran sterben."""
|
||||
import gegner
|
||||
schatten = [{"raum": "T", "anfrage": "kaputt", "antwort": "auch kaputt"},
|
||||
{"raum": "T", "antwort": {"reads": "kein-list"}},
|
||||
{"raum": "T", "anfrage": {"_sitze": {"2": 5}},
|
||||
"antwort": {"reads": [{"seat": 2, "style": "nit", "foldChance": 0.7, "trust": 0.4}]}}]
|
||||
r = gegner.reads_je_sitz(schatten, "T")
|
||||
self.assertEqual(r[5]["stil"], "nit")
|
||||
|
||||
def test_reiner_textbrocken_im_schatten_wird_uebersprungen(self):
|
||||
import gegner
|
||||
self.assertEqual(gegner.reads_je_sitz(["nur text", {"raum": "T"}], "T"), {})
|
||||
|
||||
|
||||
class UrteilInDerAnsicht(unittest.TestCase):
|
||||
def test_tisch_traegt_sein_urteil(self):
|
||||
|
||||
Reference in New Issue
Block a user