Skip to content

Commit

Permalink
Converted some more tests in test_cim_obj from unittest to pytest and…
Browse files Browse the repository at this point in the history
… a fix.

Details:
- Converted all str and repr test classes to py.test.
- Converted most init test classes to py.test.
- Added test cases for testing the position of init arguments.
- Fixed a bug where the initialization of the qualifiers attribute
  of CIMProperty and CIMMethod did not ensure that the items
  in the input dictionary were cnverted to CIMQualifier objects.
  It now ensures that. Adjusted the testcases accordingly.
- Fixed a bug where the DeprecationWarning when setting the
  deprecated value attribute of CIMParameter was always issued
  even when the value was None. Now, it is only issued when the
  value is not None. Adjusted the testcases accordingly.
- The getter method for the deprecated value attribute of CIMParameter
  issued a DeprecationWarning. Removed that warning because
  issuing it in the setter method is sufficient.
  Adjusted the testcases accordingly.

Signed-off-by: Andreas Maier <maiera@de.ibm.com>
  • Loading branch information
andy-maier committed Dec 18, 2017
1 parent e7510d1 commit 7fd3004
Show file tree
Hide file tree
Showing 2 changed files with 2,786 additions and 985 deletions.
32 changes: 23 additions & 9 deletions pywbem/cim_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -3202,8 +3202,13 @@ def qualifiers(self):
@qualifiers.setter
def qualifiers(self, qualifiers):
"""Setter method; for a description see the getter method."""
# We make sure that the dictionary is a NocaseDict object, and that the
# property values are CIMQualifier objects:
# pylint: disable=attribute-defined-outside-init
self._qualifiers = NocaseDict(qualifiers)
self._qualifiers = NocaseDict()
if qualifiers:
for key, value in qualifiers.items():
self._qualifiers[key] = _cim_qualifier(key, value)

def copy(self):
"""
Expand Down Expand Up @@ -3734,8 +3739,13 @@ def qualifiers(self):
@qualifiers.setter
def qualifiers(self, qualifiers):
"""Setter method; for a description see the getter method."""
# We make sure that the dictionary is a NocaseDict object, and that the
# property values are CIMQualifier objects:
# pylint: disable=attribute-defined-outside-init
self._qualifiers = NocaseDict(qualifiers)
self._qualifiers = NocaseDict()
if qualifiers:
for key, value in qualifiers.items():
self._qualifiers[key] = _cim_qualifier(key, value)

def _cmp(self, other):
"""
Expand Down Expand Up @@ -4108,8 +4118,13 @@ def qualifiers(self):
@qualifiers.setter
def qualifiers(self, qualifiers):
"""Setter method; for a description see the getter method."""
# We make sure that the dictionary is a NocaseDict object, and that the
# property values are CIMQualifier objects:
# pylint: disable=attribute-defined-outside-init
self._qualifiers = NocaseDict(qualifiers)
self._qualifiers = NocaseDict()
if qualifiers:
for key, value in qualifiers.items():
self._qualifiers[key] = _cim_qualifier(key, value)

@property
def value(self):
Expand All @@ -4118,17 +4133,16 @@ def value(self):
this attribute does not make any sense. Accessing it will cause a
:term:`DeprecationWarning` to be issued.
"""
warnings.warn(
"The value attribute of CIMParameter is deprecated",
DeprecationWarning)
return self._value

@value.setter
def value(self, value):
"""Setter method; for a description see the getter method."""
warnings.warn(
"The value attribute of CIMParameter is deprecated",
DeprecationWarning)
if value is not None:
warnings.warn(
"The value attribute of CIMParameter (name=%r) is deprecated" %
self.name,
DeprecationWarning)
# pylint: disable=attribute-defined-outside-init
self._value = cimvalue(value, self.type)

Expand Down
Loading

0 comments on commit 7fd3004

Please sign in to comment.