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

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: Follow sdefresne suugestions. 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
20 self.assertEquals(sample_import_mojom.AnotherShape.RECTANGLE, 10)
21 self.assertEquals(sample_import_mojom.AnotherShape.CIRCLE, 11)
22 self.assertEquals(sample_import_mojom.AnotherShape.TRIANGLE, 12)
23
24 self.assertEquals(sample_import_mojom.YetAnotherShape.RECTANGLE, 20)
25 self.assertEquals(sample_import_mojom.YetAnotherShape.CIRCLE, 21)
26 self.assertEquals(sample_import_mojom.YetAnotherShape.TRIANGLE, 22)
27
28 # Testing an enum class cannot be instantiated.
29 def testNonInstantiableEnum(self):
30 with self.assertRaises(TypeError):
31 sample_import_mojom.Shape()
32
33 # Testing an enum does not contain the VALUES constant.
34 def testNoVALUESConstant(self):
35 with self.assertRaises(AttributeError):
36 # pylint: disable=W0104
37 sample_import_mojom.Shape.VALUES
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698