-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_param_to_property.py
60 lines (50 loc) · 1.73 KB
/
test_param_to_property.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
from uiautomator import param_to_property
class TestParamToProperty(unittest.TestCase):
def test_props(self):
args_value = None
kwargs_value = None
@param_to_property("one", "two", "three")
def func(*args, **kwargs):
self.assertEqual(args, args_value)
self.assertEqual(kwargs, kwargs_value)
args_value = ("one", "two", "three")
kwargs_value = {"test": 1}
func.one.two.three(test=1)
args_value = ("one", "three")
kwargs_value = {"another_test": 100}
func.one("three", another_test=100)
args_value = ("one", "two", "three")
kwargs_value = {}
func("one", "two", "three")
args_value = ("three", "one", "two")
kwargs_value = {}
func.three("one", "two")
def test_kwprops(self):
args_value = None
kwargs_value = None
@param_to_property(key=["one", "two", "three"])
def func(*args, **kwargs):
self.assertEqual(args, args_value)
self.assertEqual(kwargs, kwargs_value)
args_value = (1,)
kwargs_value = {"key": "one"}
func.one(1)
args_value = (2, 3)
kwargs_value = {"key": "two"}
func.two(2, 3)
args_value = ()
kwargs_value = {}
func()
def test_error(self):
@param_to_property(key=["one", "two", "three"])
def func(*args, **kwargs):
pass
with self.assertRaises(AttributeError):
func.one.one
with self.assertRaises(SyntaxError):
@param_to_property("a", "b", key=["one", "two", "three"])
def func(*args, **kwargs):
pass