MCPcopy Create free account
hub / github.com/LabPy/lantz / test_limits_units

Method test_limits_units

lantz/testsuite/test_feat.py:149–169  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

147 self.assertRaises(ValueError, setattr, obj, "eggs", 0)
148
149 def test_limits_units(self):
150
151 class Spam(Driver):
152
153 _eggs = 8
154
155 @Feat(limits=(1, 10), units='second')
156 def eggs(self_):
157 return self_._eggs
158
159 @eggs.setter
160 def eggs(self_, value):
161 self_._eggs = value
162
163 obj = Spam()
164 for mult, units in ((1., 'second'), (1000., 'millisecond'), (0.001, 'kilosecond')):
165 val = Q_(2.2 * mult, units)
166 obj.eggs = val
167 self.assertEqual(obj.eggs, val)
168 self.assertRaises(ValueError, setattr, obj, "eggs", Q_(11. * mult, units))
169 self.assertRaises(ValueError, setattr, obj, "eggs", Q_(0.9 * mult, units))
170
171 def test_set_units(self):
172

Callers

nothing calls this directly

Calls 1

SpamClass · 0.70

Tested by

no test coverage detected