Skip to content

Commit

Permalink
Fix test_request_no_token_dummy cms dependency.
Browse files Browse the repository at this point in the history
* tests/test_auth_token_middleware.py: test_request_no_token_dummy has a
dependency on the keystone.common.cms module importing subprocess prior
to running. The cms._ensure_subprocess() function does this. Call this
function in the base test class's setUp method to ensure subprocess is
imported before symbols from that module are needed. Doing this in the
base setUp will ensure that this works for any additional tests with the
same dependency.

This fix is needed because testr runs tests in non deterministic order
which means that each test needs to be able to run on its own (eg in its
own process without any other tests running first) and they need to run
without interfering any other tests (each test must properly clean up
after itself). Prior to this commit test_request_no_token_dummy would
fail when executed on its own.

Closes-Bug: #1209300
Change-Id: I3cf669b94ed77ad0cd729ead0b4162a3f1b8819f
  • Loading branch information
cboylan committed Aug 7, 2013
1 parent 4e9af1f commit fb7aae4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/test_auth_token_middleware.py
Expand Up @@ -643,6 +643,12 @@ def setUp(self, expected_env=None, auth_version=None,
self.fake_http = fake_http or FakeHTTPConnection
self.set_middleware(self.fake_app, self.fake_http,
expected_env, self.conf)
# self.middleware.verify_signed_token will call
# _ensure_subprocess, but we need
# cms.subprocess.CalledProcessError to be imported first.
# Explicitly call _ensure_subprocess to make sure the import
# happens before we need it regardless of test order.
cms._ensure_subprocess()

self.response_status = None
self.response_headers = None
Expand Down

0 comments on commit fb7aae4

Please sign in to comment.