Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ def __ne__(self, other):
"""Compare objects by comparing all attributes."""
return not self.__eq__(other)

def __contains__(self, key):
return key in self.__dict__

def __str__(self):
return str({k: v for k, v in self.__dict__.items() if not k.startswith('_')})

Expand Down
18 changes: 18 additions & 0 deletions sdk/textanalytics/azure-ai-textanalytics/tests/test_dict_mixin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# coding=utf-8
# ------------------------------------
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------

import pytest
from azure.ai.textanalytics import _models


class TestDictMixin:

def test_contains(self):
model = _models.DictMixin()
key = "name"
value = "steve"
model.__setitem__(key, value)
assert model.__contains__(key)