Beispiel #1
0
 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
Beispiel #2
0
 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
Beispiel #3
0
 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
Beispiel #4
0
 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"]
Beispiel #5
0
 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']
Beispiel #6
0
 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']
Beispiel #7
0
 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),
     )
Beispiel #8
0
 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),
     )
Beispiel #9
0
 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"]
Beispiel #10
0
 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")
Beispiel #11
0
 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')
Beispiel #12
0
 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")
Beispiel #13
0
 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'}
         }
     )
Beispiel #14
0
 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'}
         }
     )
Beispiel #15
0
 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"},
         },
     )
Beispiel #16
0
 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"
             },
         },
     )
Beispiel #17
0
 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"
             },
         },
     )
Beispiel #18
0
 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
Beispiel #19
0
 def top_level_path(self):
     collection = Collection.from_module(load('tree'))
     build = collection.collections['build']
     assert collection.subcollection_from_path('build') is build
Beispiel #20
0
 def works_great_with_subclassing(self):
     class MyCollection(Collection):
         pass
     c = MyCollection.from_module(load('integration'))
     assert isinstance(c, MyCollection)
Beispiel #21
0
 def setup(self):
     self.c = Collection.from_module(load('integration'))
Beispiel #22
0
 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))
Beispiel #23
0
 def top_level_path(self):
     collection = Collection.from_module(load("tree"))
     build = collection.collections["build"]
     assert collection.subcollection_from_path("build") is build
Beispiel #24
0
 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
Beispiel #25
0
 def top_level_path(self):
     collection = Collection.from_module(load("tree"))
     build = collection.collections["build"]
     assert collection.subcollection_from_path("build") is build
Beispiel #26
0
 def may_specify_namespace(self):
     foo = load("foo")
     assert Program(namespace=foo).namespace is foo
Beispiel #27
0
 def honors_subcollection_task_aliases(self):
     self.c.add_collection(load("decorators"))
     assert "decorators.bar" in self.c
Beispiel #28
0
 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
Beispiel #29
0
        def works_great_with_subclassing(self):
            class MyCollection(Collection):
                pass

            c = MyCollection.from_module(load("integration"))
            assert isinstance(c, MyCollection)
Beispiel #30
0
 def can_take_module_objects(self):
     self.c.add_collection(load('integration'))
     assert 'integration' in self.c.collections
Beispiel #31
0
 def honors_subcollection_task_aliases(self):
     self.c.add_collection(load('decorator'))
     assert 'decorator.bar' in self.c
Beispiel #32
0
 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
Beispiel #33
0
 def setup(self):
     self.c = Collection.from_module(load('explicit_root'))
Beispiel #34
0
 def setup(self):
     self.c = Collection.from_module(load('explicit_root'))
Beispiel #35
0
 def may_specify_namespace(self):
     foo = load('foo')
     ok_(Program(namespace=foo).namespace is foo)
Beispiel #36
0
 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
Beispiel #37
0
 def may_specify_namespace(self):
     foo = load("foo")
     assert Program(namespace=foo).namespace is foo
Beispiel #38
0
 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'
Beispiel #39
0
 def setup(self):
     self.mod = load('integration')
     self.from_module = Collection.from_module
Beispiel #40
0
 def honors_subcollection_task_aliases(self):
     self.c.add_collection(load('decorators'))
     assert 'decorators.bar' in self.c
Beispiel #41
0
 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
Beispiel #42
0
 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
Beispiel #43
0
 def honors_subcollection_task_aliases(self):
     self.c.add_collection(load("decorators"))
     assert "decorators.bar" in self.c
Beispiel #44
0
 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
Beispiel #45
0
 def can_take_module_objects(self):
     self.c.add_collection(load('integration'))
     assert 'integration' in self.c.collections
Beispiel #46
0
 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'
Beispiel #47
0
 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))
Beispiel #48
0
 def ruta_de_nivel_superior(self):
     coleccion = Coleccion.del_modulo(load("arbol"))
     fabric = coleccion.colecciones["fabric"]
     assert coleccion.subcoleccion_desde_ruta("fabric") is fabric
Beispiel #49
0
 def top_level_path(self):
     collection = Collection.from_module(load('tree'))
     build = collection.collections['build']
     assert collection.subcollection_from_path('build') is build
Beispiel #50
0
 def setup(self):
     self.c = Collection.from_module(load('integration'))
Beispiel #51
0
 def setup(self):
     self.mod = load('integration')
     self.from_module = Collection.from_module
Beispiel #52
0
 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