deb-python-gabbi/test-limit.sh
Chris Dent 1b9c4dfdf0 Allow test_loader_name to override test class module (#171)
When running gabbi by default the pretty name of the test
(displayed in test results) has a 'gabbi.suitemaker' prefix. This
can be disorienting when reviewing result sets or trying to track
those results to where in a code tree the gabbi tests are loaded.

This change allows the __module__ of the test classes that are
dynamically created to be override with the test_loader_name
that is passed in to to the build_tests method. By setting this
to __name__ the test is appropriately situated in its context. The
gist of this change can be seen on the diff to test-limit.sh.

Note that this has also been tested in OpenStack Nova, which
was the source of this need. There tests which were showing up with
the name:

    gabbi.suitemaker.test_placement_api_inventory_get_that_inventory.\
      test_request

have become:

    nova.tests.functional.api.openstack.placement.\
      test_placement_api.inventory_get_that_inventory.test_request

By default nothing has changed. This change only impact situations where
test_loader_name is used.
2016-09-20 19:28:48 +01:00

16 lines
569 B
Bash
Executable File

#!/bin/bash
# Run a test which is limited to just one request from a file that
# contains many requests and confirm that only one was run and that
# it did actually run.
#
# This covers a situation where the change of intercepts to fixtures
# broke limiting tests and we never knew.
GREP_TEST_MATCH='tests.test_intercept.self_checklimit.test_request ... ok'
GREP_COUNT_MATCH='Ran 1 '
python setup.py testr --testr-args="checklimit" && \
testr last --subunit | subunit2pyunit 2>&1 | \
grep "${GREP_TEST_MATCH}" && \
testr last | grep "${GREP_COUNT_MATCH}"