[Piglit] [PATCH 8/9] framework/exectest.py: use grouping parens instead of \ to break strings

Ilia Mirkin imirkin at alum.mit.edu
Thu Apr 10 13:42:44 PDT 2014


On Thu, Apr 10, 2014 at 4:38 PM, Dylan Baker <baker.dylan.c at gmail.com> wrote:
> On Wednesday, April 09, 2014 23:01:24 Ilia Mirkin wrote:
>
>> On Wed, Apr 9, 2014 at 10:56 PM, Dylan Baker <baker.dylan.c at gmail.com>
>> wrote:
>
>> > On Wednesday, April 09, 2014 09:58:47 PM Ilia Mirkin wrote:
>
>> >> On Wed, Apr 9, 2014 at 9:27 PM, Dylan Baker <baker.dylan.c at gmail.com>
>> >> wrote:
>
>> >> > ---
>
>> >> >
>
>> >> > framework/exectest.py | 16 ++++++++--------
>
>> >> > 1 file changed, 8 insertions(+), 8 deletions(-)
>
>> >> >
>
>> >> > diff --git a/framework/exectest.py b/framework/exectest.py
>
>> >> > index 72061e0..76f9be8 100644
>
>> >> > --- a/framework/exectest.py
>
>> >> > +++ b/framework/exectest.py
>
>> >> >
>
>> >> > @@ -90,15 +90,15 @@ class Test(object):
>
>> >> > if not isinstance(result, TestResult):
>
>> >> > result = TestResult(result)
>
>> >> > result['result'] = 'warn'
>
>> >> >
>
>> >> > - result['note'] = 'Result not returned as an
>
>> >> > instance
>
>> >> > ' \ - 'of TestResult'
>
>> >> > + result['note'] = ('Result not returned as an
>
>> >> > instance
>
>> >> > ' + 'of TestResult')
>
>> >> >
>
>> >> > except:
>
>> >> > result = TestResult()
>
>> >> > result['result'] = 'fail'
>
>> >> >
>
>> >> > - result['exception'] = str(sys.exc_info()[0]) + \
>
>> >> > - str(sys.exc_info()[1])
>
>> >> > - result['traceback'] = \
>
>> >> > - "".join(traceback.format_tb(sys.exc_info()[2]))
>
>> >> > + result['exception'] = (str(sys.exc_info()[0]) +
>
>> >> > + str(sys.exc_info()[1]))
>
>
>
>
>
> so what about something like this:
>
> exception = sys.exc_info()
>
> result['exception'] = "{}{}".format(*exception[:2])
>
> result['traceback'] = "".join(traceback.format_tb(exception[2]))
>
>
>
> This should make things easier to read and reduces our function calls.
>

Sounds good to me.

  -ilia


More information about the Piglit mailing list