def project(request, pytestconfig): project_dir = get_populus_option(cmdline_option="--populus-project", ini_option="populus_project", environ_var="PYTEST_POPULUS_PROJECT", pytestconfig=pytestconfig, default=pytestconfig.args[0]) if not os.path.exists(get_json_config_file_path(project_dir)): raise FileNotFoundError( "No populus project found for testing in {project_dir}".format( project_dir=project_dir)) contracts = request.config.cache.get(CACHE_KEY_CONTRACTS, None) mtime = request.config.cache.get(CACHE_KEY_MTIME, None) project = Project(project_dir, create_config_file=True) project.fill_contracts_cache(contracts, mtime) request.config.cache.set( CACHE_KEY_CONTRACTS, normalize_object_for_json(project.compiled_contract_data), ) request.config.cache.set( CACHE_KEY_MTIME, get_latest_mtime(project.get_all_source_file_paths()), ) return project
def project(request, project_dir, user_config_path, _loaded_contract_fixtures, _loaded_test_contract_fixtures): contracts = request.config.cache.get(CACHE_KEY_CONTRACTS, None) mtime = request.config.cache.get(CACHE_KEY_MTIME, None) project = Project( project_dir=project_dir, user_config_file_path=user_config_path, ) key_value_pairs_from_fn = getattr(request.function, '_populus_config_key_value_pairs', []) key_value_pairs_from_module = getattr(request.module, '_populus_config_key_value_pairs', []) key_value_pairs = tuple( itertools.chain( key_value_pairs_from_module, key_value_pairs_from_fn, )) for key, value in key_value_pairs: if value is None: del project.config[key] else: project.config[key] = value project.fill_contracts_cache(contracts, mtime) request.config.cache.set( CACHE_KEY_CONTRACTS, normalize_object_for_json(project.compiled_contract_data), ) request.config.cache.set( CACHE_KEY_MTIME, get_latest_mtime(project.get_all_source_file_paths()), ) return project
def project(request, project_dir, user_config_path, _loaded_contract_fixtures, _loaded_test_contract_fixtures): contracts = request.config.cache.get(CACHE_KEY_CONTRACTS, None) mtime = request.config.cache.get(CACHE_KEY_MTIME, None) project = Project( project_dir=project_dir, user_config_file_path=user_config_path, ) key_value_pairs_from_fn = getattr(request.function, '_populus_config_key_value_pairs', []) key_value_pairs_from_module = getattr(request.module, '_populus_config_key_value_pairs', []) key_value_pairs = tuple(itertools.chain( key_value_pairs_from_module, key_value_pairs_from_fn, )) for key, value in key_value_pairs: if value is None: del project.config[key] else: project.config[key] = value project.fill_contracts_cache(contracts, mtime) request.config.cache.set( CACHE_KEY_CONTRACTS, normalize_object_for_json(project.compiled_contract_data), ) request.config.cache.set( CACHE_KEY_MTIME, get_latest_mtime(project.get_all_source_file_paths()), ) return project