~larry-e-works/uci-engine/amqp-to-kombu

« back to all changes in this revision

Viewing changes to cupstream2distro/tests/system/__init__.py

  • Committer: Francis Ginther
  • Date: 2014-06-10 20:42:46 UTC
  • mto: This revision was merged to the branch mainline in revision 571.
  • Revision ID: francis.ginther@canonical.com-20140610204246-b1bsrik7nlcolqy7
Import lp:cupstream2distro rev 605.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
# Copyright: (C) 2013 Canonical
 
3
#
 
4
# Authors:
 
5
#  Didier Roche
 
6
#
 
7
# This program is free software; you can redistribute it and/or modify it under
 
8
# the terms of the GNU General Public License as published by the Free Software
 
9
# Foundation; version 3.
 
10
#
 
11
# This program is distributed in the hope that it will be useful, but WITHOUT
 
12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
13
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
14
# details.
 
15
#
 
16
# You should have received a copy of the GNU General Public License along with
 
17
# this program; if not, write to the Free Software Foundation, Inc.,
 
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
19
 
 
20
 
 
21
import os
 
22
 
 
23
from ..tools import basetestcase
 
24
 
 
25
 
 
26
class BaseSystemTestCase(basetestcase.BaseTestCase):
 
27
    '''Base system test case module, remove all mocks from PATH
 
28
 
 
29
    Note that BaseSystemTestCase cleanswap the double BranchHandlingTests import (with PATH change) due to nosetests.
 
30
    So we need it to be inherited *first* by subclasses to be the last executed'''
 
31
 
 
32
    @classmethod
 
33
    def setUpClass(cls):
 
34
        super(BaseSystemTestCase, cls).setUpClass()
 
35
        cls.removeFromPath(os.path.join("mocks", "offline"))
 
36
        cls.removeFromPath(os.path.join("mocks", "online"))
 
37
 
 
38
 
 
39
class BaseSystemTestCaseWithErrors(BaseSystemTestCase):
 
40
    '''Base system test case module, simulating errors in mock objects'''
 
41
 
 
42
    def setUp(self):
 
43
        '''Reset the error mode to 1'''
 
44
        super(BaseSystemTestCaseWithErrors, self).setUp()
 
45
        os.environ['MOCK_ERROR_MODE'] = "1"
 
46
 
 
47
    @classmethod
 
48
    def tearDownClass(cls):
 
49
        super(BaseSystemTestCaseWithErrors, cls).setUpClass()
 
50
        try:
 
51
            os.environ.pop('MOCK_ERROR_MODE')
 
52
        except:
 
53
            pass