Пример #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
Пример #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
Пример #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
Пример #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"]
Пример #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']
Пример #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']
Пример #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),
     )
Пример #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),
     )
Пример #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"]
Пример #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")
Пример #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')
Пример #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")
Пример #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'}
         }
     )
Пример #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'}
         }
     )
Пример #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"},
         },
     )
Пример #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"
             },
         },
     )
Пример #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"
             },
         },
     )
Пример #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
Пример #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
Пример #20
0
 def works_great_with_subclassing(self):
     class MyCollection(Collection):
         pass
     c = MyCollection.from_module(load('integration'))
     assert isinstance(c, MyCollection)
Пример #21
0
 def setup(self):
     self.c = Collection.from_module(load('integration'))
Пример #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))
Пример #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
Пример #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
Пример #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
Пример #26
0
 def may_specify_namespace(self):
     foo = load("foo")
     assert Program(namespace=foo).namespace is foo
Пример #27
0
 def honors_subcollection_task_aliases(self):
     self.c.add_collection(load("decorators"))
     assert "decorators.bar" in self.c
Пример #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
Пример #29
0
        def works_great_with_subclassing(self):
            class MyCollection(Collection):
                pass

            c = MyCollection.from_module(load("integration"))
            assert isinstance(c, MyCollection)
Пример #30
0
 def can_take_module_objects(self):
     self.c.add_collection(load('integration'))
     assert 'integration' in self.c.collections
Пример #31
0
 def honors_subcollection_task_aliases(self):
     self.c.add_collection(load('decorator'))
     assert 'decorator.bar' in self.c
Пример #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
Пример #33
0
 def setup(self):
     self.c = Collection.from_module(load('explicit_root'))
Пример #34
0
 def setup(self):
     self.c = Collection.from_module(load('explicit_root'))
Пример #35
0
 def may_specify_namespace(self):
     foo = load('foo')
     ok_(Program(namespace=foo).namespace is foo)
Пример #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
Пример #37
0
 def may_specify_namespace(self):
     foo = load("foo")
     assert Program(namespace=foo).namespace is foo
Пример #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'
Пример #39
0
 def setup(self):
     self.mod = load('integration')
     self.from_module = Collection.from_module
Пример #40
0
 def honors_subcollection_task_aliases(self):
     self.c.add_collection(load('decorators'))
     assert 'decorators.bar' in self.c
Пример #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
Пример #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
Пример #43
0
 def honors_subcollection_task_aliases(self):
     self.c.add_collection(load("decorators"))
     assert "decorators.bar" in self.c
Пример #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
Пример #45
0
 def can_take_module_objects(self):
     self.c.add_collection(load('integration'))
     assert 'integration' in self.c.collections
Пример #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'
Пример #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))
Пример #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
Пример #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
Пример #50
0
 def setup(self):
     self.c = Collection.from_module(load('integration'))
Пример #51
0
 def setup(self):
     self.mod = load('integration')
     self.from_module = Collection.from_module
Пример #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