File: __init__.py

package info (click to toggle)
microsoft-authentication-library-for-python 1.34.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,320 kB
  • sloc: python: 8,613; xml: 2,783; sh: 27; makefile: 19
file content (26 lines) | stat: -rw-r--r-- 882 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import sys
import logging

if sys.version_info[:2] < (2, 7):
    # The unittest module got a significant overhaul in Python 2.7,
    # so if we're in 2.6 we can use the backported version unittest2.
    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)
            # Some of these errors are configuration issues, not library issues
            raise unittest.SkipTest(response.get("error_description"))
        else:
            if assertion is None:
                assertion = lambda: self.assertIn("access_token", response)
            assertion()