def logInManager(): """Create a Browser instance and log in as a manager.""" manager = Browser() manager.handleErrors = False manager.addHeader('Authorization', 'Basic manager:schooltool') manager.open('http://localhost/') assert 'SchoolTool' in manager.contents return manager
def setupBrowser(auth=None): """Create a testbrowser object for use in pagetests. :param auth: HTTP authentication string. None for the anonymous user, or a string of the form 'Basic email:password' for an authenticated user. :return: A `Browser` object. """ browser = Browser() # Set up our Browser objects with handleErrors set to False, since # that gives a tracebacks instead of unhelpful error messages. browser.handleErrors = False if auth is not None: browser.addHeader("Authorization", auth) return browser