@@ -17,12 +17,12 @@ class AppTest:
1717 settings = dict (
1818 PrintConfigAtStartUp = False
1919 )
20- bufferOutput = True # set to False if you want to run pdb inside a test to debug it.
20+ catchOutput = True # set to False if you want to run pdb inside a test
2121
2222 @classmethod
2323 def setUpClass (cls ):
2424 stdout , stderr = sys .stdout , sys .stderr
25- if cls .bufferOutput :
25+ if cls .catchOutput :
2626 sys .stdout = sys .stderr = StringIO ()
2727 cls .currentDir = getcwd ()
2828 import webware
@@ -37,7 +37,7 @@ def setUpClass(cls):
3737 else :
3838 error = None
3939 finally :
40- if cls .bufferOutput :
40+ if cls .catchOutput :
4141 output = sys .stdout .getvalue ().rstrip ()
4242 sys .stdout , sys .stderr = stdout , stderr
4343 else :
@@ -46,46 +46,47 @@ def setUpClass(cls):
4646 raise RuntimeError (
4747 'Error setting up application:\n ' + error +
4848 '\n Output was:\n ' + output )
49- if cls .bufferOutput :
50- if ( not output .startswith ('Webware for Python' )
51- or 'Running in development mode' not in output
52- or 'Loading context' not in output ):
53- raise AssertionError (
54- 'Application was not properly started.'
55- ' Output was:\n ' + output )
49+ if cls .catchOutput and not (
50+ output .startswith ('Webware for Python' )
51+ and 'Running in development mode' in output
52+ and 'Loading context' in output ):
53+ raise AssertionError (
54+ 'Application was not properly started.'
55+ ' Output was:\n ' + output )
5656
5757 @classmethod
5858 def tearDownClass (cls ):
5959 stdout , stderr = sys .stdout , sys .stderr
60- if cls .bufferOutput :
60+ if cls .catchOutput :
6161 sys .stdout = sys .stderr = StringIO ()
6262 cls .app .shutDown ()
63- if cls .bufferOutput :
63+ if cls .catchOutput :
6464 output = sys .stdout .getvalue ().rstrip ()
6565 sys .stdout , sys .stderr = stdout , stderr
6666 else :
6767 output = ''
6868 chdir (cls .currentDir )
69- if cls .bufferOutput and output != ('Application is shutting down...\n '
70- 'Application has been successfully shutdown.' ):
69+ if cls .catchOutput and output != (
70+ 'Application is shutting down...\n '
71+ 'Application has been successfully shutdown.' ):
7172 raise AssertionError (
7273 'Application was not properly shut down. Output was:\n '
7374 + output )
7475
7576 def setUp (self ):
7677 self .stdout , self .stderr = sys .stdout , sys .stderr
77- if self .bufferOutput :
78+ if self .catchOutput :
7879 sys .stdout = sys .stderr = StringIO ()
7980
8081 def tearDown (self ):
81- if self .bufferOutput :
82+ if self .catchOutput :
8283 self .output = sys .stdout .getvalue ().rstrip ()
8384 sys .stdout , sys .stderr = self .stdout , self .stderr
8485 else :
8586 self .output = ''
8687
8788 def run (self , result = None ):
8889 result = super ().run (result ) # pylint: disable=no-member
89- if not result .wasSuccessful () and self .bufferOutput and self . output :
90+ if not result .wasSuccessful () and self .output :
9091 print ("Application output was:" )
9192 print (self .output )
0 commit comments