Python enum parameterization

We are experiencing an issue with python ENUMs not being mergeable in a test plan. If there are multiple test steps with the same enum, we find that we cannot parameterize them to the same parameter at a higher level.

One of the parameters seems to overwrite the other instead of sharing the same source parameter. When changing the top level parameter, it will change one of the lower level properties and throw this error.
image

Is there an issue with python enums being parameterized in 9.20+?

Did this work in a previous version?

Yes, This works in OpenTap 9.19.4

@alexander.larsen do you have any idea what may have changed here?

@brennen_direnzo I don’t know what causes this in particular, but if it’s a 9.20 regression, then it was likely introduced by https://github.com/opentap/opentap/pull/1001. I will look into it

1 Like

Hi @davihous

I was trying to reproduce your issue, but I am unable to merge enums even in 9.19.4. Can you share a simple example which works in 9.19.4, but not in 9.20?

For reference, this is what I tried:

from opentap import *
import OpenTap
from enum import Enum

class SimpleEnum(Enum):
    ONE = 1
    TWO = 2
    THREE = 3


@attribute(OpenTap.Display("My Enum Step", "Simple Enum Step", "PyEnums"))
class MyEnumStep (TestStep):
    MySimpleEnum = property(SimpleEnum, SimpleEnum.TWO)
    def __init__(self):
        super(MyEnumStep, self).__init__()
    
    def Run(self):
        self.log.Debug("Enum: {0}", str(self.MySimpleEnum))

When I try to merge this enum on a parent step, OpenTAP tells me that properties of this kind cannot be merged. How did you make this work with 9.19.4?

Hi @alexander.larsen ,

To build off of your code I adjusted as follows:

from opentap import *
import OpenTap
from enum import Enum

class SimpleEnum(Enum):
    ONE = 1
    TWO = 2
    THREE = 3


@attribute(OpenTap.Display("My Enum Step", "Simple Enum Step", "PyEnums"))
class MyEnumStep (TestStep):
    MySimpleEnum = property(SimpleEnum, SimpleEnum.TWO)
    def __init__(self):
        super(MyEnumStep, self).__init__()
    
    def Run(self):
        self.log.Debug("Enum: {0}", str(self.MySimpleEnum))

@attribute(OpenTap.Display("My Other Enum Step", "Simple Enum Step", "PyEnums"))
class MyOtherEnumStep (TestStep):
    MySimpleEnum = property(SimpleEnum, SimpleEnum.TWO)
    def __init__(self):
        super(MyOtherEnumStep, self).__init__()
    
    def Run(self):
        self.log.Debug("Enum: {0}", str(self.MySimpleEnum))

Now I make a tap plan with the steps in a sequence. I parameterize MyEnumStep.MySimpleEnum just fine, but I get an issue trying to parameterize MyOtherEnumStep.MySimpleEnum.

@alexander.larsen

I was mistaken in the plugin that broke it. It was the Python plugin. 3.0.0 works and 3.0.1 does not

Okay thanks, that makes more sense. I can confirm merging python Enums works with 3.0.0, but not with 3.0.1. Thanks for clarifying. @rolf_madsen do you know what happened?

I have opened an issue here: Enum values cannot be multi-selected or cloned · Issue #108 · opentap/OpenTap.Python · GitHub

1 Like