@@ -33,46 +33,17 @@ def tearDown(self):
3333 except FileNotFoundError :
3434 pass
3535
36- def testDemoClassic (self ):
37- with captured_output () as (out , err ):
38- install_demo (self .home , 'anydbm' , 'classic' )
39- output = out .getvalue ().strip ()
40- print (output )
41-
42- # dummy up the return of get_server so the serve_forever method
43- # raises keyboard interrupt exiting the server so the test exits.
44- gs = roundup .scripts .roundup_server .ServerConfig .get_server
45- def raise_KeyboardInterrupt ():
46- raise KeyboardInterrupt
47-
48- def test_get_server (self ):
49- httpd = gs (self )
50- httpd .serve_forever = raise_KeyboardInterrupt
51- return httpd
52-
53- roundup .scripts .roundup_server .ServerConfig .get_server = test_get_server
54-
55- # Run under context manager to capture output of startup text.
56- with captured_output () as (out , err ):
57- run_demo (self .home )
58- output = out .getvalue ().strip ()
59- print (output )
60- # if the server installed and started this will be the
61- # last line in the output.
62- self .assertIn ("Keyboard Interrupt: exiting" , output .split ('\n ' ))
63-
64- def testDemoMinimal (self ):
36+ def run_install_demo (self , template , db = "anydbm" ):
6537 with captured_output () as (out , err ):
66- # use a modified path that resolves when
67- install_demo (self .home , 'sqlite' , '../templates/minimal' )
38+ install_demo (self .home , db , template )
6839 output = out .getvalue ().strip ()
6940 print (output )
7041
7142 # verify that db was set properly by reading config
7243 with open (self .home + "/config.ini" , "r" ) as f :
7344 config_lines = f .readlines ()
7445
75- self .assertIn ("backend = sqlite \n " , config_lines )
46+ self .assertIn ("backend = %s \n " % db , config_lines )
7647
7748 # dummy up the return of get_server so the serve_forever method
7849 # raises keyboard interrupt exiting the server so the test exits.
@@ -96,36 +67,18 @@ def test_get_server(self):
9667 # last line in the output.
9768 self .assertIn ("Keyboard Interrupt: exiting" , output .split ('\n ' ))
9869
70+ def testDemoClassic (self ):
71+ self .run_install_demo ("classic" )
72+
73+ def testDemoMinimal (self ):
74+ self .run_install_demo ('../templates/minimal' , db = "sqlite" )
75+
9976 def testDemoJinja (self ):
100- with captured_output () as (out , err ):
101- install_demo (self .home , 'anydbm' , 'jinja2' )
102- output = out .getvalue ().strip ()
103- print (output )
77+ self .run_install_demo ('jinja2' , db = "anydbm" )
10478
10579 # verify that template was set to jinja2 by reading config
10680 with open (self .home + "/config.ini" , "r" ) as f :
10781 config_lines = f .readlines ()
10882
10983 self .assertIn ("template_engine = jinja2\n " , config_lines )
11084
111- # dummy up the return of get_server so the serve_forever method
112- # raises keyboard interrupt exiting the server so the test exits.
113- gs = roundup .scripts .roundup_server .ServerConfig .get_server
114- def raise_KeyboardInterrupt ():
115- raise KeyboardInterrupt
116-
117- def test_get_server (self ):
118- httpd = gs (self )
119- httpd .serve_forever = raise_KeyboardInterrupt
120- return httpd
121-
122- roundup .scripts .roundup_server .ServerConfig .get_server = test_get_server
123-
124- # Run under context manager to capture output of startup text.
125- with captured_output () as (out , err ):
126- run_demo (self .home )
127- output = out .getvalue ().strip ()
128- print (output )
129- # if the server installed and started this will be the
130- # last line in the output.
131- self .assertIn ("Keyboard Interrupt: exiting" , output .split ('\n ' ))
0 commit comments