コード例 #1
0
ファイル: test_hkutils.py プロジェクト: attish/heapkeeper_
    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_)
コード例 #2
0
ファイル: test_hkutils.py プロジェクト: attish/heapkeeper-old
    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_)
コード例 #3
0
ファイル: test_hkutils.py プロジェクト: attish/heapkeeper-old
 def try_():
     # Function already defined # pylint: disable=E0102
     hkutils.set_defaultoptions(options, f, ['other1', 'other2'])
コード例 #4
0
ファイル: test_hkutils.py プロジェクト: attish/heapkeeper_
 def try_():
     hkutils.set_defaultoptions(options, f, ['other1', 'other2'])