Skip to content

Commit

Permalink
Adjusted test so it won't break if only one style is defined in an en…
Browse files Browse the repository at this point in the history
…try in parameters
  • Loading branch information
fu committed Dec 7, 2018
1 parent cfa001d commit 8c60f60
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/test_back_and_forward_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@


def test_simple_back_and_forward_mapping():
skey = random.choice(list(up.parameters.keys()))
while True:
skey = random.choice(list(up.parameters.keys()))

param_dict = up.parameters[skey]
param_dict = up.parameters[skey]
available_styles = [k for k in param_dict.keys() if 'style' in k]
if len(available_styles) >= 2:
break

while True:
# must be sure to have both keys in the random param_dict
try:
source_style, target_style = random.choices(up.available_styles, k=2)
source_style, target_style = random.choices(available_styles, k=2)
# python 3.7
except:
source_style, target_style = random.sample(up.available_styles, 2)
source_style, target_style = random.sample(available_styles, 2)
# python <3.7
if source_style in param_dict.keys() and target_style in param_dict.keys():
if isinstance(param_dict[source_style], str) and \
Expand Down

0 comments on commit 8c60f60

Please sign in to comment.