blob: a329c7d43c2b60e8f44493820b3ae6e3c5b6f731 [file] [log] [blame]
# -*- coding: utf-8 -*-
# Copyright 2020 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Configuration and fixtures for pytest.
See the following doc link for an explanation of and how it is used
by pytest:
from __future__ import print_function
import pytest
import chromite as cr
def overlay_stack(tmp_path_factory):
"""Factory for stacked Portage overlays.
The factory function takes an integer argument and returns an iterator of
that many overlays, each of which has all prior overlays as masters.
def make_overlay_stack(height):
if not height <= len(cr.test.Overlay.HIERARCHY_NAMES):
raise ValueError(
'Overlay stacks taller than %s are not supported. Received: %s' %
(len(cr.test.Overlay.HIERARCHY_NAMES), height))
overlays = []
for i in range(height):
'overlay-' + cr.test.Overlay.HIERARCHY_NAMES[i]),
yield overlays[i]
return make_overlay_stack
# pylint: disable=redefined-outer-name
def simple_sysroot(overlay_stack, tmp_path):
"""Create the simplest possible sysroot."""
# pylint: disable=redefined-outer-name
overlay, = overlay_stack(1)
profile = overlay.create_profile()
return cr.test.Sysroot(tmp_path, profile, [overlay])