# Python enum parameterization

**URL:** <https://forum.opentap.io/t/python-enum-parameterization/1085>\
**Category:** General\
**Created:** [April 4, 2023, 4:58pm UTC](https://forum.opentap.io/t/python-enum-parameterization/1085 "2023-04-04T16:58:16Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![davihous](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@davihous](https://forum.opentap.io/u/davihous)\
**Post date:** [April 4, 2023, 4:58pm UTC](https://forum.opentap.io/t/python-enum-parameterization/1085/1 "2023-04-04T16:58:16Z")

</div>

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](https://us1.discourse-cdn.com/flex020/uploads/opentap/original/1X/883dd15e8a8746356fe3dd194bfd97edad234c89.png)

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

---

<div class="post-metadata">

**Author:** ![alan\_copeland](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@alan\_copeland](https://forum.opentap.io/u/alan_copeland)\
**Post date:** [April 5, 2023, 3:00pm UTC](https://forum.opentap.io/t/python-enum-parameterization/1085/2 "2023-04-05T15:00:02Z")

</div>

> [@davihous](#):
>
> , we find that we cannot parameterize them to the same parameter at a higher level.
> 
> One

Did this work in a previous version?

---

<div class="post-metadata">

**Author:** ![davihous](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@davihous](https://forum.opentap.io/u/davihous)\
**Post date:** [April 5, 2023, 3:12pm UTC](https://forum.opentap.io/t/python-enum-parameterization/1085/3 "2023-04-05T15:12:35Z")

</div>

Yes, This works in OpenTap 9.19.4

---

<div class="post-metadata">

**Author:** ![brennen\_direnzo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opentap.io/brennen_direnzo/32/6_2.png) [@brennen\_direnzo](https://forum.opentap.io/u/brennen_direnzo)\
**Post date:** [April 6, 2023, 11:20am UTC](https://forum.opentap.io/t/python-enum-parameterization/1085/4 "2023-04-06T11:20:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![alexander.larsen](https://avatars.discourse-cdn.com/v4/letter/a/9d8465/32.png) [@alexander.larsen](https://forum.opentap.io/u/alexander.larsen)\
**Post date:** [April 11, 2023, 7:24am UTC](https://forum.opentap.io/t/python-enum-parameterization/1085/5 "2023-04-11T07:24:03Z")

</div>

@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](https://github.com/opentap/opentap/pull/1001). I will look into it

---

<div class="post-metadata">

**Author:** ![alexander.larsen](https://avatars.discourse-cdn.com/v4/letter/a/9d8465/32.png) [@alexander.larsen](https://forum.opentap.io/u/alexander.larsen)\
**Post date:** [April 20, 2023, 8:45am UTC](https://forum.opentap.io/t/python-enum-parameterization/1085/6 "2023-04-20T08:45:34Z")

</div>

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:

```python
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?

---

<div class="post-metadata">

**Author:** ![davihous](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@davihous](https://forum.opentap.io/u/davihous)\
**Post date:** [April 20, 2023, 2:48pm UTC](https://forum.opentap.io/t/python-enum-parameterization/1085/7 "2023-04-20T14:48:30Z")

</div>

Hi @alexander.larsen ,

To build off of your code I adjusted as follows:

```csharp
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.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/opentap/original/1X/748cd3ea67310523fb7a3d7c9386d6e99f5a1b3a.png)

 ![image](https://us1.discourse-cdn.com/flex020/uploads/opentap/original/1X/7825a485ca9cabbf7b9d353fa6eb0717db029060.png)

---

<div class="post-metadata">

**Author:** ![davihous](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@davihous](https://forum.opentap.io/u/davihous)\
**Post date:** [April 20, 2023, 3:37pm UTC](https://forum.opentap.io/t/python-enum-parameterization/1085/8 "2023-04-20T15:37:30Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![alexander.larsen](https://avatars.discourse-cdn.com/v4/letter/a/9d8465/32.png) [@alexander.larsen](https://forum.opentap.io/u/alexander.larsen)\
**Post date:** [April 21, 2023, 7:25am UTC](https://forum.opentap.io/t/python-enum-parameterization/1085/9 "2023-04-21T07:25:53Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![rolf\_madsen](https://avatars.discourse-cdn.com/v4/letter/r/43a26b/32.png) [@rolf\_madsen](https://forum.opentap.io/u/rolf_madsen)\
**Post date:** [April 21, 2023, 1:53pm UTC](https://forum.opentap.io/t/python-enum-parameterization/1085/10 "2023-04-21T13:53:33Z")

</div>

I have opened an issue here: [Enum values cannot be multi-selected or cloned · Issue #108 · opentap/OpenTap.Python · GitHub](https://github.com/opentap/OpenTap.Python/issues/108)
