pythonpython-3.xtestcomplete

How to pass an object as a dictionary key in Python(TestComplete issue?)


I am aware dictionary keys needs to be strings or immutable objects. But I don't want to pass strings as a key. Reason is, every where I use the dictionary, I have to type exact string and leaves so mach hard coding and room for errors.

This is only happening on TestComplete (V12). Is it possible for me to do something like this,

class test():
    testStr = 'test'
    testStr2 = 'test2'

class Coverage():
     Data ={test.testStr    : True,
            test.testStr2   : 'something with white space'}

If this is a bad idea, why?


Solution

  • This seems to be a problem in TestComplete's Python parser and SmartBear has a patch for it. You can contact them to get the patch.