# Child classes in test step properties

**URL:** <https://forum.opentap.io/t/child-classes-in-test-step-properties/646>\
**Category:** Technical\
**Tags:** python, plugin\
**Created:** [March 24, 2022, 1:03pm UTC](https://forum.opentap.io/t/child-classes-in-test-step-properties/646 "2022-03-24T13:03:15Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tatiana.boye](https://avatars.discourse-cdn.com/v4/letter/t/ba8739/32.png) [@tatiana.boye](https://forum.opentap.io/u/tatiana.boye)\
**Post date:** [March 24, 2022, 1:03pm UTC](https://forum.opentap.io/t/child-classes-in-test-step-properties/646/1 "2022-03-24T13:03:15Z")

</div>

I’m currently adding Python plugins for multiple test & measurement devices and I was wondering if I could create a simple straightforward HAL in OpenTAP.

Let’s say I have two oscilloscopes coming from different vendors but both capable of doing certain things and I’d like to have them interchangeable within OpenTAP. To achieve that, I created an `Oscilloscope` instrument class and two child implementations. In my test step I specified that it requires a resource of the `Oscilloscope` type hoping that it would accept any of its child classes. Unfortunately it doesn’t seem to be the case as the list of available resources in the Editor is empty. That being said, everything works as expected if I couple my step to a specific child class.

Am I overlooking something?

---

<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:** [March 24, 2022, 1:36pm UTC](https://forum.opentap.io/t/child-classes-in-test-step-properties/646/2 "2022-03-24T13:36:44Z")

</div>

@tatiana.boye welcome to the OpenTAP community!

This should all be possible, however, I only have an example of doing this in .NET. Are you able to share a code snip of what you are trying? @rolf_madsen , @ivan.diep , or @kaushik.santhanam I think would be able to help.

---

<div class="post-metadata">

**Author:** ![tatiana.boye](https://avatars.discourse-cdn.com/v4/letter/t/ba8739/32.png) [@tatiana.boye](https://forum.opentap.io/u/tatiana.boye)\
**Post date:** [March 24, 2022, 1:45pm UTC](https://forum.opentap.io/t/child-classes-in-test-step-properties/646/3 "2022-03-24T13:45:46Z")

</div>

Thanks @brennen_direnzo!

Here’s a simplified example of what I’m trying to do:

```csharp
import OpenTap
from PythonTap import Instrument, TestStep

@Attribute(BrowsableAttribute, False)
class Oscilloscope(Instrument):
    pass

@Attribute(OpenTap.DisplayAttribute, "My Scope 1", "Scope 1.", "Oscilloscopes")
class MyScope1(Oscilloscope):
    pass

@Attribute(OpenTap.DisplayAttribute, "My Scope 2", "Scope 2.", "Oscilloscopes")
class MyScope2(Oscilloscope):
    pass

@Attribute(OpenTap.DisplayAttribute, "My Scope Test Step", "My scope test step.", "Signal Processing")
class MyScopeTestStep(TestStep):
    def __init__ (self):
        super(). __init__ ()
        self.AddProperty("scope", None, Oscilloscope)\
            .AddAttribute(OpenTap.DisplayAttribute, "Oscilloscope", "The oscilloscope to use in the step.", "Resources")

```

---

<div class="post-metadata">

**Author:** ![ivan.diep](https://avatars.discourse-cdn.com/v4/letter/i/b5e925/32.png) [@ivan.diep](https://forum.opentap.io/u/ivan.diep)\
**Post date:** [March 24, 2022, 4:14pm UTC](https://forum.opentap.io/t/child-classes-in-test-step-properties/646/4 "2022-03-24T16:14:36Z")

</div>

Hi Tatiana,  
In your `MyScope1` and `MyScope2` class, you should inherit from `Oscilloscope` instead of `Instrument` to get your desired behavior. All the other code in your example can be left as is.

```csharp
@Attribute(BrowsableAttribute, False)
class Oscilloscope(Instrument):
    pass

@Attribute(OpenTap.DisplayAttribute, "My Scope 1", "Scope 1.", "Oscilloscopes")
class MyScope1(Oscilloscope):
    pass

@Attribute(OpenTap.DisplayAttribute, "My Scope 2", "Scope 2.", "Oscilloscopes")
class MyScope2(Oscilloscope):
    pass

```

---

<div class="post-metadata">

**Author:** ![tatiana.boye](https://avatars.discourse-cdn.com/v4/letter/t/ba8739/32.png) [@tatiana.boye](https://forum.opentap.io/u/tatiana.boye)\
**Post date:** [March 24, 2022, 4:33pm UTC](https://forum.opentap.io/t/child-classes-in-test-step-properties/646/5 "2022-03-24T16:33:19Z")

</div>

@ivan.diep Thanks for checking that and sorry for the confusion–it was just a typo I made when preparing the “simplified example”. In the original code the inheritance is correct, I’ve just edited my previous post.

---

<div class="post-metadata">

**Author:** ![tatiana.boye](https://avatars.discourse-cdn.com/v4/letter/t/ba8739/32.png) [@tatiana.boye](https://forum.opentap.io/u/tatiana.boye)\
**Post date:** [March 24, 2022, 4:45pm UTC](https://forum.opentap.io/t/child-classes-in-test-step-properties/646/6 "2022-03-24T16:45:02Z")

</div>

That said, the example seems to work properly. I’ll need to see what could be wrong with the original code, it must be something on my end. Thanks again @ivan.diep and @brennen_direnzo.

---

<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:** [March 25, 2022, 1:30pm UTC](https://forum.opentap.io/t/child-classes-in-test-step-properties/646/7 "2022-03-25T13:30:45Z")

</div>

Let us know if you are still having issues and we can dive in deeper.
