import configparser
import os

import pytest

CWD = os.path.dirname(os.path.realpath(__file__))

config = configparser.ConfigParser()


@pytest.fixture(scope="session", autouse=True)
def headless():
    config_file = os.path.join(CWD, "fixtures.ini")
    dev_config = _read_config_section(config_file, 'dev')
    return _str_to_bool(dev_config["headless"])


def _read_config_section(source, section):
    config.read(source)
    return config[section]


def _str_to_bool(s):
    return s.lower() in ['true', '1', 'yes']
