# Path: stestr/tests/base.py
# class TestCase(testtools.TestCase):
#     def setUp(self):
# 
# Path: stestr/user_config.py
# def get_user_config(path=None):
#     def __init__(self, path):
#     def run(self):
#     def failing(self):
#     def last(self):
#     def load(self):
#     def history_list(self):
#     def history_show(self):
# class UserConfig:


import io
import os
from unittest import mock
from stestr.tests import base
from stestr import user_config
            if path == self.home_path:
                return True
            else:
                return False

        path_mock.side_effect = fake_isfile
        user_config.get_user_config()
        user_mock.assert_called_once_with(self.home_path)

    @mock.patch('yaml.safe_load', return_value={})
    @mock.patch('builtins.open', mock.mock_open())
    def test_user_config_empty_schema(self, yaml_mock):
        user_conf = user_config.UserConfig('/path')
        self.assertEqual({}, user_conf.config)

    @mock.patch('yaml.safe_load',
                return_value={'init': {'subunit-trace': True}})
    @mock.patch('sys.exit')
    @mock.patch('builtins.open', mock.mock_open())
    def test_user_config_invalid_command(self, exit_mock, yaml_mock):
        user_config.UserConfig('/path')
        error_string = ("Provided user config file /path is invalid because:\n"
                        "extra keys not allowed @ data['init']")
        exit_mock.assert_called_once_with(error_string)

    @mock.patch('yaml.safe_load',
                return_value={'run': {'subunit-trace': True}})
    @mock.patch('sys.exit')
    @mock.patch('builtins.open', mock.mock_open())
    def test_user_config_invalid_option(self, exit_mock, yaml_mock):

# Path: stestr/tests/base.py
# class TestCase(testtools.TestCase):
#     def setUp(self):
# 
# Path: stestr/user_config.py
# def get_user_config(path=None):
#     def __init__(self, path):
#     def run(self):
#     def failing(self):
#     def last(self):
#     def load(self):
#     def history_list(self):
#     def history_show(self):
# class UserConfig:


# Path: stestr/tests/test_user_config.py
import io
import os
from unittest import mock
from stestr.tests import base
from stestr import user_config

            if path == self.home_path:
                return True
            else:
                return False

        path_mock.side_effect = fake_isfile
        user_config.get_user_config()
        user_mock.assert_called_once_with(self.home_path)

    @mock.patch('yaml.safe_load', return_value={})
    @mock.patch('builtins.open', mock.mock_open())
    def test_user_config_empty_schema(self, yaml_mock):
        user_conf = user_config.UserConfig('/path')
        self.assertEqual({}, user_conf.config)

    @mock.patch('yaml.safe_load',
                return_value={'init': {'subunit-trace': True}})
    @mock.patch('sys.exit')
    @mock.patch('builtins.open', mock.mock_open())
    def test_user_config_invalid_command(self, exit_mock, yaml_mock):
        user_config.UserConfig('/path')
        error_string = ("Provided user config file /path is invalid because:\n"
                        "extra keys not allowed @ data['init']")
        exit_mock.assert_called_once_with(error_string)

    @mock.patch('yaml.safe_load',
                return_value={'run': {'subunit-trace': True}})
    @mock.patch('sys.exit')
    @mock.patch('builtins.open', mock.mock_open())
    def test_user_config_invalid_option(self, exit_mock, yaml_mock):

        user_config.UserConfig('/path')