~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

(jameinel) Merge 2.4 into 2.5,
 and resolve a few conflicts wrt extract_format_string(). (John A Meinel)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1782
1782
 
1783
1783
        :returns: The actual attr value.
1784
1784
        """
1785
 
        value = getattr(obj, attr_name)
1786
1785
        # The actual value is captured by the call below
1787
 
        self.addCleanup(setattr, obj, attr_name, value)
 
1786
        value = getattr(obj, attr_name, _unitialized_attr)
 
1787
        if value is _unitialized_attr:
 
1788
            # When the test completes, the attribute should not exist, but if
 
1789
            # we aren't setting a value, we don't need to do anything.
 
1790
            if new is not _unitialized_attr:
 
1791
                self.addCleanup(delattr, obj, attr_name)
 
1792
        else:
 
1793
            self.addCleanup(setattr, obj, attr_name, value)
1788
1794
        if new is not _unitialized_attr:
1789
1795
            setattr(obj, attr_name, new)
1790
1796
        return value