当前位置: 首页>>代码示例>>Python>>正文


Python CONTEXT.copy方法代码示例

本文整理汇总了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)
开发者ID:2cadz,项目名称:nereid,代码行数:26,代码来源:test_dispatch.py

示例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([{}])
开发者ID:kret0s,项目名称:gnuhealth-live,代码行数:32,代码来源:test_access.py


注:本文中的trytond.tests.test_tryton.CONTEXT.copy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。