|
import sys |
|
import logging |
|
|
|
if sys.version_info[:2] < (2, 7): |
|
|
|
|
|
import unittest2 as unittest |
|
else: |
|
import unittest |
|
|
|
|
|
class Oauth2TestCase(unittest.TestCase): |
|
|
|
logger = logging.getLogger(__file__) |
|
|
|
def assertLoosely(self, response, assertion=None, |
|
skippable_errors=("invalid_grant", "interaction_required")): |
|
if response.get("error") in skippable_errors: |
|
self.logger.debug("Response = %s", response) |
|
|
|
raise unittest.SkipTest(response.get("error_description")) |
|
else: |
|
if assertion is None: |
|
assertion = lambda: self.assertIn("access_token", response) |
|
assertion() |
|
|
|
|