예제 #1
0
 def testDefaultEnumScope(self):
     """
     Enum instances must only affect the scope they are created in.
     """
     ENUM_NAME = 'THE_ANSWER'
     ENUM_VALUE = 42
     local_dict = locals()
     global_dict = globals()
     self.assertEqual(local_dict.get(ENUM_NAME), None)
     self.assertEqual(global_dict.get(ENUM_NAME), None)
     self.assertEqual(getattr(libusb1, ENUM_NAME, None), None)
     TEST_ENUM = libusb1.Enum({ENUM_NAME: ENUM_VALUE})
     self.assertEqual(local_dict.get(ENUM_NAME), ENUM_VALUE)
     self.assertEqual(global_dict.get(ENUM_NAME), None)
     self.assertEqual(getattr(libusb1, ENUM_NAME, None), None)
예제 #2
0
 def testExplicitEnumScope(self):
     """
     Enum instances must only affect the scope they are created in.
     """
     ENUM_NAME = 'THE_ANSWER'
     ENUM_VALUE = 42
     local_dict = locals()
     global_dict = globals()
     self.assertEqual(local_dict.get(ENUM_NAME), None)
     self.assertEqual(global_dict.get(ENUM_NAME), None)
     self.assertEqual(getattr(libusb1, ENUM_NAME, None), None)
     # pylint: disable=unused-variable
     TEST_ENUM = libusb1.Enum({ENUM_NAME: ENUM_VALUE}, global_dict)
     # pylint: enable=unused-variable
     try:
         self.assertEqual(local_dict.get(ENUM_NAME), None)
         self.assertEqual(global_dict.get(ENUM_NAME), ENUM_VALUE)
         self.assertEqual(getattr(libusb1, ENUM_NAME, None), None)
     finally:
         del global_dict[ENUM_NAME]