Skip to content

Commit fda9514

Browse files
authored
added contains to DictMixin (#16604)
1 parent a00a4f4 commit fda9514

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ def __ne__(self, other):
4343
"""Compare objects by comparing all attributes."""
4444
return not self.__eq__(other)
4545

46+
def __contains__(self, key):
47+
return key in self.__dict__
48+
4649
def __str__(self):
4750
return str({k: v for k, v in self.__dict__.items() if not k.startswith('_')})
4851

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# coding=utf-8
2+
# ------------------------------------
3+
# Copyright (c) Microsoft Corporation.
4+
# Licensed under the MIT License.
5+
# ------------------------------------
6+
7+
import pytest
8+
from azure.ai.textanalytics import _models
9+
10+
11+
class TestDictMixin:
12+
13+
def test_contains(self):
14+
model = _models.DictMixin()
15+
key = "name"
16+
value = "steve"
17+
model.__setitem__(key, value)
18+
assert model.__contains__(key)

0 commit comments

Comments
 (0)