def test_length_property_not_cached(self):
nodes = np.asfortranarray([
[0.0, 0.0],
[1.0, 2.0],
])
curve = self._make_one(nodes, 1)
self.assertIsNone(curve._length)
patch = unittest.mock.patch(
'bezier._curve_helpers.compute_length',
return_value=unittest.mock.sentinel.length)
with patch as mocked:
self.assertEqual(curve.length, unittest.mock.sentinel.length)
self.assertEqual(mocked.call_count, 1)
call = mocked.mock_calls[0]
_, positional, keyword = call
self.assertEqual(keyword, {})
self.assertEqual(len(positional), 1)
self.assertEqual(positional[0], nodes)
评论列表
文章目录