Example #1
0
    def testContains(self):
        c1 = Context()
        c1.add(self.id1)
        self.assertTrue(self.id1 in c1)

        c2 = Context(self.id1)
        self.assertTrue(self.id1 in c2)
Example #2
0
 def testSecondaryCreation(self):
     c1 = Context(self.id1)
     self.assertIsNotNone(c1, "Creation of Context failed")
     self.assertFalse(c1.isEmpty())
     self.assertEqual(len(c1), 1)
     self.assertEqual(c1[0], self.id1, "Saved Context seems not to be stored correctly")
     try:
         # this MUST fail with an IndexError
         a = c1[1]
     except IndexError:
         pass
     else:
         raise AssertionError("IndexError was not raised despite out-of-bounds access, something was wrong")
Example #3
0
    def testCreationAndRemove(self):
        """tests the correct creation of a context"""
        c1 = Context()
        self.assertIsNotNone(c1, "Creation of Context failed")
        self.assertEqual(len(c1), 0)
        self.assertTrue(c1.isEmpty())
        c1.add(self.id1)
        self.assertEqual(len(c1), 1)
        self.assertFalse(c1.isEmpty())

        c1.remove(self.id1)
        self.assertTrue(c1.isEmpty())
        self.assertEqual(len(c1), 0)
Example #4
0
    def addOverrideAction(self, action: QAction, context: Context, scriptable: bool):
        if HostOsInfo.isMacHost():
            action.setIconVisibleInMenu(False)
            if self.isEmpty():
                self._action.initialize(action)
            if context.isEmpty():
                self._contextActionMap[None] = action
            else:
                for i in range(len(context)):
                    cId = context[i]
                    if cId in self._contextActionMap:
                        warnings.warn(self.__msgActionWarning(action, cId, self._contextActionMap.get(cId, None)))
                    self._contextActionMap[cId] = action

            self._scriptableMap[action] = scriptable
            self.setCurrentContext(self._context)
Example #5
0
 def testPrepend(self):
     c1 = Context()
     c1.add(ItemId())
     c1.prepend(self.id1)
     self.assertEqual(c1.indexOf(self.id1), 0)
Example #6
0
 def testIndexOf(self):
     c1 = Context(self.id1)
     self.assertEqual(c1.indexOf(self.id1), 0)