[Piglit] [RFC 05/10] framework: add various helper functions to TestResult
Dylan Baker
dylan at pnwbakers.com
Thu Oct 19 00:55:47 UTC 2017
I'll look at the rest of these tomorrow, but I'm out of time now.
Quoting Nicolai Hähnle (2017-10-11 03:26:54)
> From: Nicolai Hähnle <nicolai.haehnle at amd.com>
>
> ---
> framework/results.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 46 insertions(+)
>
> diff --git a/framework/results.py b/framework/results.py
> index 26ebbe7a6..c13379b3e 100644
> --- a/framework/results.py
> +++ b/framework/results.py
> @@ -202,20 +202,66 @@ class TestResult(object):
> if relative == '':
> if self.subtests:
> raise KeyError(key)
> return self.result
>
> try:
> return self.subtests[relative]
> except KeyError:
> raise KeyError(key)
>
> + def set_result(self, key, status):
> + """Set the result status of a (sub-)test covered by this object.
> +
> + Raises KeyError if the test is not covered.
> + """
> + relative = grouptools.relative(self.root, key)
> +
> + if relative == '':
> + if self.subtests:
> + raise KeyError(key)
> + self.result = status
> + return
> +
> + if relative not in self.subtests:
> + raise KeyError(key)
> +
> + self.subtests[relative] = status
> +
> + @property
> + def tests(self):
> + """Iterator over the names of tests covered by this object."""
> + if self.subtests:
> + for subtest in six.iterkeys(self.subtests):
> + yield grouptools.join(self.root, subtest)
> + else:
> + yield self.root
> +
> + def add_test(self, key):
> + """Add a (sub-)test to the tests covered by this object."""
> + relative = grouptools.relative(self.root, key)
> +
> + if relative == '':
> + assert not self.subtests
> + return # Nothing to be done
> +
> + self.subtests[relative] = status.NOTRUN
> +
> + def have_test(self, key):
> + """Whether a given (sub-)test is covered by this object."""
> + relative = grouptools.relative(self.root, key)
> +
> + if relative == '':
> + return not self.subtests
> +
> + return relative in self.subtests
> +
> def to_json(self):
> """Return the TestResult as a json serializable object."""
> obj = {
> '__type__': 'TestResult',
> 'root': self.root,
> 'command': self.command,
> 'environment': self.environment,
> 'err': self.err,
> 'out': self.out,
> 'result': self.result,
> --
> 2.11.0
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/piglit
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: signature
URL: <https://lists.freedesktop.org/archives/piglit/attachments/20171018/813a6eec/attachment.sig>
More information about the Piglit
mailing list