示例#1
0
    def test__r(self):

        self.prop_test(
            CompoundProperty(
                total_hours=R('days') * 24 + R('hours') + R('minutes') / 60,
                days=V(1),
                hours=V(1),
                minutes=V(30),
            ),
            dict(days=1, hours=1, minutes=30, total_hours=25.5),
        )
示例#2
0
 def test__empty_source(self):
     with self.assertRaises(PropertyNotResolved):
         R().get({}, {})
     with self.assertRaises(PropertyNotResolved):
         R(sources_it=[]).get({}, {})
     self.prop_test(D(x=V(1), y=D(x=R()))['y']['x'], 1)
示例#3
0
 def test__ref_to_property_in_grandparent(self):
     self.prop_test(D(x=V(1), y=D(z=R('x')))['y']['z'], 1)
示例#4
0
 def test__ref_to_property_in_parent(self):
     self.prop_test(D(x=V(1), y=R('x'))['y'], 1)
示例#5
0
 def test__result__list(self):
     self.prop_test(R(0), 9, result=[9])
示例#6
0
 def test__default(self):
     self.prop_test(R(default=9), 9, result={})
示例#7
0
 def test__sources__lists(self):
     self.prop_test(R([2, 1], [1, 3], [1, 2]), 9, result={1: {2: 9}})
示例#8
0
 def test__source__list(self):
     self.prop_test(R([1]), 9, result={1: 9})
     self.prop_test(R([1, 2]), 9, result={1: {2: 9}})
示例#9
0
 def test__sources_it(self):
     self.prop_test(R(sources_it=[1, 2]), 9, result={2: 9})
     self.prop_test(R(sources_it=[[1, 2]]), 9, result={1: {2: 9}})
示例#10
0
 def test__sources(self):
     self.prop_test(R(1, 2), 9, result={2: 9})
示例#11
0
 def test__source(self):
     self.prop_test(R(1), 9, result={1: 9})
示例#12
0
 def test__ref__get_item__index_out_of_range__with_default(self):
     self.prop_test(D(a=V([]), x=P(R('a')[0], default=0))['x'], 0)
     self.prop_test(D(a=V([]), x=P(R('a')[1], default=0))['x'], 0)
     self.prop_test(
         D(dict(lazy=True), a=V([]), x=R('a')[1], y=R('x', default=0))['y'],
         0)