Beispiel #1
0
 def get_config_updates_recursive(self):
     config_updates = self.config_updates.copy()
     for sr_path, subrunner in self.subrunners.items():
         if not is_prefix(self.path, sr_path):
             continue
         update = subrunner.get_config_updates_recursive()
         if update:
             config_updates[rel_path(self.path, sr_path)] = update
     return config_updates
Beispiel #2
0
 def get_config_updates_recursive(self):
     config_updates = self.config_updates.copy()
     for sr_path, subrunner in self.subrunners.items():
         if not is_prefix(self.path, sr_path):
             continue
         update = subrunner.get_config_updates_recursive()
         if update:
             config_updates[rel_path(self.path, sr_path)] = update
     return config_updates
Beispiel #3
0
def test_is_prefix():
    assert is_prefix('', 'foo')
    assert is_prefix('foo', 'foo.bar')
    assert is_prefix('foo.bar', 'foo.bar.baz')

    assert not is_prefix('a', 'foo.bar')
    assert not is_prefix('a.bar', 'foo.bar')
    assert not is_prefix('foo.b', 'foo.bar')
    assert not is_prefix('foo.bar', 'foo.bar')
Beispiel #4
0
def test_is_prefix():
    assert is_prefix("", "foo")
    assert is_prefix("foo", "foo.bar")
    assert is_prefix("foo.bar", "foo.bar.baz")

    assert not is_prefix("a", "foo.bar")
    assert not is_prefix("a.bar", "foo.bar")
    assert not is_prefix("foo.b", "foo.bar")
    assert not is_prefix("foo.bar", "foo.bar")
Beispiel #5
0
def test_is_prefix():
    assert is_prefix('', 'foo')
    assert is_prefix('foo', 'foo.bar')
    assert is_prefix('foo.bar', 'foo.bar.baz')

    assert not is_prefix('a', 'foo.bar')
    assert not is_prefix('a.bar', 'foo.bar')
    assert not is_prefix('foo.b', 'foo.bar')
    assert not is_prefix('foo.bar', 'foo.bar')
Beispiel #6
0
 def get_fixture_recursive(runner):
     for sr_path, subrunner in runner.subrunners.items():
         # I am not sure if it is necessary to trigger all
         subrunner.get_fixture()
         get_fixture_recursive(subrunner)
         sub_fix = copy(subrunner.config)
         sub_path = sr_path
         if is_prefix(self.path, sub_path):
             sub_path = sr_path[len(self.path):].strip('.')
         # Note: This might fail if we allow non-dict fixtures
         set_by_dotted_path(self.fixture, sub_path, sub_fix)
Beispiel #7
0
 def get_fixture_recursive(runner):
     for sr_path, subrunner in runner.subrunners.items():
         # I am not sure if it is necessary to trigger all
         subrunner.get_fixture()
         get_fixture_recursive(subrunner)
         sub_fix = copy(subrunner.config)
         sub_path = sr_path
         if is_prefix(self.path, sub_path):
             sub_path = sr_path[len(self.path):].strip('.')
         # Note: This might fail if we allow non-dict fixtures
         set_by_dotted_path(self.fixture, sub_path, sub_fix)
Beispiel #8
0
    def gather_fallbacks(self):
        fallback = {}
        for sr_path, subrunner in self.subrunners.items():
            if self.path and is_prefix(self.path, sr_path):
                path = sr_path[len(self.path):].strip('.')
                set_by_dotted_path(fallback, path, subrunner.config)
            else:
                set_by_dotted_path(fallback, sr_path, subrunner.config)

        # dogmatize to make the subrunner configurations read-only
        self.fallback = dogmatize(fallback)
        self.fallback.revelation()
Beispiel #9
0
    def gather_fallbacks(self):
        fallback = {}
        for sr_path, subrunner in self.subrunners.items():
            if self.path and is_prefix(self.path, sr_path):
                path = sr_path[len(self.path):].strip('.')
                set_by_dotted_path(fallback, path, subrunner.config)
            else:
                set_by_dotted_path(fallback, sr_path, subrunner.config)

        # dogmatize to make the subrunner configurations read-only
        self.fallback = dogmatize(fallback)
        self.fallback.revelation()
Beispiel #10
0
    def get_fixture(self):
        if self.fixture is not None:
            return self.fixture

        self.fixture = copy(self.config)
        for sr_path, subrunner in self.subrunners.items():
            sub_fix = subrunner.get_fixture()
            sub_path = sr_path
            if is_prefix(self.path, sub_path):
                sub_path = sr_path[len(self.path):].strip('.')
            # Note: This might fail if we allow non-dict fixtures
            set_by_dotted_path(self.fixture, sub_path, sub_fix)
        return self.fixture
Beispiel #11
0
    def get_fixture(self):
        if self.fixture is not None:
            return self.fixture

        self.fixture = copy(self.config)
        for sr_path, subrunner in self.subrunners.items():
            sub_fix = subrunner.get_fixture()
            sub_path = sr_path
            if is_prefix(self.path, sub_path):
                sub_path = sr_path[len(self.path):].strip('.')
            # Note: This might fail if we allow non-dict fixtures
            set_by_dotted_path(self.fixture, sub_path, sub_fix)
        return self.fixture
Beispiel #12
0
    def set_up_seed(self, rnd=None):
        if self.seed is not None:
            return

        self.seed = self.config.get('seed') or get_seed(rnd)
        self.rnd = create_rnd(self.seed)

        if self.generate_seed:
            self.config['seed'] = self.seed

        if 'seed' in self.config and 'seed' in self.config_mods.added:
            self.config_mods.modified.add('seed')
            self.config_mods.added -= {'seed'}

        # Hierarchically set the seed of proper subrunners
        for subrunner_path, subrunner in reversed(list(
                self.subrunners.items())):
            if is_prefix(self.path, subrunner_path):
                subrunner.set_up_seed(self.rnd)
Beispiel #13
0
    def set_up_seed(self, rnd=None):
        if self.seed is not None:
            return

        self.seed = self.config.get('seed') or get_seed(rnd)
        self.rnd = create_rnd(self.seed)

        if self.generate_seed:
            self.config['seed'] = self.seed

        if 'seed' in self.config and 'seed' in self.config_mods.added:
            self.config_mods.modified.add('seed')
            self.config_mods.added -= {'seed'}

        # Hierarchically set the seed of proper subrunners
        for subrunner_path, subrunner in reversed(list(
                self.subrunners.items())):
            if is_prefix(self.path, subrunner_path):
                subrunner.set_up_seed(self.rnd)
Beispiel #14
0
    def set_up_config(self):
        if self.config is not None:
            return self.config

        # gather presets
        fallback = {}
        for sr_path, subrunner in self.subrunners.items():
            if self.path and is_prefix(self.path, sr_path):
                path = sr_path[len(self.path):].strip('.')
                set_by_dotted_path(fallback, path, subrunner.config)
            else:
                set_by_dotted_path(fallback, sr_path, subrunner.config)

        # dogmatize to make the subrunner configurations read-only
        const_fallback = dogmatize(fallback)
        const_fallback.revelation()

        self.config = {}

        # named configs first
        cfg_list = []
        for ncfg in self.named_configs_to_use:
            if os.path.exists(ncfg):
                cfg_list.append(ConfigDict(load_config_file(ncfg)))
            else:
                cfg_list.append(self.named_configs[ncfg])

        self.config_updates, _ = chain_evaluate_config_scopes(
            cfg_list,
            fixed=self.config_updates,
            preset=self.config,
            fallback=const_fallback)

        # unnamed (default) configs second
        self.config, self.summaries = chain_evaluate_config_scopes(
            self.config_scopes,
            fixed=self.config_updates,
            preset=self.config,
            fallback=const_fallback)

        self.get_config_modifications()