示例#1
0
    def config_defaults(self, fixture):
        """To facilitate dependency injection, the Configuration of one Egg can set the 'automatic' ConfigSettings of
           another egg on which it depends."""

        egg_needing_injection = EasterEgg('test-inject')
        fixture.set_config_spec(
            egg_needing_injection,
            'reahl.component_dev.test_config:ConfigWithInjectedSetting')
        pkg_resources.working_set.add(egg_needing_injection)

        fixture.set_config_spec(
            easter_egg,
            'reahl.component_dev.test_config:ConfigWhichInjectsSetting')

        easter_egg.add_dependency(
            egg_needing_injection.as_requirement_string())

        # Usually this happens inside other infrastructure, such as the implementation of reahl serve (see reahl-dev)
        config = StoredConfiguration(fixture.config_dir.name)
        config.configure()

        # The default value is still used
        vassert(config.some_key.injected_setting == 123)
示例#2
0
 class EasterFixture:
     group_name = 'abc'
     stub_egg = EasterEgg()
示例#3
0
from __future__ import print_function, unicode_literals, absolute_import, division
import pkg_resources

from reahl.stubble import EasterEgg


#first we need some stub classes which in real life would be provided
# by another egg as entry points:
class StubClass1(object):
    pass


class StubClass2(object):
    pass


#then, we initialise the EasterEgg:
stub_egg = EasterEgg()
pkg_resources.working_set.add(stub_egg)

#then, use 1 of two methods to add the stubbed entry point classes:
group_name = 'xxx'
stub_egg.add_entry_point_from_line(group_name,
                                   'test1 = examples.setuptools:StubClass1')
stub_egg.add_entry_point(group_name, 'test2', StubClass2)

#now, the actual code (which is presumably being tested)
#  (we just print out each class it finds...)
for i in pkg_resources.iter_entry_points(group_name):
    print(i.load())
 def new_containing_egg(self):
     egg = EasterEgg(name='example_egg', location=self.egg_directory.name)
     yield egg
     egg.deactivate()
示例#5
0
 def setUp(self):
     self.group_name = 'abc'
     self.stub_egg = EasterEgg()
     self.saved_working_set = pkg_resources.working_set
     pkg_resources.working_set = pkg_resources.WorkingSet()
     pkg_resources.working_set.add(self.stub_egg)
 def new_containing_egg(self):
     return EasterEgg(name='example_egg', location=self.egg_directory.name)