MCPcopy Create free account
hub / github.com/StackStorm/st2 / test_cast_array

Method test_cast_array

st2common/tests/unit/test_casts.py:50–65  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

48 self.assertRaisesRegex(ValueError, expected_msg, cast_func, value)
49
50 def test_cast_array(self):
51 cast_func = get_cast("array")
52
53 # Python literal
54 value = str([1, 2, 3])
55 result = cast_func(value)
56 self.assertEqual(result, [1, 2, 3])
57
58 # JSON serialized
59 value = json.dumps([4, 5, 6])
60 result = cast_func(value)
61 self.assertEqual(result, [4, 5, 6])
62
63 # Can't cast, should throw
64 value = "\\invalid"
65 self.assertRaises(SyntaxError, cast_func, value)

Callers

nothing calls this directly

Calls 2

get_castFunction · 0.90
cast_funcFunction · 0.85

Tested by

no test coverage detected