33import sys , os
44import types
55import py
6+ import pytest
67import time
78import re
89
@@ -101,7 +102,7 @@ def test_basic_connection_with_bad_api_key():
101102 """
102103 BOGUS_API_KEY = "_ABC123DEF456GHI789JKL012MNO345PQR678STUVZ"
103104 expectedErrMsg = 'Invalid credentials'
104- with py . test .raises (RallyRESTAPIError ) as excinfo :
105+ with pytest .raises (RallyRESTAPIError ) as excinfo :
105106 rally = Rally (
PROD ,
"[email protected] " ,
"manict0X0" ,
apikey = BOGUS_API_KEY )
106107 actualErrVerbiage = excinfo .value .args [0 ]
107108 assert excinfo .value .__class__ .__name__ == 'RallyRESTAPIError'
@@ -117,7 +118,7 @@ def test_basic_connection_with_good_up_and_bad_api_key():
117118 """
118119 BOGUS_API_KEY = "_ABC123DEF456GHI789JKL012MNO345PQR678STUVZ"
119120 expectedErrMsg = 'Invalid credentials'
120- with py . test .raises (RallyRESTAPIError ) as excinfo :
121+ with pytest .raises (RallyRESTAPIError ) as excinfo :
121122 rally = Rally (PROD , user = PROD_USER , password = PROD_PSWD , apikey = BOGUS_API_KEY )
122123 actualErrVerbiage = excinfo .value .args [0 ]
123124 assert expectedErrMsg == actualErrVerbiage
@@ -134,7 +135,7 @@ def test_nonexistent_server():
134135 bogus_server = "bogus.notreally.bug"
135136 expectedErrMsg = "Target Rally host: '%s' non-existent or unreachable" % bogus_server
136137 #print expectedErrMsg
137- with py . test .raises (RallyRESTAPIError ) as excinfo :
138+ with pytest .raises (RallyRESTAPIError ) as excinfo :
138139 rally = Rally (server = bogus_server )
139140 actualErrVerbiage = excinfo .value .args [0 ] # becuz Python2.6 deprecates message :-(
140141 #print actualErrVerbiage
@@ -155,14 +156,12 @@ def test_non_rally_server():
155156 non_rally_server = 'www.irs.gov'
156157 #non_rally_server = 'www.espn.com'
157158
158- with py . test . raises (RallyRESTAPIError ) as excinfo :
159+ with pytest . raises (RallyRESTAPIError ) as exc :
159160 rally = Rally (server = non_rally_server , timeout = 5 )
160- print ("Exception typename: %s" % excinfo .typename )
161- actualErrVerbiage = excinfo .value .args [0 ] # becuz Python2.6 deprecates message :-(
162- print (actualErrVerbiage )
163- expectedErrMsg = "Target host: '%s' is either not reachable or " % non_rally_server
164- ex_value_mo = re .search (expectedErrMsg , actualErrVerbiage )
165- assert ex_value_mo is not None
161+ print ("Exception typename: %s" % exc .typename )
162+ print (str (exc ))
163+ expected_error = "404 Target host: 'www.irs.gov' is either not reachable or doesn't support the Rally WSAPI"
164+ assert expected_error in str (exc )
166165 time .sleep (1 )
167166
168167
@@ -175,13 +174,13 @@ def test_bad_server_spec():
175174 The status_code in the response must indicate a non-success condition.
176175 """
177176 bad_server = "ww!w.\f o,o\r \n .c%om"
178- expectedErrMsg = "404 Target host: 'ww!w.\x0c o,o\r \n .c%om' is either not reachable or doesn't support the Rally WSAPI"
177+ expectedErrMsg = "host: 'ww!w.\x0c o,o\r \n .c%om' is either not reachable or doesn't support the Rally WSAPI"
179178 print ("expectedErrMesssage |{0}|" .format (expectedErrMsg ))
180- with py . test . raises (RallyRESTAPIError ) as excinfo :
179+ with pytest . raises (RallyRESTAPIError ) as exc :
181180 rally = Rally (server = bad_server , timeout = 3 )
182- actualErrVerbiage = excinfo .value .args [0 ] # becuz Python2.6 deprecates message :-(
181+ actualErrVerbiage = exc .value .args [0 ]
183182 print ("actualErrVerbiage |{0}|" .format (actualErrVerbiage ))
184- assert actualErrVerbiage == expectedErrMsg
183+ assert expectedErrMsg in actualErrVerbiage
185184 time .sleep (1 )
186185
187186
@@ -200,7 +199,7 @@ def test_insuff_credentials():
200199 """
201200 expectedErrMsg = 'Invalid credentials'
202201
203- with py . test .raises (RallyRESTAPIError ) as excinfo :
202+ with pytest .raises (RallyRESTAPIError ) as excinfo :
204203 rally = Rally (server = RALLY , user = RALLY_USER , password = "" )
205204 response = rally .get ('Project' , fetch = False , limit = 10 )
206205 actualErrVerbiage = excinfo .value .args [0 ] # becuz Python2.6 deprecates message :-(
@@ -209,7 +208,7 @@ def test_insuff_credentials():
209208 #print "detected valid user, missing password condition"
210209 time .sleep (1 )
211210
212- with py . test .raises (RallyRESTAPIError ) as excinfo :
211+ with pytest .raises (RallyRESTAPIError ) as excinfo :
213212 rally = Rally (server = RALLY , user = "" , password = "doofus" )
214213 response = rally .get ('Project' , fetch = False , limit = 10 )
215214 actualErrVerbiage = excinfo .value .args [0 ] # becuz Python2.6 deprecates message :-(
@@ -218,7 +217,7 @@ def test_insuff_credentials():
218217 #print "detected blank user, invalid password condition"
219218 time .sleep (1 )
220219
221- with py . test .raises (RallyRESTAPIError ) as excinfo :
220+ with pytest .raises (RallyRESTAPIError ) as excinfo :
222221 rally = Rally (server = RALLY , user = "" , password = "" )
223222 response = rally .get ('Project' , fetch = False , limit = 10 )
224223 actualErrVerbiage = excinfo .value .args [0 ] # becuz Python2.6 deprecates message :-(
@@ -227,7 +226,7 @@ def test_insuff_credentials():
227226 #print "detected blank user and password condition"
228227 time .sleep (1 )
229228
230- with py . test .raises (RallyRESTAPIError ) as excinfo :
229+ with pytest .raises (RallyRESTAPIError ) as excinfo :
231230 rally = Rally (server = RALLY , user = "guest" , password = "" )
232231 response = rally .get ('Project' , fetch = False , limit = 10 )
233232 actualErrVerbiage = excinfo .value .args [0 ] # becuz Python2.6 deprecates message :-(
@@ -236,7 +235,7 @@ def test_insuff_credentials():
236235 #print "detected invalid user, blank password condition"
237236 time .sleep (1 )
238237
239- with py . test .raises (RallyRESTAPIError ) as excinfo :
238+ with pytest .raises (RallyRESTAPIError ) as excinfo :
240239 rally = Rally (server = RALLY , user = "guest" , password = "doofus" )
241240 response = rally .get ('Project' , fetch = False , limit = 10 )
242241 actualErrVerbiage = excinfo .value .args [0 ] # becuz Python2.6 deprecates message :-(
@@ -245,7 +244,7 @@ def test_insuff_credentials():
245244 #print "detected invalid user, invalid password condition"
246245 time .sleep (1 )
247246
248- with py . test .raises (RallyRESTAPIError ) as excinfo :
247+ with pytest .raises (RallyRESTAPIError ) as excinfo :
249248 rally = Rally (server = RALLY , user = "guest" )
250249 response = rally .get ('Project' , fetch = False , limit = 10 )
251250 actualErrVerbiage = excinfo .value .args [0 ] # becuz Python2.6 deprecates message :-(
0 commit comments