import os


def open_file(filename):
    ''' Load a file from the fixtures directory. '''
    path = 'fixtures/' + filename
    if ('tests' in os.listdir('.')):
        path = 'tests/' + path
    return open(path, mode='rb')

import os


def open_file(filename, mode='rb'):
    ''' Load a file from the fixtures directory. '''
    path = 'fixtures/' + filename
    if ('tests' in os.listdir('.')):
        path = 'tests/' + path
    return open(path, mode=mode)

Support opening files as text streams on tests
Support opening files as text streams on tests
