本文整理汇总了Python中trytond.tests.test_tryton.CONTEXT.copy方法的典型用法代码示例。如果您正苦于以下问题:Python CONTEXT.copy方法的具体用法?Python CONTEXT.copy怎么用?Python CONTEXT.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trytond.tests.test_tryton.CONTEXT
的用法示例。
在下文中一共展示了CONTEXT.copy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_0010_test_failure_counter
# 需要导入模块: from trytond.tests.test_tryton import CONTEXT [as 别名]
# 或者: from trytond.tests.test_tryton.CONTEXT import copy [as 别名]
def test_0010_test_failure_counter(self):
context = CONTEXT.copy()
with Transaction().start(DB_NAME, USER, context=context) as txn:
self.setup_defaults()
app = self.get_app()
txn.cursor.commit()
DatabaseOperationalError = backend.get('DatabaseOperationalError')
@transaction_start.connect
def incr_error_count(app):
"""
Subscribe to the transaction_start to increment the counter
"""
self.error_counter += 1
CONFIG['retry'] = 4
with app.test_client() as c:
try:
c.get('fail-with-transaction-error')
except DatabaseOperationalError:
self.assertEqual(self.error_counter, 5)
示例2: ModelAccessTestCase
# 需要导入模块: from trytond.tests.test_tryton import CONTEXT [as 别名]
# 或者: from trytond.tests.test_tryton.CONTEXT import copy [as 别名]
# -*- coding: utf-8 -*-
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import unittest
from trytond.tests.test_tryton import POOL, DB_NAME, USER, CONTEXT, \
install_module
from trytond.transaction import Transaction
from trytond.exceptions import UserError
CONTEXT = CONTEXT.copy()
CONTEXT['_check_access'] = True
class ModelAccessTestCase(unittest.TestCase):
'Test Model Access'
def setUp(self):
install_module('tests')
self.model_access = POOL.get('ir.model.access')
self.test_access = POOL.get('test.access')
self.model = POOL.get('ir.model')
self.group = POOL.get('res.group')
def test0010perm_read(self):
'Test Read Access'
with Transaction().start(DB_NAME, USER,
context=CONTEXT) as transaction:
model, = self.model.search([('model', '=', 'test.access')])
test, = self.test_access.create([{}])