def returns_unique_Collection_objects_for_same_input_module(self): # Ignoring self.c for now, just in case it changes later. # First, a module with no root NS mod = load('integration') c1 = Collection.from_module(mod) c2 = Collection.from_module(mod) assert c1 is not c2 # Now one *with* a root NS (which was previously buggy) mod2 = load('explicit_root') c3 = Collection.from_module(mod2) c4 = Collection.from_module(mod2) assert c3 is not c4
def devuelve_objs_Coleccion_unicos_para_el_mismo_modulo_de_entrada( self): # Ignorando self.c por ahora, en caso de que cambie más tarde. # Primero, un módulo sin raíz Hangar mod = load("integracion") c1 = Coleccion.del_modulo(mod) c2 = Coleccion.del_modulo(mod) assert c1 is not c2 # Ahora uno *con* una raíz Hangar (que anteriormente tenía errores) mod2 = load("raiz_explicita") c3 = Coleccion.del_modulo(mod2) c4 = Coleccion.del_modulo(mod2) assert c3 is not c4
def honors_subcollection_default_tasks_on_subcollection_name(self): sub = Collection.from_module(load("decorators")) self.c.add_collection(sub) # Sanity assert self.c["decorators.biz"] is sub["biz"] # Real test assert self.c["decorators"] is self.c["decorators.biz"]
def honors_subcollection_default_tasks_on_subcollection_name(self): sub = Collection.from_module(load('decorator')) self.c.add_collection(sub) # Sanity assert self.c['decorator.biz'] is sub['biz'] # Real test assert self.c['decorator'] is self.c['decorator.biz']
def honors_subcollection_default_tasks_on_subcollection_name(self): sub = Collection.from_module(load('decorators')) self.c.add_collection(sub) # Sanity assert self.c['decorators.biz'] is sub['biz'] # Real test assert self.c['decorators'] is self.c['decorators.biz']
def explicit_namespace_works_correctly(self): # Regression-ish test re #288 ns = Collection.from_module(load('integration')) expect( 'print_foo', out='foo\n', program=Program(namespace=ns), )
def explicit_namespace_works_correctly(self): # Regression-ish test re #288 ns = Collection.from_module(load('integration')) expect( 'print-foo', out='foo\n', program=Program(namespace=ns), )
def respeta_los_artefactos_pordefecto_de_la_subcoleccion_en_el_nombre_de_la_subcoleccion( self): sub = Coleccion.del_modulo(load("decoradores")) self.c.ad_coleccion(sub) # Sanity assert self.c["decoradores.biz"] is sub["biz"] # Real prueba assert self.c["decoradores"] is self.c["decoradores.biz"]
def invalid_path(self): # This is really just testing Lexicon/dict behavior but w/e, good # to be explicit, esp if we ever want this to become Exit or # another custom exception. (For now most/all callers manually # catch KeyError and raise Exit just to keep most Exit use high up # in the stack...) with raises(KeyError): collection = Collection.from_module(load("tree")) collection.subcollection_from_path("lol.whatever.man")
def invalid_path(self): # This is really just testing Lexicon/dict behavior but w/e, good # to be explicit, esp if we ever want this to become Exit or # another custom exception. (For now most/all callers manually # catch KeyError and raise Exit just to keep most Exit use high up # in the stack...) with raises(KeyError): collection = Collection.from_module(load('tree')) collection.subcollection_from_path('lol.whatever.man')
def Ruta_no_valida(self): # Esto realmente es solo probar el comportamiento de Lexicon/dict, # pero bueno, bueno ser explícito, especialmente si alguna vez # queremos que esto se convierta en Salida u otra excepción # personalizada. (Por ahora, la mayoría / todas las personas que # llaman capturan manualmente KeyError y generan Salida solo para # mantener la mayoría del uso de Salida en lo alto del stack ...) with raises(KeyError): coleccion = Coleccion.del_modulo(load("arbol")) coleccion.subcoleccion_desde_ruta("jeje.cualquier.pieza")
def setup(self): mod = load('explicit_root') mod.ns.configure({ 'key': 'builtin', 'otherkey': 'yup', 'subconfig': {'mykey': 'myvalue'} }) mod.ns.name = 'builtin_name' self.unchanged = Collection.from_module(mod) self.changed = Collection.from_module( mod, name='override_name', config={ 'key': 'override', 'subconfig': {'myotherkey': 'myothervalue'} } )
def setup(self): mod = load("explicit_root") mod.ns.configure( { "key": "builtin", "otherkey": "yup", "subconfig": {"mykey": "myvalue"}, } ) mod.ns.name = "builtin_name" self.unchanged = Collection.from_module(mod) self.changed = Collection.from_module( mod, name="override_name", config={ "key": "override", "subconfig": {"myotherkey": "myothervalue"}, }, )
def setup(self): mod = load("explicit_root") mod.ns.configure({ "key": "builtin", "otherkey": "yup", "subconfig": { "mykey": "myvalue" }, }) mod.ns.name = "builtin_name" self.unchanged = Collection.from_module(mod) self.changed = Collection.from_module( mod, name="override_name", config={ "key": "override", "subconfig": { "myotherkey": "myothervalue" }, }, )
def setup(self): mod = load("raiz_explicita") mod.hng.configurar({ "clave": "incorporado", "otraclave": "yup", "subconfig": { "miclave": "mivalor" }, }) mod.hng.nombre = "builtin_name" self.nocambiado = Coleccion.del_modulo(mod) self.cambiado = Coleccion.del_modulo( mod, nombre="anular_nombre", config={ "clave": "anular", "subconfig": { "miotraclave": "miotrovalor" }, }, )
def ruta_anidada(self): coleccion = Coleccion.del_modulo(load("arbol")) docs = coleccion.colecciones["fabric"].colecciones["docs"] assert coleccion.subcoleccion_desde_ruta("fabric.docs") is docs
def top_level_path(self): collection = Collection.from_module(load('tree')) build = collection.collections['build'] assert collection.subcollection_from_path('build') is build
def works_great_with_subclassing(self): class MyCollection(Collection): pass c = MyCollection.from_module(load('integration')) assert isinstance(c, MyCollection)
def setup(self): self.c = Collection.from_module(load('integration'))
def explicit_namespace_works_correctly(self): # Regression-ish test re #288 ns = Collection.from_module(load("integration")) expect("print-foo", out="foo\n", program=Program(namespace=ns))
def top_level_path(self): collection = Collection.from_module(load("tree")) build = collection.collections["build"] assert collection.subcollection_from_path("build") is build
def nested_path(self): collection = Collection.from_module(load("tree")) docs = collection.collections["build"].collections["docs"] assert collection.subcollection_from_path("build.docs") is docs
def may_specify_namespace(self): foo = load("foo") assert Program(namespace=foo).namespace is foo
def honors_subcollection_task_aliases(self): self.c.add_collection(load("decorators")) assert "decorators.bar" in self.c
def honors_explicit_collections(self): coll = Collection.from_module(load("explicit_root")) assert "top-level" in coll.tasks assert "sub-level" in coll.collections # The real key test assert "sub-task" not in coll.tasks
def works_great_with_subclassing(self): class MyCollection(Collection): pass c = MyCollection.from_module(load("integration")) assert isinstance(c, MyCollection)
def can_take_module_objects(self): self.c.add_collection(load('integration')) assert 'integration' in self.c.collections
def honors_subcollection_task_aliases(self): self.c.add_collection(load('decorator')) assert 'decorator.bar' in self.c
def setup(self): self.c = Collection.from_module(load('explicit_root'))
def may_specify_namespace(self): foo = load('foo') ok_(Program(namespace=foo).namespace is foo)
def nested_path(self): collection = Collection.from_module(load('tree')) docs = collection.collections['build'].collections['docs'] assert collection.subcollection_from_path('build.docs') is docs
def allows_tasks_with_explicit_names_to_override_bound_name(self): coll = Collection.from_module(load('subcollection_task_name')) assert 'explicit-name' in coll.tasks # not 'implicit_name'
def setup(self): self.mod = load('integration') self.from_module = Collection.from_module
def honors_subcollection_task_aliases(self): self.c.add_collection(load('decorators')) assert 'decorators.bar' in self.c
def honors_explicit_collections(self): coll = Collection.from_module(load('explicit_root')) assert 'top-level' in coll.tasks assert 'sub-level' in coll.collections # The real key test assert 'sub-task' not in coll.tasks
def ruta_de_nivel_superior(self): coleccion = Coleccion.del_modulo(load("arbol")) fabric = coleccion.colecciones["fabric"] assert coleccion.subcoleccion_desde_ruta("fabric") is fabric