svanoort / pyresttest

Python Rest Testing
Apache License 2.0
1.15k stars 325 forks source link

override user-agent will be ignored #188

Closed thebino closed 8 years ago

thebino commented 8 years ago

I've a case, where the api result depends on the user-agent so I try to override it for some test cases but it is ignored completly:

User-Agent: PycURL/7.43.0 libcurl/7.43.0 SecureTransport zlib/1.2.5
svanoort commented 8 years ago

Hi @thebino ,

PyRestTest offers an option to pass in custom Curl options to the tests (if there's something special which the framework does not support): https://github.com/svanoort/pyresttest#custom-http-options-special-curl-settings

In this case what you want is 'curl_option_useragent' with the new user agent. I hope that helps? PS: there's a whole list of custom options for Curl that you can use - to get the PyRestTest option name, replace 'curlopt_' with 'curloption'.

If you get too fancy though, do please note that PyRestTest does not do validation on these, beyond checking that they are valid option names with PyCurl, so it is possible to get runtime errors in the tests if you specify the wrong argument type or an invalid value.

Kind regards, Sam

thebino commented 8 years ago

brilliant, works for me as intended. Thanks for the fast response.