Exemple #1
0
    def test_set_defaultoptions(self):

        def f(other1, a, b=1, c=2, other2=None):
            pass

        options = {'a':0, 'b': 1}
        hkutils.set_defaultoptions(options, f, ['other1', 'other2'])
        self.assertEquals(options, {'a':0, 'b':1, 'c':2})

        options = {'b': 1}
        def try_():
            hkutils.set_defaultoptions(options, f, ['other1', 'other2'])
        self.assertRaises(hkutils.HkException, try_)

        options = {'a':0, 'b': 1, 'other': 2}
        def try_():
            hkutils.set_defaultoptions(options, f, ['other1', 'other2'])
        self.assertRaises(hkutils.HkException, try_)
    def test_set_defaultoptions(self):

        """Tests :func:`hkutils.set_defaultoptions`."""

        def f(other1, a, b=1, c=2, other2=None):
            # Unused arguments # pylint: disable=W0613
            pass

        options = {'a':0, 'b': 1}
        hkutils.set_defaultoptions(options, f, ['other1', 'other2'])
        self.assertEqual(options, {'a':0, 'b':1, 'c':2})

        options = {'b': 1}
        def try_():
            # Function already defined # pylint: disable=E0102
            hkutils.set_defaultoptions(options, f, ['other1', 'other2'])
        self.assertRaises(hkutils.HkException, try_)

        options = {'a':0, 'b': 1, 'other': 2}
        def try_():
            # Function already defined # pylint: disable=E0102
            hkutils.set_defaultoptions(options, f, ['other1', 'other2'])
        self.assertRaises(hkutils.HkException, try_)
 def try_():
     # Function already defined # pylint: disable=E0102
     hkutils.set_defaultoptions(options, f, ['other1', 'other2'])
Exemple #4
0
 def try_():
     hkutils.set_defaultoptions(options, f, ['other1', 'other2'])