Package buildbot :: Package util :: Module monkeypatches
[frames] | no frames]

Source Code for Module buildbot.util.monkeypatches

 1  # This file is part of Buildbot.  Buildbot is free software: you can 
 2  # redistribute it and/or modify it under the terms of the GNU General Public 
 3  # License as published by the Free Software Foundation, version 2. 
 4  # 
 5  # This program is distributed in the hope that it will be useful, but WITHOUT 
 6  # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
 7  # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
 8  # details. 
 9  # 
10  # You should have received a copy of the GNU General Public License along with 
11  # this program; if not, write to the Free Software Foundation, Inc., 51 
12  # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
13  # 
14  # Copyright Buildbot Team Members 
15   
16  import sys 
17  import twisted 
18  from twisted.trial import unittest 
19   
20 -def add_debugging_monkeypatches():
21 """ 22 DO NOT CALL THIS DIRECTLY 23 24 This adds a few "harmless" monkeypatches which make it easier to debug 25 failing tests. It is called automatically by buildbot.test.__init__. 26 """ 27 from twisted.application.service import Service 28 old_startService = Service.startService 29 old_stopService = Service.stopService 30 def startService(self): 31 assert not self.running 32 return old_startService(self)
33 def stopService(self): 34 assert self.running 35 return old_stopService(self) 36 Service.startService = startService 37 Service.stopService = stopService 38 39 # versions of Twisted before 9.0.0 did not have a UnitTest.patch that worked 40 # on Python-2.7 41 if twisted.version.major <= 9 and sys.version_info[:2] == (2,7): 42 def nopatch(self, *args): 43 raise unittest.SkipTest('unittest.TestCase.patch is not available') 44 unittest.TestCase.patch = nopatch 45