[Pytest-commit] commit/pytest: James Tatum: Cleaning up the docstrings in monkeypatch.py

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Fri Jan 9 10:06:56 CET 2015


1 new commit in pytest:

https://bitbucket.org/hpk42/pytest/commits/f6f70a7ff3eb/
Changeset:   f6f70a7ff3eb
User:        James Tatum
Date:        2015-01-09 01:15:22+00:00
Summary:     Cleaning up the docstrings in monkeypatch.py
Affected #:  1 file

diff -r d91265465608bd3777ab0c882e5d68335d7472dd -r f6f70a7ff3eb79863eba18a6a51b17aafe51c8d7 _pytest/monkeypatch.py
--- a/_pytest/monkeypatch.py
+++ b/_pytest/monkeypatch.py
@@ -66,14 +66,14 @@
 notset = Notset()
 
 class monkeypatch:
-    """ object keeping a record of setattr/item/env/syspath changes. """
+    """ Object keeping a record of setattr/item/env/syspath changes. """
     def __init__(self):
         self._setattr = []
         self._setitem = []
         self._cwd = None
 
     def setattr(self, target, name, value=notset, raising=True):
-        """ set attribute value on target, memorizing the old value.
+        """ Set attribute value on target, memorizing the old value.
         By default raise AttributeError if the attribute did not exist.
 
         For convenience you can specify a string as ``target`` which
@@ -108,15 +108,15 @@
         setattr(target, name, value)
 
     def delattr(self, target, name=notset, raising=True):
-        """ delete attribute ``name`` from ``target``, by default raise
+        """ Delete attribute ``name`` from ``target``, by default raise
         AttributeError it the attribute did not previously exist.
 
         If no ``name`` is specified and ``target`` is a string
         it will be interpreted as a dotted import path with the
         last part being the attribute name.
 
-        If raising is set to false, the attribute is allowed to not
-        pre-exist.
+        If ``raising`` is set to False, no exception will be raised if the
+        attribute is missing.
         """
         __tracebackhide__ = True
         if name is notset:
@@ -135,12 +135,16 @@
             delattr(target, name)
 
     def setitem(self, dic, name, value):
-        """ set dictionary entry ``name`` to value. """
+        """ Set dictionary entry ``name`` to value. """
         self._setitem.insert(0, (dic, name, dic.get(name, notset)))
         dic[name] = value
 
     def delitem(self, dic, name, raising=True):
-        """ delete ``name`` from dict, raise KeyError if it doesn't exist."""
+        """ Delete ``name`` from dict. Raise KeyError if it doesn't exist.
+
+        If ``raising`` is set to False, no exception will be raised if the
+        key is missing.
+        """
         if name not in dic:
             if raising:
                 raise KeyError(name)
@@ -149,7 +153,7 @@
             del dic[name]
 
     def setenv(self, name, value, prepend=None):
-        """ set environment variable ``name`` to ``value``.  if ``prepend``
+        """ Set environment variable ``name`` to ``value``.  If ``prepend``
         is a character, read the current environment variable value
         and prepend the ``value`` adjoined with the ``prepend`` character."""
         value = str(value)
@@ -158,17 +162,22 @@
         self.setitem(os.environ, name, value)
 
     def delenv(self, name, raising=True):
-        """ delete ``name`` from environment, raise KeyError it not exists."""
+        """ Delete ``name`` from the environment. Raise KeyError it does not
+        exist.
+
+        If ``raising`` is set to False, no exception will be raised if the
+        environment variable is missing.
+        """
         self.delitem(os.environ, name, raising=raising)
 
     def syspath_prepend(self, path):
-        """ prepend ``path`` to ``sys.path`` list of import locations. """
+        """ Prepend ``path`` to ``sys.path`` list of import locations. """
         if not hasattr(self, '_savesyspath'):
             self._savesyspath = sys.path[:]
         sys.path.insert(0, str(path))
 
     def chdir(self, path):
-        """ change the current working directory to the specified path
+        """ Change the current working directory to the specified path
         path can be a string or a py.path.local object
         """
         if self._cwd is None:
@@ -179,9 +188,9 @@
             os.chdir(path)
 
     def undo(self):
-        """ undo previous changes.  This call consumes the
-        undo stack.  Calling it a second time has no effect unless
-        you  do more monkeypatching after the undo call."""
+        """ Undo previous changes.  This call consumes the
+        undo stack. Calling it a second time has no effect unless
+        you do more monkeypatching after the undo call."""
         for obj, name, value in self._setattr:
             if value is not notset:
                 setattr(obj, name, value)

Repository URL: https://bitbucket.org/hpk42/pytest/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.


More information about the pytest-commit mailing list