| Index: mojo/python/tests/bindings_enums_unittest.py
|
| diff --git a/mojo/python/tests/bindings_enums_unittest.py b/mojo/python/tests/bindings_enums_unittest.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..2b79ee5707ac480c092f68b496090596b2270c24
|
| --- /dev/null
|
| +++ b/mojo/python/tests/bindings_enums_unittest.py
|
| @@ -0,0 +1,37 @@
|
| +# Copyright 2014 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +import unittest
|
| +
|
| +# Generated files
|
| +# pylint: disable=F0401
|
| +import sample_import_mojom
|
| +
|
| +
|
| +class EnumBindingsTest(unittest.TestCase):
|
| +
|
| + # Testing that enum class have expected constant values.
|
| + def testTopLevelEnumGeneration(self):
|
| + self.assertEquals(sample_import_mojom.Shape.RECTANGLE, 1)
|
| + self.assertEquals(sample_import_mojom.Shape.CIRCLE, 2)
|
| + self.assertEquals(sample_import_mojom.Shape.TRIANGLE, 3)
|
| +
|
| + self.assertEquals(sample_import_mojom.AnotherShape.RECTANGLE, 10)
|
| + self.assertEquals(sample_import_mojom.AnotherShape.CIRCLE, 11)
|
| + self.assertEquals(sample_import_mojom.AnotherShape.TRIANGLE, 12)
|
| +
|
| + self.assertEquals(sample_import_mojom.YetAnotherShape.RECTANGLE, 20)
|
| + self.assertEquals(sample_import_mojom.YetAnotherShape.CIRCLE, 21)
|
| + self.assertEquals(sample_import_mojom.YetAnotherShape.TRIANGLE, 22)
|
| +
|
| + # Testing an enum class cannot be instantiated.
|
| + def testNonInstantiableEnum(self):
|
| + with self.assertRaises(TypeError):
|
| + sample_import_mojom.Shape()
|
| +
|
| + # Testing an enum does not contain the VALUES constant.
|
| + def testNoVALUESConstant(self):
|
| + with self.assertRaises(AttributeError):
|
| + # pylint: disable=W0104
|
| + sample_import_mojom.Shape.VALUES
|
|
|