Skip to content

Commit 2ed20d2

Browse files
author
Abhilash Joseph C
committed
Added few testcase for testcase run
1 parent e6d85e7 commit 2ed20d2

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

resttest3/testcase.py

+9
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,14 @@ def auth_username(self):
332332
def auth_username(self, username):
333333
self.__auth_username = Parser.coerce_string_to_ascii(username)
334334

335+
@property
336+
def ssl_insecure(self):
337+
return self.__ssl_insecure
338+
339+
@ssl_insecure.setter
340+
def ssl_insecure(self, val):
341+
self.__ssl_insecure = bool(val)
342+
335343
@property
336344
def auth_password(self):
337345
return self.__auth_password
@@ -618,6 +626,7 @@ def run(self, context=None, timeout=None, curl_handler=None):
618626
except pycurl.error:
619627
curl_handler = pycurl.Curl()
620628
curl_handler.setopt(pycurl.CAINFO, certifi.where()) # Fix for #29
629+
curl_handler.setopt(pycurl.FOLLOWLOCATION, 1) # Support for HTTP 301
621630
else:
622631
curl_handler = pycurl.Curl()
623632

tests/test_testcase.py

+15
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from inspect import getframeinfo, currentframe
33
from pathlib import Path
44

5+
import pycurl
56
import yaml
67

78
from resttest3.binding import Context
@@ -140,6 +141,20 @@ def test_include(self):
140141
ts.parse('', [{'import': 'tests/content-test.yaml'}])
141142
self.assertEqual(1, len(ts.test_group_list_dict))
142143

144+
def test_pycurl_run(self):
145+
x = TestCase('https://api.github.com', None, None, None, None)
146+
x.run()
147+
self.assertEqual(True, x.is_passed)
148+
x.ssl_insecure = True
149+
x.run()
150+
self.assertEqual(True, x.is_passed)
151+
curl_handler = pycurl.Curl()
152+
x.run(curl_handler=curl_handler)
153+
self.assertEqual(True, x.is_passed)
154+
curl_handler.close()
155+
x.run(curl_handler=curl_handler)
156+
self.assertEqual(True, x.is_passed)
157+
143158

144159
if __name__ == '__main__':
145160
unittest.main()

0 commit comments

Comments
 (0)