[Piglit] [PATCH 4/6] tests/igt.py: fix invalid name errors

Thomas Wood thomas.wood at intel.com
Fri Jan 23 09:50:41 PST 2015


On 23 January 2015 at 17:10, Dylan Baker <baker.dylan.c at gmail.com> wrote:
> On Friday, January 23, 2015 15:02:44 Thomas Wood wrote:
>> On 19 January 2015 at 17:38, Dylan Baker <baker.dylan.c at gmail.com> wrote:
>> > Make constants all caps, per PEP8, make functions all lowercase with
>> > underscores, and move some toplevel work into helper functions.
>> >
>> > This lowers the pylint warnings to just missing docstrings.
>> > ---
>> >  tests/igt.py | 28 ++++++++++++++++------------
>> >  1 file changed, 16 insertions(+), 12 deletions(-)
>> >
>> > diff --git a/tests/igt.py b/tests/igt.py
>> > index f0064fc..6c3613e 100644
>> > --- a/tests/igt.py
>> > +++ b/tests/igt.py
>> > @@ -41,7 +41,7 @@ __all__ = ['profile']
>> >  ##### automatically add all tests into the 'igt' category.
>> >  #############################################################################
>> >
>> > -def checkEnvironment():
>> > +def check_environment():
>> >      debugfs_path = "/sys/kernel/debug/dri"
>> >      if os.getuid() != 0:
>> >          print "Test Environment check: not root!"
>> > @@ -72,9 +72,9 @@ if not (os.path.exists(os.path.join(IGT_TEST_ROOT, 'single-tests.txt'))
>> >      print "intel-gpu-tools test lists not found."
>> >      sys.exit(0)
>> >
>> > -igtEnvironmentOk = checkEnvironment()
>> > +IGT_ENVIRONMENT_OK = check_environment()
>> >
>> > -profile = TestProfile()
>> > +profile = TestProfile()  # pylint: disable=invalid-name
>> >
>> >  class IGTTest(Test):
>> >      def __init__(self, binary, arguments=None):
>> > @@ -85,7 +85,7 @@ class IGTTest(Test):
>> >          self.timeout = 600
>> >
>> >      def interpret_result(self):
>> > -        if not igtEnvironmentOk:
>> > +        if not IGT_ENVIRONMENT_OK:
>> >              return
>> >
>> >          if self.result['returncode'] == 0:
>> > @@ -98,14 +98,14 @@ class IGTTest(Test):
>> >              self.result['result'] = 'fail'
>> >
>> >      def run(self):
>> > -        if not igtEnvironmentOk:
>> > +        if not IGT_ENVIRONMENT_OK:
>> >              self.result['result'] = 'fail'
>> >              self.result['info'] = unicode("Test Environment isn't OK")
>> >              return
>> >
>> >          super(IGTTest, self).run()
>> >
>> > -def listTests(listname):
>> > +def list_tests(listname):
>> >      with open(os.path.join(IGT_TEST_ROOT, listname + '.txt'), 'r') as f:

There's also an invalid variable name warning here.

>> >          lines = (line.rstrip() for line in f.readlines())
>> >
>> > @@ -122,10 +122,7 @@ def listTests(listname):
>> >
>> >      return progs
>> >
>> > -tests = listTests("single-tests")
>> > -tests.extend(listTests("multi-tests"))
>> > -
>> > -def addSubTestCases(test):
>> > +def add_subtest_cases(test):
>> >      proc = subprocess.Popen(
>> >          [os.path.join(IGT_TEST_ROOT, test), '--list-subtests'],
>> >          stdout=subprocess.PIPE,
>> > @@ -152,9 +149,16 @@ def addSubTestCases(test):
>> >          profile.test_list[grouptools.join('igt', test, subtest)] = \
>> >              IGTTest(test, ['--run-subtest', subtest])
>> >
>> > -for test in tests:
>> > -    addSubTestCases(test)
>> >
>> > +def populate_profile():
>> > +    tests = list_tests("single-tests")  # pylint: disable=invalid-name
>>
>> I don't think there is an invalid name issue here? Also, invalid-name
>> is already disabled by the comment above (next to "profile").
>
> You're right, it shouldn't be an invalid name, it likely was before it
> was pulled into a function, I'll fix that.
>
> Just FYI, if you put the pylint disable comment at the end of a line
> then only that line is ignored.
>
>>
>> > +    tests.extend(list_tests("multi-tests"))
>> > +
>> > +    for test in tests:
>> > +        add_subtest_cases(test)
>> > +
>> > +
>> > +populate_profile()
>> >  profile.dmesg = True
>> >
>> >  # the dmesg property of TestProfile returns a Dmesg object
>> > --
>> > 2.2.1
>> >
>> > _______________________________________________
>> > Piglit mailing list
>> > Piglit at lists.freedesktop.org
>> > http://lists.freedesktop.org/mailman/listinfo/piglit


More information about the Piglit mailing list