Пример #1
0
    def finalize_initialization(self, run):
        # look at seed again, because it might have changed during the
        # configuration process
        if 'seed' in self.config:
            self.seed = self.config['seed']
        self.rnd = create_rnd(self.seed)

        for cfunc in self._captured_functions:
            # Setup the captured function
            cfunc.logger = self.logger.getChild(cfunc.__name__)
            seed = get_seed(self.rnd)
            cfunc.rnd = create_rnd(seed)
            cfunc.run = run
            cfunc.config = get_by_dotted_path(self.get_fixture(),
                                              cfunc.prefix,
                                              default={})

            # Make configuration read only if enabled in settings
            if SETTINGS.CONFIG.READ_ONLY_CONFIG:
                cfunc.config = make_read_only(
                    cfunc.config,
                    error_message='The configuration is read-only in a '
                    'captured function!')

        if not run.force:
            self._warn_about_suspicious_changes()
Пример #2
0
    def finalize_initialization(self, run):
        # look at seed again, because it might have changed during the
        # configuration process
        if 'seed' in self.config:
            self.seed = self.config['seed']
        self.rnd = create_rnd(self.seed)

        for cfunc in self._captured_functions:
            cfunc.logger = self.logger.getChild(cfunc.__name__)
            cfunc.config = get_by_dotted_path(self.get_fixture(), cfunc.prefix)
            seed = get_seed(self.rnd)
            cfunc.rnd = create_rnd(seed)
            cfunc.run = run

        self._warn_about_suspicious_changes()
Пример #3
0
    def finalize_initialization(self, run):
        # look at seed again, because it might have changed during the
        # configuration process
        if 'seed' in self.config:
            self.seed = self.config['seed']
        self.rnd = create_rnd(self.seed)

        for cfunc in self._captured_functions:
            cfunc.logger = self.logger.getChild(cfunc.__name__)
            cfunc.config = get_by_dotted_path(self.get_fixture(), cfunc.prefix)
            seed = get_seed(self.rnd)
            cfunc.rnd = create_rnd(seed)
            cfunc.run = run

        self._warn_about_suspicious_changes()
Пример #4
0
def test_get_by_dotted_path():
    assert get_by_dotted_path({'a': 12}, 'a') == 12
    assert get_by_dotted_path({'a': 12}, '') == {'a': 12}
    assert get_by_dotted_path({'foo': {'a': 12}}, 'foo.a') == 12
    assert get_by_dotted_path({'foo': {'a': 12}}, 'foo.b') is None
Пример #5
0
def test_get_by_dotted_path():
    assert get_by_dotted_path({"a": 12}, "a") == 12
    assert get_by_dotted_path({"a": 12}, "") == {"a": 12}
    assert get_by_dotted_path({"foo": {"a": 12}}, "foo.a") == 12
    assert get_by_dotted_path({"foo": {"a": 12}}, "foo.b") is None
Пример #6
0
def test_get_by_dotted_path():
    assert get_by_dotted_path({'a': 12}, 'a') == 12
    assert get_by_dotted_path({'a': 12}, '') == {'a': 12}
    assert get_by_dotted_path({'foo': {'a': 12}}, 'foo.a') == 12
    assert get_by_dotted_path({'foo': {'a': 12}}, 'foo.b') is None
Пример #7
0
def get_logs(key, _run):
    logs = _run.info.get('logs', {})
    return get_by_dotted_path(logs, key)