Forum Discussion

oriShalhon's avatar
oriShalhon
Occasional Contributor
2 years ago

Python workflow and imports

Hi, 

 

Trying to perform import between nested files and classes similarly to any other python project does not seem to work on testComplete. 

 

The case is as such: 

I have under script Dir two directories (A, B) with 1 script file in each dir (a.py, b.py) each file has the definition of a class(ClassA, ClassB)

 

Trying to import using nested syntax doesn't work :

 

from A.a import ClassA 

 

class ClassB(ClassA):.....

 

is there a specific syntax for import behavior working in python on TestComplete?

 

Thanks!

 

6 Replies

  • oriShalhon's avatar
    oriShalhon
    Occasional Contributor

    This does not answer what I intended. 
    In most python IDES you can freely make nested folders to organize your project. 

     

    Is it possible when working with testComplete?

     

    I want the hierarchy to be 

    folderClassA--> ClassA.py --> ClassA object 

     

    FolderClassB -->ClassB.py --> ClassB object 

     

    and I want to know if it is possible to perform the imports of nested files (similarly to every other IDES as already mentioned): 

    "From folderClassA.ClassA import ClassA "

     

     

     

  • mcpm's avatar
    mcpm
    New Contributor

    Hi,

     

    one thing - are you aware that folders in Test Complete are sort of "virtuals", only for presentation purposes? I mean, despite you create and see folders in TestComplete (under script group) files are stored in flat stucture in hard disk (in Script folder). So in your case solution would be like that I guess:

     

    from a import ClassA 
    
    class ClassB(ClassA):
       pass

     

     

    • cvanvlack's avatar
      cvanvlack
      Occasional Contributor

      So if one were to use a different editor (e.g. VS Code) to create a bunch of helper functions in nested folders it sounds like I would need to pull all of that code into the "Script" folder as the paths between the .py files aren't respected?