Remove most prints for unit tests
Generally, print should not be used for unit tests, it may pollute the output stream. Right now, our internal build system is facing BlockingIOError: [Errno 11] write could not complete without blocking on prints. Especially ACL tests seem to be a big offender because they are vary numerous and each may print several times. Many prints in other tests are cryptic and probably just leftover from debugging. I only leave the API unit tests where the output is arguably useful. But I reduce it to one print per call since the input is already known. Change-Id: Ic5aaf9624f86b39609e2db6157c98cf8e35712fc
This commit is contained in:
parent
22918bde84
commit
88fd22de79
@ -104,7 +104,6 @@ class BaseApiTest(db_base.DbTestCase):
|
||||
:param path_prefix: prefix of the url path
|
||||
"""
|
||||
full_path = path_prefix + path
|
||||
print('%s: %s %s' % (method.upper(), full_path, params))
|
||||
response = getattr(self.app, "%s_json" % method)(
|
||||
str(full_path),
|
||||
params=params,
|
||||
@ -113,7 +112,7 @@ class BaseApiTest(db_base.DbTestCase):
|
||||
extra_environ=extra_environ,
|
||||
expect_errors=expect_errors
|
||||
)
|
||||
print('GOT:%s' % response)
|
||||
print(method.upper(), full_path, "WITH", params, "GOT", str(response))
|
||||
return response
|
||||
|
||||
def put_json(self, path, params, expect_errors=False, headers=None,
|
||||
@ -187,13 +186,12 @@ class BaseApiTest(db_base.DbTestCase):
|
||||
:param path_prefix: prefix of the url path
|
||||
"""
|
||||
full_path = path_prefix + path
|
||||
print('DELETE: %s' % (full_path))
|
||||
response = self.app.delete(str(full_path),
|
||||
headers=headers,
|
||||
status=status,
|
||||
extra_environ=extra_environ,
|
||||
expect_errors=expect_errors)
|
||||
print('GOT:%s' % response)
|
||||
print("DELETE", full_path, "GOT", str(response))
|
||||
return response
|
||||
|
||||
def get_json(self, path, expect_errors=False, headers=None,
|
||||
@ -225,15 +223,14 @@ class BaseApiTest(db_base.DbTestCase):
|
||||
all_params.update(params)
|
||||
if q:
|
||||
all_params.update(query_params)
|
||||
print('GET: %s %r' % (full_path, all_params))
|
||||
response = self.app.get(full_path,
|
||||
params=all_params,
|
||||
headers=headers,
|
||||
extra_environ=extra_environ,
|
||||
expect_errors=expect_errors)
|
||||
print("GET", full_path, "WITH", params, "GOT", str(response))
|
||||
if not expect_errors:
|
||||
response = response.json
|
||||
print('GOT:%s' % response)
|
||||
return response
|
||||
|
||||
def validate_link(self, link, bookmark=False, headers=None):
|
||||
|
@ -1114,7 +1114,6 @@ class TestListPortsByShard(test_api_base.BaseApiTest):
|
||||
|
||||
res = self.get_json('/ports?shard=shard1,shard2', headers=self.headers)
|
||||
self.assertEqual(2, len(res['ports']))
|
||||
print(res['ports'][0])
|
||||
self.assertNotEqual(res['ports'][0]['address'], bad_shard_address)
|
||||
self.assertNotEqual(res['ports'][1]['address'], bad_shard_address)
|
||||
|
||||
|
@ -102,7 +102,6 @@ class TestACLBase(base.BaseApiTest):
|
||||
# in troubleshooting ACL testing. This is a pattern
|
||||
# followed in API unit testing in ironic, and
|
||||
# really does help.
|
||||
print('API ACL Testing Path %s %s' % (method, path))
|
||||
if headers:
|
||||
for k, v in headers.items():
|
||||
rheaders[k] = v.format(**self.format_data)
|
||||
@ -185,8 +184,6 @@ class TestACLBase(base.BaseApiTest):
|
||||
if assert_dict_contains:
|
||||
for k, v in assert_dict_contains.items():
|
||||
self.assertIn(k, response)
|
||||
print(k)
|
||||
print(v)
|
||||
if str(v) == "None":
|
||||
# Compare since the variable loaded from the
|
||||
# json ends up being null in json or None.
|
||||
@ -219,13 +216,6 @@ class TestACLBase(base.BaseApiTest):
|
||||
# a filtered view in these cases.
|
||||
self.assertEqual(0, len(items))
|
||||
|
||||
# NOTE(TheJulia): API tests in Ironic tend to have a pattern
|
||||
# to print request and response data to aid in development
|
||||
# and troubleshooting. As such the prints should remain,
|
||||
# at least until we are through primary development of the
|
||||
# this test suite.
|
||||
print('ACL Test GOT %s' % response)
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class TestRBACBasic(TestACLBase):
|
||||
|
@ -678,7 +678,6 @@ class TestNeutronNetworkActions(db_base.DbTestCase):
|
||||
|
||||
network_data = neutron.get_neutron_port_data('port1', 'vif1')
|
||||
|
||||
print(network_data)
|
||||
expected_port = {
|
||||
'id': 'port1',
|
||||
'type': 'vif',
|
||||
|
@ -2162,8 +2162,6 @@ class iPXEBuildConfigOptionsTestCase(db_base.DbTestCase):
|
||||
if iso_boot:
|
||||
self.node.instance_info = {'boot_iso': 'http://test.url/file.iso'}
|
||||
self.node.save()
|
||||
print(expected_options)
|
||||
print(image_info)
|
||||
iso_url = os.path.join(http_url, self.node.uuid, 'boot_iso')
|
||||
expected_options.update(
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user