def test_choice_default():
  class Dumb(Struct):
    one = String

  class ChoiceDefaultStruct(Struct):
    a = Default(Choice("IntOrDumb", [Dumb, Integer]), 28)
    b = Integer

  class OtherStruct(Struct):
    first = ChoiceDefaultStruct
    second = String

  v = OtherStruct(second="hello")
  assert v.check()
  assert json.loads(v.json_dumps()) == {"second": "hello"}
  w = v(first=ChoiceDefaultStruct())
  assert w.check()
  assert json.loads(w.json_dumps()) == {'first': {'a': 28}, 'second': 'hello'}
  x = v(first=ChoiceDefaultStruct(a=296, b=36))
  assert x.check()
  assert json.loads(x.json_dumps()) == {'first': {'a': 296, 'b': 36},
                      'second': 'hello'}
  y = v(first=ChoiceDefaultStruct(a=Dumb(one="Oops"), b=37))
  assert y.check()
  assert json.loads(y.json_dumps()) == {'first': {'a': {'one': 'Oops'}, 'b': 37},
                                        'second': 'hello'}
Ensure that choices with a default work correctly.
dataset/ETHPy150Open wickman/pystachio/tests/test_choice.py/test_choice_default