[Piglit] [Patch v2 6/8] igt.py: add docstrings.

Dylan Baker baker.dylan.c at gmail.com
Mon Jan 26 13:57:21 PST 2015


On Monday, January 26, 2015 13:41:26 Ian Romanick wrote:
> On 01/26/2015 11:28 AM, Dylan Baker wrote:
> > In some cases this is really just about formatting.
> > 
> > Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
> > ---
> >  tests/igt.py | 24 ++++++++++++++++--------
> >  1 file changed, 16 insertions(+), 8 deletions(-)
> > 
> > diff --git a/tests/igt.py b/tests/igt.py
> > index b7ee165..4a46fb0 100644
> > --- a/tests/igt.py
> > +++ b/tests/igt.py
> > @@ -22,6 +22,14 @@
> >  # OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
> >  # DEALINGS IN THE SOFTWARE.
> >  
> > +"""IGTTest: Execute an intel-gpu-tools test.
> > +
> > +To use this, create an igt symlink in piglit/bin which points to the root
> > +of the intel-gpu-tools sources with the compiled tests. Piglit will
> > +automatically add all tests into the 'igt' category.
> > +
> > +"""
> 
> Is the extra blank line in the docstring required by PEP?
> 

It isn't strictly required, but it is a very common practice (Google
does require it in their docstrings), it's also how we do the rest of
our docstrings.

> > +
> >  import os
> >  import re
> >  import sys
> > @@ -33,16 +41,14 @@ from framework.profile import TestProfile, Test
> >  
> >  __all__ = ['profile']
> >  
> > -#############################################################################
> > -##### IGTTest: Execute an intel-gpu-tools test
> > -#####
> > -##### To use this, create an igt symlink in piglit/bin which points to the root
> > -##### of the intel-gpu-tools sources with the compiled tests. Piglit will
> > -##### automatically add all tests into the 'igt' category.
> > -#############################################################################
> >  
> >  
> >  def check_environment():
> > +    """Check that the environment that piglit is running in is appropraite.
> > +
> > +    IGT requires root, debugfs to be mounted, and to be the only drm client.
> > +
> > +    """
> >      debugfs_path = "/sys/kernel/debug/dri"
> >      if os.getuid() != 0:
> >          print "Test Environment check: not root!"
> > @@ -77,11 +83,11 @@ if not (os.path.exists(os.path.join(IGT_TEST_ROOT, 'single-tests.txt'))
> >      sys.exit(0)
> >  
> >  IGT_ENVIRONMENT_OK = check_environment()
> > -
> >  profile = TestProfile()  # pylint: disable=invalid-name
> >  
> >  
> >  class IGTTest(Test):
> > +    """Test class for running libdrm."""
> >      def __init__(self, binary, arguments=None):
> >          if arguments is None:
> >              arguments = []
> > @@ -112,6 +118,7 @@ class IGTTest(Test):
> >  
> >  
> >  def list_tests(listname):
> > +    """Parse igt test list and return them as a list."""
> >      with open(os.path.join(IGT_TEST_ROOT, listname + '.txt'), 'r') as f:
> >          lines = (line.rstrip() for line in f.readlines())
> >  
> > @@ -130,6 +137,7 @@ def list_tests(listname):
> >  
> >  
> >  def add_subtest_cases(test):
> > +    """Get subtest instances."""
> >      proc = subprocess.Popen(
> >          [os.path.join(IGT_TEST_ROOT, test), '--list-subtests'],
> >          stdout=subprocess.PIPE,
> > 
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20150126/626c737b/attachment.sig>


More information about the Piglit mailing list