示例#1
0
    def test_order(self):
        txt = "def foo(**kwargs, key=val): pass"
        out = sort_arguments(txt=txt)
        self.assertEqual(out, "def foo(key=val, **kwargs):")

        txt = "def foo(**kwargs, key=val, first): pass"
        correct = "def foo(first, key=val, **kwargs):"
        self.assertEqual(correct, sort_arguments(txt=txt))
示例#2
0
 def test_kwargs_into_arg(self):
     txt = "def foo(self, *args, **kwargs): pass"
     correct = "def foo(self, *args, **kwargs):"
     self.assertEqual(correct, sort_arguments(txt=txt))
示例#3
0
 def test_arg_kwargs_all(self):
     txt = "def foo(self, **kwargs, one, two=[], *arg): pass"
     correct = "def foo(self, one, two=[], *arg, **kwargs):"
     self.assertEqual(correct, sort_arguments(txt=txt))
示例#4
0
 def test_arg(self):
     txt = "def foo(self, *arg, one): pass"
     correct = "def foo(self, one, *arg):"
     self.assertEqual(correct, sort_arguments(txt=txt))
示例#5
0
 def test_simple_to_all(self):
     txt = "def foo(self, key=[], second): pass"
     correct = "def foo(self, second, key=[]):"
     self.assertEqual(correct, sort_arguments(txt=txt))
示例#6
0
 def test_insert_last(self):
     txt = "def foo(self, key=[], second): pass"
     correct = "def foo(self, second, key=[]):"
     self.assertEqual(correct, sort_arguments(txt=txt))
示例#7
0
 def test_append_kw(self):
     txt = "def rst(one, two=None, three=['inlist']): pass"
     correct = "def rst(one, two=None, three=['inlist']):"
     self.assertEqual(correct, sort_arguments(txt=txt))
示例#8
0
 def test_append_last(self):
     txt = "def rst(one, two): pass"
     correct = "def rst(one, two):"
     self.assertEqual(correct, sort_arguments(txt=txt))
示例#9
0
 def test_kwargs(self):
     txt = "def rst(**kwargs, first): pass"
     out = sort_arguments(txt=txt)
     self.assertEqual(out, "def rst(first, **kwargs):")
示例#10
0
 def test_nominal(self):
     txt = "def foo(bar): pass"
     out = sort_arguments(txt=txt)
     self.assertTrue(out in txt)