Esempio n. 1
0
    def test_preserve_annotations(self):
        func = f('self, a:2, b, c:3', 4)

        tr = modifiers._PokTranslator(func, kwoargs=('a', 'b'))
        self.assertSigsEqual(s('self, c:3, *, a:2, b', 4), signature(tr))
        self.assertSigsEqual(s('c:3, *, a:2, b', 4),
                             signature(safe_get(tr, object(), object)))
Esempio n. 2
0
def poktranslator_test(self, expected_sig_str, orig_sig_str, posoargs,
                       kwoargs):
    expected_sig = s(expected_sig_str)
    orig_sig = s(orig_sig_str)
    for exp, orig in defaults_variations(expected_sig, orig_sig):
        for exp, orig in stars_variations(exp, orig):
            func = modifiers._PokTranslator(func_from_sig(orig), posoargs,
                                            kwoargs)
            self.assertSigsEqual(exp, signature(func))
            test_func_sig_coherent(func)
            repr(func)  # must not cause an error
Esempio n. 3
0
def poktranslator_test(self, expected_sig_str, orig_sig_str,
                        posoargs, kwoargs):
    expected_sig = s(expected_sig_str)
    orig_sig = s(orig_sig_str)
    for exp, orig in defaults_variations(expected_sig, orig_sig):
        for exp, orig in stars_variations(exp, orig):
            func = modifiers._PokTranslator(
                func_from_sig(orig), posoargs, kwoargs)
            self.assertSigsEqual(exp, signature(func))
            test_func_sig_coherent(func)
            repr(func) # must not cause an error
Esempio n. 4
0
    def test_preserve_annotations(self):
        func = f('self, a:2, b, c:3', 4)

        tr = modifiers._PokTranslator(func, kwoargs=('a', 'b'))
        self.assertSigsEqual(
            s('self, c:3, *, a:2, b', 4),
            signature(tr)
            )
        self.assertSigsEqual(
            s('c:3, *, a:2, b', 4),
            signature(safe_get(tr, object(), object))
            )