[Piglit] [PATCH 1/3] summary_tests.py: Add tests for subtest handling
Dylan Baker
baker.dylan.c at gmail.com
Thu May 8 14:43:39 PDT 2014
On Thursday, April 24, 2014 17:20:40 Dylan Baker wrote:
> These tests are meant to show that subtest handling actually works.
> ---
> framework/tests/summary_tests.py | 77 +++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 76 insertions(+), 1 deletion(-)
>
> diff --git a/framework/tests/summary_tests.py b/framework/tests/summary_tests.py
> index 1ad51b5..bad1ba7 100644
> --- a/framework/tests/summary_tests.py
> +++ b/framework/tests/summary_tests.py
> @@ -21,6 +21,7 @@
>
> """ Module providing tests for the summary module """
>
> +from __future__ import print_function
> import json
> import copy
> import nose.tools as nt
> @@ -67,6 +68,80 @@ def check_sets(old, ostat, new, nstat, set_):
> with utils.with_tempfile(json.dumps(new)) as nfile:
> summ = summary.Summary([ofile, nfile])
>
> - print summ.tests
> + print(summ.tests)
> nt.assert_equal(1, len(summ.tests[set_]),
> msg="{0} was not appended".format(set_))
> +
> +
> +def test_subtest_handling():
> + data = copy.deepcopy(utils.JSON_DATA)
> + data['tests']['with_subtests'] = {}
> + data['tests']['with_subtests']['result'] = 'pass'
> +
> + data['tests']['with_subtests']['subtest'] = {}
> + data['tests']['with_subtests']['subtest']['subtest1'] = 'fail'
> + data['tests']['with_subtests']['subtest']['subtest2'] = 'warn'
> + data['tests']['with_subtests']['subtest']['subtest3'] = 'crash'
> + data['tests']['is_skip'] = {}
> + data['tests']['is_skip']['result'] = 'skip'
> +
> + with utils.with_tempfile(json.dumps(data)) as sumfile:
> + summ = summary.Summary([sumfile])
> +
> + check_subtests_are_tests.description = \
> + "Subtests should be treated as full tests "
> + yield check_subtests_are_tests, summ
> +
> + check_tests_w_subtests_are_groups.description = \
> + "Tests with subtests should be a group"
> + yield check_tests_w_subtests_are_groups, summ
> +
> + test_removed_from_all.description = \
> + "Tests with subtests should not be in the tests['all'] name"
> + yield test_removed_from_all, summ
> +
> + subtest_not_skip_notrun.description = \
> + "Skip's should not become NotRun"
> + yield subtest_not_skip_notrun, summ
> +
> +
> + at nt.nottest
> +def check_subtests_are_tests(summary_):
> + """ Subtests should be treated as full tests """
> + print(summary_.fractions)
> + nt.assert_equal(summary_.fractions['fake-tests']['with_subtests'], (0, 3),
> + msg="Summary.fraction['fake-tests']['with_subtests'] should "
> + "be (0, 3), but isn't")
> +
> +
> + at nt.nottest
> +def check_tests_w_subtests_are_groups(summary_):
> + """ Tests with subtests should be a group
> +
> + We know that the status will be 'pass' if it's not being overwritten, and
> + will be 'crash' if it has. (since we set the data that way)
> +
> + """
> + print(summary_.status)
> + nt.assert_equal(
> + str(summary_.status['fake-tests']['with_subtests']), 'crash',
> + msg="Summary.status['fake-tests']['with_subtests'] should "
> + "be crash, but isn't")
> +
> +
> + at nt.nottest
> +def test_removed_from_all(summary_):
> + """ Tests with subtests should not be in the all results """
> + print(summary_.tests['all'])
> + nt.assert_not_in('with_subtests', summary_.tests['all'],
> + msg="Test with subtests should have been removed from "
> + "self.tests['all'], but wasn't")
> +
> +
> + at nt.nottest
> +def subtest_not_skip_notrun(summary_):
> + """ Ensure that skips are not changed to notruns """
> + print(summary_.status['fake-tests']['is_skip'])
> + print(summary_.results[0].tests['is_skip'])
> + nt.eq_(summary_.status['fake-tests']['is_skip'], 'skip',
> + msg="Status should be skip but was changed")
>
bump.
I should note that this series was applied previously, but reverted
because of unrelated bugs, I know some of them have been fixed, and I
believe that the rest no long are relavent. (they were in igt)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20140508/ea0feb01/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20140508/ea0feb01/attachment-0001.sig>
More information about the Piglit
mailing list