Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: mojo/python/tests/bindings_enums_unittest.py

Issue 545433002: mojo: Generate top level enums for python bindings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unhelpful conditional Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import unittest
6
7 # Generated files
8 # pylint: disable=F0401
9 import sample_import_mojom
10
11
12 class EnumBindingsTest(unittest.TestCase):
13
14 # Testing that enum class have expected constant values.
15 def testTopLevelEnumGeneration(self):
16 self.assertEquals(sample_import_mojom.Shape.RECTANGLE, 1)
17 self.assertEquals(sample_import_mojom.Shape.CIRCLE, 2)
18 self.assertEquals(sample_import_mojom.Shape.TRIANGLE, 3)
19 self.assertEquals(sample_import_mojom.Shape.LAST,
20 sample_import_mojom.Shape.TRIANGLE)
21
22 self.assertEquals(sample_import_mojom.AnotherShape.RECTANGLE, 10)
23 self.assertEquals(sample_import_mojom.AnotherShape.CIRCLE, 11)
24 self.assertEquals(sample_import_mojom.AnotherShape.TRIANGLE, 12)
25
26 self.assertEquals(sample_import_mojom.YetAnotherShape.RECTANGLE, 20)
27 self.assertEquals(sample_import_mojom.YetAnotherShape.CIRCLE, 21)
28 self.assertEquals(sample_import_mojom.YetAnotherShape.TRIANGLE, 22)
29
30 # Testing an enum class cannot be instantiated.
31 def testNonInstantiableEnum(self):
32 with self.assertRaises(TypeError):
33 sample_import_mojom.Shape()
34
35 # Testing an enum does not contain the VALUES constant.
36 def testNoVALUESConstant(self):
37 with self.assertRaises(AttributeError):
38 # pylint: disable=W0104
39 sample_import_mojom.Shape.VALUES
40
41 # Testing enum values are frozen.
42 def testEnumFrozen(self):
43 with self.assertRaises(AttributeError):
44 sample_import_mojom.Shape.RECTANGLE = 2
45 with self.assertRaises(AttributeError):
46 del sample_import_mojom.Shape.RECTANGLE
47 with self.assertRaises(AttributeError):
48 sample_import_mojom.Shape.NewShape = 4
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698