本文整理汇总了Python中oauth2client._helpers.positional方法的典型用法代码示例。如果您正苦于以下问题:Python _helpers.positional方法的具体用法?Python _helpers.positional怎么用?Python _helpers.positional使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oauth2client._helpers
的用法示例。
在下文中一共展示了_helpers.positional方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from oauth2client import _helpers [as 别名]
# 或者: from oauth2client._helpers import positional [as 别名]
def setUp(self):
access_token = 'foo'
client_id = 'some_client_id'
client_secret = 'cOuDdkfjxxnv+'
refresh_token = '1/0/a.df219fjls0'
token_expiry = datetime.datetime.utcnow()
user_agent = 'refresh_checker/1.0'
self.credentials = client.OAuth2Credentials(
access_token, client_id, client_secret,
refresh_token, token_expiry, oauth2client.GOOGLE_TOKEN_URI,
user_agent, revoke_uri=oauth2client.GOOGLE_REVOKE_URI,
scopes='foo', token_info_uri=oauth2client.GOOGLE_TOKEN_INFO_URI)
# Provoke a failure if @_helpers.positional is not respected.
self.old_positional_enforcement = (
_helpers.positional_parameters_enforcement)
_helpers.positional_parameters_enforcement = (
_helpers.POSITIONAL_EXCEPTION)
示例2: test_recursive_authorize
# 需要导入模块: from oauth2client import _helpers [as 别名]
# 或者: from oauth2client._helpers import positional [as 别名]
def test_recursive_authorize(self):
# Tests that OAuth2Credentials doesn't introduce new method
# constraints. Formerly, OAuth2Credentials.authorize monkeypatched the
# request method of the passed in HTTP object with a wrapper annotated
# with @_helpers.positional(1). Since the original method has no such
# annotation, that meant that the wrapper was violating the contract of
# the original method by adding a new requirement to it. And in fact
# the wrapper itself doesn't even respect that requirement. So before
# the removal of the annotation, this test would fail.
token_response = {'access_token': '1/3w', 'expires_in': 3600}
encoded_response = json.dumps(token_response).encode('utf-8')
http = http_mock.HttpMock(data=encoded_response)
http = self.credentials.authorize(http)
http = self.credentials.authorize(http)
transport.request(http, 'http://example.com')
示例3: test_usage
# 需要导入模块: from oauth2client import _helpers [as 别名]
# 或者: from oauth2client._helpers import positional [as 别名]
def test_usage(self):
_helpers.positional_parameters_enforcement = (
_helpers.POSITIONAL_EXCEPTION)
# 1 positional arg, 1 keyword-only arg.
@_helpers.positional(1)
def function(pos, kwonly=None):
return True
self.assertTrue(function(1))
self.assertTrue(function(1, kwonly=2))
with self.assertRaises(TypeError):
function(1, 2)
# No positional, but a required keyword arg.
@_helpers.positional(0)
def function2(required_kw):
return True
self.assertTrue(function2(required_kw=1))
with self.assertRaises(TypeError):
function2(1)
# Unspecified positional, should automatically figure out 1 positional
# 1 keyword-only (same as first case above).
@_helpers.positional
def function3(pos, kwonly=None):
return True
self.assertTrue(function3(1))
self.assertTrue(function3(1, kwonly=2))
with self.assertRaises(TypeError):
function3(1, 2)
示例4: test_enforcement_warning
# 需要导入模块: from oauth2client import _helpers [as 别名]
# 或者: from oauth2client._helpers import positional [as 别名]
def test_enforcement_warning(self, mock_logger):
_helpers.positional_parameters_enforcement = (
_helpers.POSITIONAL_WARNING)
@_helpers.positional(1)
def function(pos, kwonly=None):
return True
self.assertTrue(function(1, 2))
self.assertTrue(mock_logger.warning.called)
示例5: test_enforcement_ignore
# 需要导入模块: from oauth2client import _helpers [as 别名]
# 或者: from oauth2client._helpers import positional [as 别名]
def test_enforcement_ignore(self, mock_logger):
_helpers.positional_parameters_enforcement = _helpers.POSITIONAL_IGNORE
@_helpers.positional(1)
def function(pos, kwonly=None):
return True
self.assertTrue(function(1, 2))
self.assertFalse(mock_logger.warning.called)