def create_test_environment():
    """Create at test environment based on $topdir/test.cfg."""
    fname = os.path.join(topdir, 'test.cfg')
    if not os.access(fname, os.R_OK):
        m = 'Tests need to be run from a checked out source repository.'
        raise RuntimeError(m)
    config = configparser.ConfigParser()
    config.read([fname])
    def config_var(name, default=None):
        try:
            return config.get('test', name)
        except (configparser.NoSectionError, configparser.NoOptionError):
            return default
    testenv.username = config_var('username')
    testenv.password = config_var('password')
    testenv.service_url = config_var('service_url') or RavelloClient.default_url
    testenv.network_blocking = config_var('network_blocking')
    testenv.sudo_password = config_var('sudo_password')
    testenv.topdir = topdir
    testenv.testdir = testdir

# Create the test environment here. A single copy is shared by all tests.
dataset/ETHPy150Open ravello/testmill/lib/testmill/test/__init__.py/create_test_environment/original