diff --git a/rolltable/tables.py b/rolltable/tables.py index b1bdb6b..07b2f46 100644 --- a/rolltable/tables.py +++ b/rolltable/tables.py @@ -113,7 +113,7 @@ class RollTable: freqs = random.choices(options, weights=weights, k=self.die) values = [] for option in freqs: - choice = random.choice(ds.data[option]) + choice = random.choice(ds.data[option]) if ds.data[option] else '' if hasattr(choice, 'keys'): c = [option] for (k, v) in choice.items(): diff --git a/tests/test_tables.py b/tests/test_tables.py index 2cf8f70..eb32068 100644 --- a/tests/test_tables.py +++ b/tests/test_tables.py @@ -82,6 +82,16 @@ B3: - B choice 3 """ +fixture_no_options = """ +metadata: + headers: + - headerA + - headerB +B1: +B2: +B3: +""" + def test_combined_tables(): combined = tables.RollTable([fixture_combined_A, fixture_combined_B], die=6) @@ -125,5 +135,5 @@ def test_no_descriptions(): def test_yaml(): - t = tables.RollTable([fixture_metadata + fixture_source]) + t = tables.RollTable([fixture_no_options]) print(t.as_yaml)