This would fail if the 'facebook' key is not present. I would suggest:

    facebook_credentials = self.testvars.get('facebook')
    self.assertTrue(facebook_credentials and facebook_credentials.get('username'), 'No facebook username setting in testvars.')
    self.assertTrue(facebook_credentials and facebook_credentials.get('password'), 'No facebook password setting in testvars.')