Forum Discussion

hhowe's avatar
hhowe
Occasional Contributor
7 years ago

Python __getprop__ fails

I've added the "requests" package to the ...\TestComplete 12\x64\Bin\Extensions\Python\Python36\Lib folder.

 

This code works beautifully to return the proper response using the Python installed by TestComplete (Python 3.6 with TestComplete 12.42):

 

import requests
baseURL = 'https://jira.mycompany.com'
URL = baseURL + '/rest/zapi/latest/util/project-list'
r = requests.get(URL, auth=('MyUsername', 'MyPassword'), verify="c:\shared\certs")
print (r.text)

 

This code does not work from within a Python project in TestComplete (running the x64 copy):


import requests
def TestAPICall():
   baseURL = 'https://jira.mycompany.com'
   URL = baseURL + '/rest/zapi/latest/util/project-list'
   r = requests.__getprop__('get', URL, auth=('MyUsername', 'MyPassword'), verify="c:\shared\certs")
   Log.Message(r.text)

 

The latter returns a Python runtime error:
   AttributeError: module 'requests' has no attribute '__getprop__'

 

I've also tried:

   r = requests.get(URL, auth=('MyUsername', 'MyPassword'), verify="c:\shared\certs")

which returns:

   AttributeError: module 'requests' has no attribute 'get'

 

What am I missing?

 

Thanks,

Heath

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    __getprop__ only applies to objects from your AUT, not to the requests object.

     

    Just as an experiment, what happens if you add the requests package to the ...\TestComplete 12\Bin\Extensions\Python\Python36\Lib folder as well.  Does that work better?

    • hhowe's avatar
      hhowe
      Occasional Contributor

      Thanks, Robert,

       

      That makes sense about the __getprop__ only being for tested objects' properties. It was a punt...and is always an afterthought/fix for me when the standard Python format fails on me. :-)

       

      I did copy the requests package to the x86 path, stopped and restarted the x64 version of TestComplete (just to be certain!) and get the same error on the "get" (direct requests.get, not requests.__getprop__). I also ran the x86 version of TestComplete and get the same error. It is finding the package, because I get a different error (ModuleNotFoundError: No module named 'requests') if the package is not in the right path.

       

      Good thoughts/info, though. Much appreciated. Other ideas??

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Can you inspect the "requests" object?  By that, I mean drop a break point in your test complete code and use the Evaluation tool to see what "requests" actually has in the way of properties, methods, fields, etc.  It could be that "get" might be an overloaded function in which case TestComplete might actually see get1, get2, get3, etc.