def test_mlazy(): it = iter(range(20, 30)) p = mlazy(nextfun(it)) assert p() == 20 assert p.evaluated assert p() == 20 assert repr(p) == '20'
def test_is_memoized(self): it = iter(range(20, 30)) p = mlazy(nextfun(it)) self.assertEqual(p(), 20) self.assertTrue(p.evaluated) self.assertEqual(p(), 20) self.assertEqual(repr(p), '20')
def expand_annotation(annotation): if isinstance(annotation, dict): return MapAnnotation(annotation) elif isinstance(annotation, string_t): return mlazy(instantiate, annotation) return annotation
def expand_route(route): if isinstance(route, dict): return MapRoute(route) if isinstance(route, string_t): return mlazy(instantiate, route) return route
def expand_route(route): if isinstance(route, (Mapping, list, tuple)): return MapRoute(route) if isinstance(route, string_t): return mlazy(expand_router_string, route) return route