From 7dfb921a33b92d94449a744a7539d6cbe67de036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferenc=20G=C3=A9czi?= Date: Mon, 6 May 2024 12:00:00 +0000 Subject: [PATCH] test: Refactor to use appropriate UT assertions where available MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ferenc Géczi --- tests/clients/test_couchbase.py | 288 +++++++++++----------- tests/clients/test_google-cloud-pubsub.py | 4 +- tests/frameworks/test_aiohttp_client.py | 60 ++--- tests/frameworks/test_aiohttp_server.py | 52 ++-- tests/frameworks/test_grpcio.py | 56 ++--- tests/frameworks/test_tornado_client.py | 70 +++--- tests/frameworks/test_wsgi.py | 102 ++++---- tests/platforms/test_lambda.py | 72 +++--- 8 files changed, 352 insertions(+), 352 deletions(-) diff --git a/tests/clients/test_couchbase.py b/tests/clients/test_couchbase.py index bba1029c6..61cdf6ef5 100644 --- a/tests/clients/test_couchbase.py +++ b/tests/clients/test_couchbase.py @@ -46,7 +46,7 @@ def setup_method(self, _): def test_vanilla_get(self): res = self.bucket.get("test-key") - assert(res) + self.assertTrue(res) def test_pipeline(self): pass @@ -56,24 +56,24 @@ def test_upsert(self): with tracer.start_active_span('test'): res = self.bucket.upsert("test_upsert", 1) - assert(res) + self.assertTrue(res) self.assertTrue(res.success) spans = self.recorder.queued_spans() self.assertEqual(2, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_span.t) self.assertEqual(cb_span.p, test_span.s) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertIsNone(cb_span.ec) self.assertEqual(cb_span.data["couchbase"]["hostname"], "%s:8091" % testenv['couchdb_host']) @@ -91,11 +91,11 @@ def test_upsert_as_root_exit_span(self): self.assertEqual(1, len(spans)) cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) self.assertEqual(cb_span.p, None) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertIsNone(cb_span.ec) self.assertEqual(cb_span.data["couchbase"]["hostname"], "%s:8091" % testenv['couchdb_host']) @@ -112,7 +112,7 @@ def test_upsert_multi(self): with tracer.start_active_span('test'): res = self.bucket.upsert_multi(kvs) - assert(res) + self.assertTrue(res) self.assertTrue(res['first_test_upsert_multi'].success) self.assertTrue(res['second_test_upsert_multi'].success) @@ -120,17 +120,17 @@ def test_upsert_multi(self): self.assertEqual(2, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_span.t) self.assertEqual(cb_span.p, test_span.s) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertIsNone(cb_span.ec) self.assertEqual(cb_span.data["couchbase"]["hostname"], "%s:8091" % testenv['couchdb_host']) @@ -147,24 +147,24 @@ def test_insert_new(self): with tracer.start_active_span('test'): res = self.bucket.insert("test_insert_new", 1) - assert(res) + self.assertTrue(res) self.assertTrue(res.success) spans = self.recorder.queued_spans() self.assertEqual(2, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_span.t) self.assertEqual(cb_span.p, test_span.s) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertIsNone(cb_span.ec) self.assertEqual(cb_span.data["couchbase"]["hostname"], "%s:8091" % testenv['couchdb_host']) @@ -190,17 +190,17 @@ def test_insert_existing(self): self.assertEqual(2, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_span.t) self.assertEqual(cb_span.p, test_span.s) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertEqual(cb_span.ec, 1) # Just search for the substring of the exception class found = cb_span.data["couchbase"]["error"].find("_KeyExistsError") @@ -226,7 +226,7 @@ def test_insert_multi(self): with tracer.start_active_span('test'): res = self.bucket.insert_multi(kvs) - assert(res) + self.assertTrue(res) self.assertTrue(res['first_test_upsert_multi'].success) self.assertTrue(res['second_test_upsert_multi'].success) @@ -234,17 +234,17 @@ def test_insert_multi(self): self.assertEqual(2, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_span.t) self.assertEqual(cb_span.p, test_span.s) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertIsNone(cb_span.ec) self.assertEqual(cb_span.data["couchbase"]["hostname"], "%s:8091" % testenv['couchdb_host']) @@ -261,24 +261,24 @@ def test_replace(self): with tracer.start_active_span('test'): res = self.bucket.replace("test_replace", 2) - assert(res) + self.assertTrue(res) self.assertTrue(res.success) spans = self.recorder.queued_spans() self.assertEqual(2, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_span.t) self.assertEqual(cb_span.p, test_span.s) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertIsNone(cb_span.ec) self.assertEqual(cb_span.data["couchbase"]["hostname"], "%s:8091" % testenv['couchdb_host']) @@ -305,17 +305,17 @@ def test_replace_non_existent(self): self.assertEqual(2, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_span.t) self.assertEqual(cb_span.p, test_span.s) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertEqual(cb_span.ec, 1) # Just search for the substring of the exception class found = cb_span.data["couchbase"]["error"].find("NotFoundError") @@ -338,7 +338,7 @@ def test_replace_multi(self): with tracer.start_active_span('test'): res = self.bucket.replace_multi(kvs) - assert(res) + self.assertTrue(res) self.assertTrue(res['first_test_replace_multi'].success) self.assertTrue(res['second_test_replace_multi'].success) @@ -346,17 +346,17 @@ def test_replace_multi(self): self.assertEqual(2, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_span.t) self.assertEqual(cb_span.p, test_span.s) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertIsNone(cb_span.ec) self.assertEqual(cb_span.data["couchbase"]["hostname"], "%s:8091" % testenv['couchdb_host']) @@ -370,24 +370,24 @@ def test_append(self): with tracer.start_active_span('test'): res = self.bucket.append("test_append", "two") - assert(res) + self.assertTrue(res) self.assertTrue(res.success) spans = self.recorder.queued_spans() self.assertEqual(2, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_span.t) self.assertEqual(cb_span.p, test_span.s) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertIsNone(cb_span.ec) self.assertEqual(cb_span.data["couchbase"]["hostname"], "%s:8091" % testenv['couchdb_host']) @@ -407,7 +407,7 @@ def test_append_multi(self): with tracer.start_active_span('test'): res = self.bucket.append_multi(kvs) - assert(res) + self.assertTrue(res) self.assertTrue(res['first_test_append_multi'].success) self.assertTrue(res['second_test_append_multi'].success) @@ -415,17 +415,17 @@ def test_append_multi(self): self.assertEqual(2, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_span.t) self.assertEqual(cb_span.p, test_span.s) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertIsNone(cb_span.ec) self.assertEqual(cb_span.data["couchbase"]["hostname"], "%s:8091" % testenv['couchdb_host']) @@ -439,24 +439,24 @@ def test_prepend(self): with tracer.start_active_span('test'): res = self.bucket.prepend("test_prepend", "two") - assert(res) + self.assertTrue(res) self.assertTrue(res.success) spans = self.recorder.queued_spans() self.assertEqual(2, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_span.t) self.assertEqual(cb_span.p, test_span.s) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertIsNone(cb_span.ec) self.assertEqual(cb_span.data["couchbase"]["hostname"], "%s:8091" % testenv['couchdb_host']) @@ -476,7 +476,7 @@ def test_prepend_multi(self): with tracer.start_active_span('test'): res = self.bucket.prepend_multi(kvs) - assert(res) + self.assertTrue(res) self.assertTrue(res['first_test_prepend_multi'].success) self.assertTrue(res['second_test_prepend_multi'].success) @@ -484,17 +484,17 @@ def test_prepend_multi(self): self.assertEqual(2, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_span.t) self.assertEqual(cb_span.p, test_span.s) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertIsNone(cb_span.ec) self.assertEqual(cb_span.data["couchbase"]["hostname"], "%s:8091" % testenv['couchdb_host']) @@ -507,24 +507,24 @@ def test_get(self): with tracer.start_active_span('test'): res = self.bucket.get("test-key") - assert(res) + self.assertTrue(res) self.assertTrue(res.success) spans = self.recorder.queued_spans() self.assertEqual(2, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_span.t) self.assertEqual(cb_span.p, test_span.s) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertIsNone(cb_span.ec) self.assertEqual(cb_span.data["couchbase"]["hostname"], "%s:8091" % testenv['couchdb_host']) @@ -546,17 +546,17 @@ def test_rget(self): self.assertEqual(2, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_span.t) self.assertEqual(cb_span.p, test_span.s) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertEqual(cb_span.ec, 1) # Just search for the substring of the exception class found = cb_span.data["couchbase"]["error"].find("CouchbaseTransientError") @@ -585,17 +585,17 @@ def test_get_not_found(self): self.assertEqual(2, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_span.t) self.assertEqual(cb_span.p, test_span.s) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertEqual(cb_span.ec, 1) # Just search for the substring of the exception class found = cb_span.data["couchbase"]["error"].find("NotFoundError") @@ -614,7 +614,7 @@ def test_get_multi(self): with tracer.start_active_span('test'): res = self.bucket.get_multi(['first_test_get_multi', 'second_test_get_multi']) - assert(res) + self.assertTrue(res) self.assertTrue(res['first_test_get_multi'].success) self.assertTrue(res['second_test_get_multi'].success) @@ -622,17 +622,17 @@ def test_get_multi(self): self.assertEqual(2, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_span.t) self.assertEqual(cb_span.p, test_span.s) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertIsNone(cb_span.ec) self.assertEqual(cb_span.data["couchbase"]["hostname"], "%s:8091" % testenv['couchdb_host']) @@ -646,24 +646,24 @@ def test_touch(self): with tracer.start_active_span('test'): res = self.bucket.touch("test_touch") - assert(res) + self.assertTrue(res) self.assertTrue(res.success) spans = self.recorder.queued_spans() self.assertEqual(2, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_span.t) self.assertEqual(cb_span.p, test_span.s) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertIsNone(cb_span.ec) self.assertEqual(cb_span.data["couchbase"]["hostname"], "%s:8091" % testenv['couchdb_host']) @@ -679,7 +679,7 @@ def test_touch_multi(self): with tracer.start_active_span('test'): res = self.bucket.touch_multi(['first_test_touch_multi', 'second_test_touch_multi']) - assert(res) + self.assertTrue(res) self.assertTrue(res['first_test_touch_multi'].success) self.assertTrue(res['second_test_touch_multi'].success) @@ -687,17 +687,17 @@ def test_touch_multi(self): self.assertEqual(2, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_span.t) self.assertEqual(cb_span.p, test_span.s) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertIsNone(cb_span.ec) self.assertEqual(cb_span.data["couchbase"]["hostname"], "%s:8091" % testenv['couchdb_host']) @@ -710,28 +710,28 @@ def test_lock(self): with tracer.start_active_span('test'): rv = self.bucket.lock("test_lock_unlock", ttl=5) - assert(rv) + self.assertTrue(rv) self.assertTrue(rv.success) # upsert automatically unlocks the key res = self.bucket.upsert("test_lock_unlock", "updated", rv.cas) - assert(res) + self.assertTrue(res) self.assertTrue(res.success) spans = self.recorder.queued_spans() self.assertEqual(3, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') filter = lambda span: span.n == "couchbase" and span.data["couchbase"]["type"] == "lock" cb_lock_span = get_first_span_by_filter(spans, filter) - assert(cb_lock_span) + self.assertTrue(cb_lock_span) filter = lambda span: span.n == "couchbase" and span.data["couchbase"]["type"] == "upsert" cb_upsert_span = get_first_span_by_filter(spans, filter) - assert(cb_upsert_span) + self.assertTrue(cb_upsert_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_lock_span.t) @@ -740,9 +740,9 @@ def test_lock(self): self.assertEqual(cb_lock_span.p, test_span.s) self.assertEqual(cb_upsert_span.p, test_span.s) - assert(cb_lock_span.stack) + self.assertTrue(cb_lock_span.stack) self.assertIsNone(cb_lock_span.ec) - assert(cb_upsert_span.stack) + self.assertTrue(cb_upsert_span.stack) self.assertIsNone(cb_upsert_span.ec) self.assertEqual(cb_lock_span.data["couchbase"]["hostname"], "%s:8091" % testenv['couchdb_host']) @@ -758,28 +758,28 @@ def test_lock_unlock(self): with tracer.start_active_span('test'): rv = self.bucket.lock("test_lock_unlock", ttl=5) - assert(rv) + self.assertTrue(rv) self.assertTrue(rv.success) # upsert automatically unlocks the key res = self.bucket.unlock("test_lock_unlock", rv.cas) - assert(res) + self.assertTrue(res) self.assertTrue(res.success) spans = self.recorder.queued_spans() self.assertEqual(3, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') filter = lambda span: span.n == "couchbase" and span.data["couchbase"]["type"] == "lock" cb_lock_span = get_first_span_by_filter(spans, filter) - assert(cb_lock_span) + self.assertTrue(cb_lock_span) filter = lambda span: span.n == "couchbase" and span.data["couchbase"]["type"] == "unlock" cb_unlock_span = get_first_span_by_filter(spans, filter) - assert(cb_unlock_span) + self.assertTrue(cb_unlock_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_lock_span.t) @@ -788,9 +788,9 @@ def test_lock_unlock(self): self.assertEqual(cb_lock_span.p, test_span.s) self.assertEqual(cb_unlock_span.p, test_span.s) - assert(cb_lock_span.stack) + self.assertTrue(cb_lock_span.stack) self.assertIsNone(cb_lock_span.ec) - assert(cb_unlock_span.stack) + self.assertTrue(cb_unlock_span.stack) self.assertIsNone(cb_unlock_span.ec) self.assertEqual(cb_lock_span.data["couchbase"]["hostname"], "%s:8091" % testenv['couchdb_host']) @@ -809,27 +809,27 @@ def test_lock_unlock_muilti(self): with tracer.start_active_span('test'): rv = self.bucket.lock_multi(keys_to_lock, ttl=5) - assert(rv) + self.assertTrue(rv) self.assertTrue(rv['test_lock_unlock_multi_1'].success) self.assertTrue(rv['test_lock_unlock_multi_2'].success) res = self.bucket.unlock_multi(rv) - assert(res) + self.assertTrue(res) spans = self.recorder.queued_spans() self.assertEqual(3, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') filter = lambda span: span.n == "couchbase" and span.data["couchbase"]["type"] == "lock_multi" cb_lock_span = get_first_span_by_filter(spans, filter) - assert(cb_lock_span) + self.assertTrue(cb_lock_span) filter = lambda span: span.n == "couchbase" and span.data["couchbase"]["type"] == "unlock_multi" cb_unlock_span = get_first_span_by_filter(spans, filter) - assert(cb_unlock_span) + self.assertTrue(cb_unlock_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_lock_span.t) @@ -838,9 +838,9 @@ def test_lock_unlock_muilti(self): self.assertEqual(cb_lock_span.p, test_span.s) self.assertEqual(cb_unlock_span.p, test_span.s) - assert(cb_lock_span.stack) + self.assertTrue(cb_lock_span.stack) self.assertIsNone(cb_lock_span.ec) - assert(cb_unlock_span.stack) + self.assertTrue(cb_unlock_span.stack) self.assertIsNone(cb_unlock_span.ec) self.assertEqual(cb_lock_span.data["couchbase"]["hostname"], "%s:8091" % testenv['couchdb_host']) @@ -857,24 +857,24 @@ def test_remove(self): with tracer.start_active_span('test'): res = self.bucket.remove("test_remove") - assert(res) + self.assertTrue(res) self.assertTrue(res.success) spans = self.recorder.queued_spans() self.assertEqual(2, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_span.t) self.assertEqual(cb_span.p, test_span.s) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertIsNone(cb_span.ec) self.assertEqual(cb_span.data["couchbase"]["hostname"], "%s:8091" % testenv['couchdb_host']) @@ -891,7 +891,7 @@ def test_remove_multi(self): with tracer.start_active_span('test'): res = self.bucket.remove_multi(keys_to_remove) - assert(res) + self.assertTrue(res) self.assertTrue(res['test_remove_multi_1'].success) self.assertTrue(res['test_remove_multi_2'].success) @@ -899,17 +899,17 @@ def test_remove_multi(self): self.assertEqual(2, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_span.t) self.assertEqual(cb_span.p, test_span.s) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertIsNone(cb_span.ec) self.assertEqual(cb_span.data["couchbase"]["hostname"], "%s:8091" % testenv['couchdb_host']) @@ -923,24 +923,24 @@ def test_counter(self): with tracer.start_active_span('test'): res = self.bucket.counter("test_counter", delta=10) - assert(res) + self.assertTrue(res) self.assertTrue(res.success) spans = self.recorder.queued_spans() self.assertEqual(2, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_span.t) self.assertEqual(cb_span.p, test_span.s) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertIsNone(cb_span.ec) self.assertEqual(cb_span.data["couchbase"]["hostname"], "%s:8091" % testenv['couchdb_host']) @@ -955,7 +955,7 @@ def test_counter_multi(self): with tracer.start_active_span('test'): res = self.bucket.counter_multi(("first_test_counter", "second_test_counter")) - assert(res) + self.assertTrue(res) self.assertTrue(res['first_test_counter'].success) self.assertTrue(res['second_test_counter'].success) @@ -963,17 +963,17 @@ def test_counter_multi(self): self.assertEqual(2, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_span.t) self.assertEqual(cb_span.p, test_span.s) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertIsNone(cb_span.ec) self.assertEqual(cb_span.data["couchbase"]["hostname"], "%s:8091" % testenv['couchdb_host']) @@ -990,24 +990,24 @@ def test_mutate_in(self): SD.array_addunique('interests', 'Cats'), SD.counter('updates', 1)) - assert(res) + self.assertTrue(res) self.assertTrue(res.success) spans = self.recorder.queued_spans() self.assertEqual(2, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_span.t) self.assertEqual(cb_span.p, test_span.s) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertIsNone(cb_span.ec) self.assertEqual(cb_span.data["couchbase"]["hostname"], "%s:8091" % testenv['couchdb_host']) @@ -1024,24 +1024,24 @@ def test_lookup_in(self): SD.get('email'), SD.get('interests')) - assert(res) + self.assertTrue(res) self.assertTrue(res.success) spans = self.recorder.queued_spans() self.assertEqual(2, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_span.t) self.assertEqual(cb_span.p, test_span.s) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertIsNone(cb_span.ec) self.assertEqual(cb_span.data["couchbase"]["hostname"], "%s:8091" % testenv['couchdb_host']) @@ -1054,23 +1054,23 @@ def test_stats(self): with tracer.start_active_span('test'): res = self.bucket.stats() - assert(res) + self.assertTrue(res) spans = self.recorder.queued_spans() self.assertEqual(2, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_span.t) self.assertEqual(cb_span.p, test_span.s) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertIsNone(cb_span.ec) self.assertEqual(cb_span.data["couchbase"]["hostname"], "%s:8091" % testenv['couchdb_host']) @@ -1083,23 +1083,23 @@ def test_ping(self): with tracer.start_active_span('test'): res = self.bucket.ping() - assert(res) + self.assertTrue(res) spans = self.recorder.queued_spans() self.assertEqual(2, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_span.t) self.assertEqual(cb_span.p, test_span.s) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertIsNone(cb_span.ec) self.assertEqual(cb_span.data["couchbase"]["hostname"], "%s:8091" % testenv['couchdb_host']) @@ -1112,23 +1112,23 @@ def test_diagnostics(self): with tracer.start_active_span('test'): res = self.bucket.diagnostics() - assert(res) + self.assertTrue(res) spans = self.recorder.queued_spans() self.assertEqual(2, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_span.t) self.assertEqual(cb_span.p, test_span.s) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertIsNone(cb_span.ec) self.assertEqual(cb_span.data["couchbase"]["hostname"], "%s:8091" % testenv['couchdb_host']) @@ -1142,24 +1142,24 @@ def test_observe(self): with tracer.start_active_span('test'): res = self.bucket.observe('test_observe') - assert(res) + self.assertTrue(res) self.assertTrue(res.success) spans = self.recorder.queued_spans() self.assertEqual(2, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_span.t) self.assertEqual(cb_span.p, test_span.s) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertIsNone(cb_span.ec) self.assertEqual(cb_span.data["couchbase"]["hostname"], "%s:8091" % testenv['couchdb_host']) @@ -1176,7 +1176,7 @@ def test_observe_multi(self): with tracer.start_active_span('test'): res = self.bucket.observe_multi(keys_to_observe) - assert(res) + self.assertTrue(res) self.assertTrue(res['test_observe_multi_1'].success) self.assertTrue(res['test_observe_multi_2'].success) @@ -1184,17 +1184,17 @@ def test_observe_multi(self): self.assertEqual(2, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_span.t) self.assertEqual(cb_span.p, test_span.s) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertIsNone(cb_span.ec) self.assertEqual(cb_span.data["couchbase"]["hostname"], "%s:8091" % testenv['couchdb_host']) @@ -1207,23 +1207,23 @@ def test_raw_n1ql_query(self): with tracer.start_active_span('test'): res = self.bucket.n1ql_query("SELECT 1") - assert(res) + self.assertTrue(res) spans = self.recorder.queued_spans() self.assertEqual(2, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_span.t) self.assertEqual(cb_span.p, test_span.s) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertIsNone(cb_span.ec) self.assertEqual(cb_span.data["couchbase"]["hostname"], "%s:8091" % testenv['couchdb_host']) @@ -1237,23 +1237,23 @@ def test_n1ql_query(self): with tracer.start_active_span('test'): res = self.bucket.n1ql_query(N1QLQuery('SELECT name FROM `travel-sample` WHERE brewery_id ="mishawaka_brewing"')) - assert(res) + self.assertTrue(res) spans = self.recorder.queued_spans() self.assertEqual(2, len(spans)) test_span = get_first_span_by_name(spans, 'sdk') - assert(test_span) + self.assertTrue(test_span) self.assertEqual(test_span.data["sdk"]["name"], 'test') cb_span = get_first_span_by_name(spans, 'couchbase') - assert(cb_span) + self.assertTrue(cb_span) # Same traceId and parent relationship self.assertEqual(test_span.t, cb_span.t) self.assertEqual(cb_span.p, test_span.s) - assert(cb_span.stack) + self.assertTrue(cb_span.stack) self.assertIsNone(cb_span.ec) self.assertEqual(cb_span.data["couchbase"]["hostname"], "%s:8091" % testenv['couchdb_host']) diff --git a/tests/clients/test_google-cloud-pubsub.py b/tests/clients/test_google-cloud-pubsub.py index 8e6ed5f90..48b57eda9 100644 --- a/tests/clients/test_google-cloud-pubsub.py +++ b/tests/clients/test_google-cloud-pubsub.py @@ -49,7 +49,7 @@ def test_publish(self): origin="instana") time.sleep(2.0) # for sanity result = future.result() - assert isinstance(result, six.string_types) + self.assertIsInstance(result, six.string_types) spans = self.recorder.queued_spans() gcps_span, test_span = spans[0], spans[1] @@ -76,7 +76,7 @@ def test_publish_as_root_exit_span(self): origin="instana") time.sleep(2.0) # for sanity result = future.result() - assert isinstance(result, six.string_types) + self.assertIsInstance(result, six.string_types) spans = self.recorder.queued_spans() self.assertEqual(1, len(spans)) diff --git a/tests/frameworks/test_aiohttp_client.py b/tests/frameworks/test_aiohttp_client.py index 20f82130d..08cbbfe24 100644 --- a/tests/frameworks/test_aiohttp_client.py +++ b/tests/frameworks/test_aiohttp_client.py @@ -73,13 +73,13 @@ async def test(): self.assertTrue(type(aiohttp_span.stack) is list) self.assertTrue(len(aiohttp_span.stack) > 1) - assert "X-INSTANA-T" in response.headers + self.assertIn("X-INSTANA-T", response.headers) self.assertEqual(response.headers["X-INSTANA-T"], traceId) - assert "X-INSTANA-S" in response.headers + self.assertIn("X-INSTANA-S", response.headers) self.assertEqual(response.headers["X-INSTANA-S"], wsgi_span.s) - assert "X-INSTANA-L" in response.headers + self.assertIn("X-INSTANA-L", response.headers) self.assertEqual(response.headers["X-INSTANA-L"], '1') - assert "Server-Timing" in response.headers + self.assertIn("Server-Timing", response.headers) self.assertEqual( response.headers["Server-Timing"], "intid;desc=%s" % traceId) @@ -127,13 +127,13 @@ async def test(): self.assertTrue(type(aiohttp_span.stack) is list) self.assertTrue(len(aiohttp_span.stack) > 1) - assert "X-INSTANA-T" in response.headers + self.assertIn("X-INSTANA-T", response.headers) self.assertEqual(response.headers["X-INSTANA-T"], traceId) - assert "X-INSTANA-S" in response.headers + self.assertIn("X-INSTANA-S", response.headers) self.assertEqual(response.headers["X-INSTANA-S"], wsgi_span2.s) - assert "X-INSTANA-L" in response.headers + self.assertIn("X-INSTANA-L", response.headers) self.assertEqual(response.headers["X-INSTANA-L"], '1') - assert "Server-Timing" in response.headers + self.assertIn("Server-Timing", response.headers) self.assertEqual( response.headers["Server-Timing"], "intid;desc=%s" % traceId) @@ -177,13 +177,13 @@ async def test(): self.assertTrue(type(aiohttp_span.stack) is list) self.assertTrue(len(aiohttp_span.stack) > 1) - assert "X-INSTANA-T" in response.headers + self.assertIn("X-INSTANA-T", response.headers) self.assertEqual(response.headers["X-INSTANA-T"], traceId) - assert "X-INSTANA-S" in response.headers + self.assertIn("X-INSTANA-S", response.headers) self.assertEqual(response.headers["X-INSTANA-S"], wsgi_span.s) - assert "X-INSTANA-L" in response.headers + self.assertIn("X-INSTANA-L", response.headers) self.assertEqual(response.headers["X-INSTANA-L"], '1') - assert "Server-Timing" in response.headers + self.assertIn("Server-Timing", response.headers) self.assertEqual( response.headers["Server-Timing"], "intid;desc=%s" % traceId) @@ -229,13 +229,13 @@ async def test(): self.assertTrue(type(aiohttp_span.stack) is list) self.assertTrue(len(aiohttp_span.stack) > 1) - assert "X-INSTANA-T" in response.headers + self.assertIn("X-INSTANA-T", response.headers) self.assertEqual(response.headers["X-INSTANA-T"], traceId) - assert "X-INSTANA-S" in response.headers + self.assertIn("X-INSTANA-S", response.headers) self.assertEqual(response.headers["X-INSTANA-S"], wsgi_span.s) - assert "X-INSTANA-L" in response.headers + self.assertIn("X-INSTANA-L", response.headers) self.assertEqual(response.headers["X-INSTANA-L"], '1') - assert "Server-Timing" in response.headers + self.assertIn("Server-Timing", response.headers) self.assertEqual( response.headers["Server-Timing"], "intid;desc=%s" % traceId) @@ -280,13 +280,13 @@ async def test(): self.assertTrue(type(aiohttp_span.stack) is list) self.assertTrue(len(aiohttp_span.stack) > 1) - assert "X-INSTANA-T" in response.headers + self.assertIn("X-INSTANA-T", response.headers) self.assertEqual(response.headers["X-INSTANA-T"], traceId) - assert "X-INSTANA-S" in response.headers + self.assertIn("X-INSTANA-S", response.headers) self.assertEqual(response.headers["X-INSTANA-S"], wsgi_span.s) - assert "X-INSTANA-L" in response.headers + self.assertIn("X-INSTANA-L", response.headers) self.assertEqual(response.headers["X-INSTANA-L"], '1') - assert "Server-Timing" in response.headers + self.assertIn("Server-Timing", response.headers) self.assertEqual( response.headers["Server-Timing"], "intid;desc=%s" % traceId) @@ -332,13 +332,13 @@ async def test(): self.assertTrue(type(aiohttp_span.stack) is list) self.assertTrue(len(aiohttp_span.stack) > 1) - assert "X-INSTANA-T" in response.headers + self.assertIn("X-INSTANA-T", response.headers) self.assertEqual(response.headers["X-INSTANA-T"], traceId) - assert "X-INSTANA-S" in response.headers + self.assertIn("X-INSTANA-S", response.headers) self.assertEqual(response.headers["X-INSTANA-S"], wsgi_span.s) - assert "X-INSTANA-L" in response.headers + self.assertIn("X-INSTANA-L", response.headers) self.assertEqual(response.headers["X-INSTANA-L"], '1') - assert "Server-Timing" in response.headers + self.assertIn("Server-Timing", response.headers) self.assertEqual( response.headers["Server-Timing"], "intid;desc=%s" % traceId) @@ -384,16 +384,16 @@ async def test(): self.assertTrue(type(aiohttp_span.stack) is list) self.assertTrue(len(aiohttp_span.stack) > 1) - assert "X-Capture-This" in aiohttp_span.data["http"]["header"] + self.assertIn("X-Capture-This", aiohttp_span.data["http"]["header"]) self.assertEqual("Ok", aiohttp_span.data["http"]["header"]["X-Capture-This"]) - assert "X-INSTANA-T" in response.headers + self.assertIn("X-INSTANA-T", response.headers) self.assertEqual(response.headers["X-INSTANA-T"], traceId) - assert "X-INSTANA-S" in response.headers + self.assertIn("X-INSTANA-S", response.headers) self.assertEqual(response.headers["X-INSTANA-S"], wsgi_span.s) - assert "X-INSTANA-L" in response.headers + self.assertIn("X-INSTANA-L", response.headers) self.assertEqual(response.headers["X-INSTANA-L"], '1') - assert "Server-Timing" in response.headers + self.assertIn("Server-Timing", response.headers) self.assertEqual(response.headers["Server-Timing"], "intid;desc=%s" % traceId) agent.options.extra_http_headers = original_extra_http_headers @@ -435,7 +435,7 @@ async def test(): aiohttp_span.data["http"]["url"]) self.assertEqual("GET", aiohttp_span.data["http"]["method"]) self.assertIsNotNone(aiohttp_span.data["http"]["error"]) - assert(len(aiohttp_span.data["http"]["error"])) + self.assertTrue(len(aiohttp_span.data["http"]["error"])) self.assertIsNotNone(aiohttp_span.stack) self.assertTrue(type(aiohttp_span.stack) is list) self.assertTrue(len(aiohttp_span.stack) > 1) diff --git a/tests/frameworks/test_aiohttp_server.py b/tests/frameworks/test_aiohttp_server.py index 9c5127ae6..41dd2ce85 100644 --- a/tests/frameworks/test_aiohttp_server.py +++ b/tests/frameworks/test_aiohttp_server.py @@ -84,13 +84,13 @@ async def test(): self.assertTrue(type(aioclient_span.stack) is list) self.assertTrue(len(aioclient_span.stack) > 1) - assert "X-INSTANA-T" in response.headers + self.assertIn("X-INSTANA-T", response.headers) self.assertEqual(response.headers["X-INSTANA-T"], traceId) - assert "X-INSTANA-S" in response.headers + self.assertIn("X-INSTANA-S", response.headers) self.assertEqual(response.headers["X-INSTANA-S"], aioserver_span.s) - assert "X-INSTANA-L" in response.headers + self.assertIn("X-INSTANA-L", response.headers) self.assertEqual(response.headers["X-INSTANA-L"], '1') - assert "Server-Timing" in response.headers + self.assertIn("Server-Timing", response.headers) self.assertEqual( response.headers["Server-Timing"], "intid;desc=%s" % traceId) @@ -146,13 +146,13 @@ async def test(): self.assertTrue(isinstance(aioclient_span.stack, list)) self.assertTrue(len(aioclient_span.stack) > 1) - assert "X-INSTANA-T" in response.headers + self.assertIn("X-INSTANA-T", response.headers) self.assertEqual(response.headers["X-INSTANA-T"], trace_id) - assert "X-INSTANA-S" in response.headers + self.assertIn("X-INSTANA-S", response.headers) self.assertEqual(response.headers["X-INSTANA-S"], aioserver_span.s) - assert "X-INSTANA-L" in response.headers + self.assertIn("X-INSTANA-L", response.headers) self.assertEqual(response.headers["X-INSTANA-L"], '1') - assert "Server-Timing" in response.headers + self.assertIn("Server-Timing", response.headers) self.assertEqual( response.headers["Server-Timing"], "intid;desc=%s" % trace_id) @@ -230,13 +230,13 @@ async def test(): self.assertTrue(type(aioclient_span.stack) is list) self.assertTrue(len(aioclient_span.stack) > 1) - assert "X-INSTANA-T" in response.headers + self.assertIn("X-INSTANA-T", response.headers) self.assertEqual(response.headers["X-INSTANA-T"], traceId) - assert "X-INSTANA-S" in response.headers + self.assertIn("X-INSTANA-S", response.headers) self.assertEqual(response.headers["X-INSTANA-S"], aioserver_span.s) - assert "X-INSTANA-L" in response.headers + self.assertIn("X-INSTANA-L", response.headers) self.assertEqual(response.headers["X-INSTANA-L"], '1') - assert "Server-Timing" in response.headers + self.assertIn("Server-Timing", response.headers) self.assertEqual( response.headers["Server-Timing"], "intid;desc=%s" % traceId) @@ -299,19 +299,19 @@ async def test(): self.assertTrue(type(aioclient_span.stack) is list) self.assertTrue(len(aioclient_span.stack) > 1) - assert "X-INSTANA-T" in response.headers + self.assertIn("X-INSTANA-T", response.headers) self.assertEqual(response.headers["X-INSTANA-T"], traceId) - assert "X-INSTANA-S" in response.headers + self.assertIn("X-INSTANA-S", response.headers) self.assertEqual(response.headers["X-INSTANA-S"], aioserver_span.s) - assert "X-INSTANA-L" in response.headers + self.assertIn("X-INSTANA-L", response.headers) self.assertEqual(response.headers["X-INSTANA-L"], '1') - assert "Server-Timing" in response.headers + self.assertIn("Server-Timing", response.headers) self.assertEqual( response.headers["Server-Timing"], "intid;desc=%s" % traceId) - assert "X-Capture-This" in aioserver_span.data["http"]["header"] + self.assertIn("X-Capture-This", aioserver_span.data["http"]["header"]) self.assertEqual("this", aioserver_span.data["http"]["header"]["X-Capture-This"]) - assert "X-Capture-That" in aioserver_span.data["http"]["header"] + self.assertIn("X-Capture-That", aioserver_span.data["http"]["header"]) self.assertEqual("that", aioserver_span.data["http"]["header"]["X-Capture-That"]) def test_server_get_401(self): @@ -361,13 +361,13 @@ async def test(): self.assertTrue(type(aioclient_span.stack) is list) self.assertTrue(len(aioclient_span.stack) > 1) - assert "X-INSTANA-T" in response.headers + self.assertIn("X-INSTANA-T", response.headers) self.assertEqual(response.headers["X-INSTANA-T"], traceId) - assert "X-INSTANA-S" in response.headers + self.assertIn("X-INSTANA-S", response.headers) self.assertEqual(response.headers["X-INSTANA-S"], aioserver_span.s) - assert "X-INSTANA-L" in response.headers + self.assertIn("X-INSTANA-L", response.headers) self.assertEqual(response.headers["X-INSTANA-L"], '1') - assert "Server-Timing" in response.headers + self.assertIn("Server-Timing", response.headers) self.assertEqual( response.headers["Server-Timing"], "intid;desc=%s" % traceId) @@ -420,13 +420,13 @@ async def test(): self.assertTrue(type(aioclient_span.stack) is list) self.assertTrue(len(aioclient_span.stack) > 1) - assert "X-INSTANA-T" in response.headers + self.assertIn("X-INSTANA-T", response.headers) self.assertEqual(response.headers["X-INSTANA-T"], traceId) - assert "X-INSTANA-S" in response.headers + self.assertIn("X-INSTANA-S", response.headers) self.assertEqual(response.headers["X-INSTANA-S"], aioserver_span.s) - assert "X-INSTANA-L" in response.headers + self.assertIn("X-INSTANA-L", response.headers) self.assertEqual(response.headers["X-INSTANA-L"], '1') - assert "Server-Timing" in response.headers + self.assertIn("Server-Timing", response.headers) self.assertEqual( response.headers["Server-Timing"], "intid;desc=%s" % traceId) diff --git a/tests/frameworks/test_grpcio.py b/tests/frameworks/test_grpcio.py index 09572a5e7..5bbd47db0 100644 --- a/tests/frameworks/test_grpcio.py +++ b/tests/frameworks/test_grpcio.py @@ -66,9 +66,9 @@ def test_unary_one_to_one(self): client_span = get_first_span_by_name(spans, 'rpc-client') test_span = get_first_span_by_name(spans, 'sdk') - assert(server_span) - assert(client_span) - assert(test_span) + self.assertTrue(server_span) + self.assertTrue(client_span) + self.assertTrue(test_span) # Same traceId self.assertEqual(server_span.t, client_span.t) @@ -126,9 +126,9 @@ def test_streaming_many_to_one(self): client_span = get_first_span_by_name(spans, 'rpc-client') test_span = get_first_span_by_name(spans, 'sdk') - assert(server_span) - assert(client_span) - assert(test_span) + self.assertTrue(server_span) + self.assertTrue(client_span) + self.assertTrue(test_span) # Same traceId self.assertEqual(server_span.t, client_span.t) @@ -189,9 +189,9 @@ def test_streaming_one_to_many(self): client_span = get_first_span_by_name(spans, 'rpc-client') test_span = get_first_span_by_name(spans, 'sdk') - assert(server_span) - assert(client_span) - assert(test_span) + self.assertTrue(server_span) + self.assertTrue(client_span) + self.assertTrue(test_span) # Same traceId self.assertEqual(server_span.t, client_span.t) @@ -251,9 +251,9 @@ def test_streaming_many_to_many(self): client_span = get_first_span_by_name(spans, 'rpc-client') test_span = get_first_span_by_name(spans, 'sdk') - assert(server_span) - assert(client_span) - assert(test_span) + self.assertTrue(server_span) + self.assertTrue(client_span) + self.assertTrue(test_span) # Same traceId self.assertEqual(server_span.t, client_span.t) @@ -309,9 +309,9 @@ def test_unary_one_to_one_with_call(self): client_span = get_first_span_by_name(spans, 'rpc-client') test_span = get_first_span_by_name(spans, 'sdk') - assert(server_span) - assert(client_span) - assert(test_span) + self.assertTrue(server_span) + self.assertTrue(client_span) + self.assertTrue(test_span) # Same traceId self.assertEqual(server_span.t, client_span.t) @@ -368,9 +368,9 @@ def test_streaming_many_to_one_with_call(self): client_span = get_first_span_by_name(spans, 'rpc-client') test_span = get_first_span_by_name(spans, 'sdk') - assert(server_span) - assert(client_span) - assert(test_span) + self.assertTrue(server_span) + self.assertTrue(client_span) + self.assertTrue(test_span) # Same traceId self.assertEqual(server_span.t, client_span.t) @@ -431,9 +431,9 @@ def process_response(future): client_span = get_first_span_by_name(spans, 'rpc-client') test_span = get_first_span_by_name(spans, 'sdk') - assert(server_span) - assert(client_span) - assert(test_span) + self.assertTrue(server_span) + self.assertTrue(client_span) + self.assertTrue(test_span) # Same traceId self.assertEqual(server_span.t, client_span.t) @@ -496,9 +496,9 @@ def process_response(future): client_span = get_first_span_by_name(spans, 'rpc-client') test_span = get_first_span_by_name(spans, 'sdk') - assert(server_span) - assert(client_span) - assert(test_span) + self.assertTrue(server_span) + self.assertTrue(client_span) + self.assertTrue(test_span) # Same traceId self.assertEqual(server_span.t, client_span.t) @@ -557,10 +557,10 @@ def test_server_error(self): client_span = get_first_span_by_name(spans, 'rpc-client') test_span = get_first_span_by_name(spans, 'sdk') - assert(log_span) - assert(server_span) - assert(client_span) - assert(test_span) + self.assertTrue(log_span) + self.assertTrue(server_span) + self.assertTrue(client_span) + self.assertTrue(test_span) # Same traceId self.assertEqual(server_span.t, client_span.t) diff --git a/tests/frameworks/test_tornado_client.py b/tests/frameworks/test_tornado_client.py index 2980f226b..244a03b7f 100644 --- a/tests/frameworks/test_tornado_client.py +++ b/tests/frameworks/test_tornado_client.py @@ -37,7 +37,7 @@ async def test(): return await self.http_client.fetch(testenv["tornado_server"] + "/") response = tornado.ioloop.IOLoop.current().run_sync(test) - assert isinstance(response, tornado.httpclient.HTTPResponse) + self.assertIsinstance(response, tornado.httpclient.HTTPResponse) time.sleep(0.5) spans = self.recorder.queued_spans() @@ -81,13 +81,13 @@ async def test(): self.assertTrue(type(client_span.stack) is list) self.assertTrue(len(client_span.stack) > 1) - assert("X-INSTANA-T" in response.headers) + self.assertIn("X-INSTANA-T", response.headers) self.assertEqual(response.headers["X-INSTANA-T"], traceId) - assert("X-INSTANA-S" in response.headers) + self.assertIn("X-INSTANA-S", response.headers) self.assertEqual(response.headers["X-INSTANA-S"], server_span.s) - assert("X-INSTANA-L" in response.headers) + self.assertIn("X-INSTANA-L", response.headers) self.assertEqual(response.headers["X-INSTANA-L"], '1') - assert("Server-Timing" in response.headers) + self.assertIn("Server-Timing", response.headers) self.assertEqual(response.headers["Server-Timing"], "intid;desc=%s" % traceId) def test_post(self): @@ -96,7 +96,7 @@ async def test(): return await self.http_client.fetch(testenv["tornado_server"] + "/", method="POST", body='asdf') response = tornado.ioloop.IOLoop.current().run_sync(test) - assert isinstance(response, tornado.httpclient.HTTPResponse) + self.assertIsInstance(response, tornado.httpclient.HTTPResponse) time.sleep(0.5) spans = self.recorder.queued_spans() @@ -139,13 +139,13 @@ async def test(): self.assertTrue(type(client_span.stack) is list) self.assertTrue(len(client_span.stack) > 1) - assert("X-INSTANA-T" in response.headers) + self.assertIn("X-INSTANA-T", response.headers) self.assertEqual(response.headers["X-INSTANA-T"], traceId) - assert("X-INSTANA-S" in response.headers) + self.assertIn("X-INSTANA-S", response.headers) self.assertEqual(response.headers["X-INSTANA-S"], server_span.s) - assert("X-INSTANA-L" in response.headers) + self.assertIn("X-INSTANA-L", response.headers) self.assertEqual(response.headers["X-INSTANA-L"], '1') - assert("Server-Timing" in response.headers) + self.assertIn("Server-Timing", response.headers) self.assertEqual(response.headers["Server-Timing"], "intid;desc=%s" % traceId) def test_get_301(self): @@ -154,7 +154,7 @@ async def test(): return await self.http_client.fetch(testenv["tornado_server"] + "/301") response = tornado.ioloop.IOLoop.current().run_sync(test) - assert isinstance(response, tornado.httpclient.HTTPResponse) + self.assertIsInstance(response, tornado.httpclient.HTTPResponse) time.sleep(0.5) spans = self.recorder.queued_spans() @@ -209,13 +209,13 @@ async def test(): self.assertTrue(type(client_span.stack) is list) self.assertTrue(len(client_span.stack) > 1) - assert("X-INSTANA-T" in response.headers) + self.assertIn("X-INSTANA-T", response.headers) self.assertEqual(response.headers["X-INSTANA-T"], traceId) - assert("X-INSTANA-S" in response.headers) + self.assertIn("X-INSTANA-S", response.headers) self.assertEqual(response.headers["X-INSTANA-S"], server_span.s) - assert("X-INSTANA-L" in response.headers) + self.assertIn("X-INSTANA-L", response.headers) self.assertEqual(response.headers["X-INSTANA-L"], '1') - assert("Server-Timing" in response.headers) + self.assertIn("Server-Timing", response.headers) self.assertEqual(response.headers["Server-Timing"], "intid;desc=%s" % traceId) def test_get_405(self): @@ -227,7 +227,7 @@ async def test(): return e.response response = tornado.ioloop.IOLoop.current().run_sync(test) - assert isinstance(response, tornado.httpclient.HTTPResponse) + self.assertIsInstance(response, tornado.httpclient.HTTPResponse) time.sleep(0.5) spans = self.recorder.queued_spans() @@ -270,13 +270,13 @@ async def test(): self.assertTrue(type(client_span.stack) is list) self.assertTrue(len(client_span.stack) > 1) - assert("X-INSTANA-T" in response.headers) + self.assertIn("X-INSTANA-T", response.headers) self.assertEqual(response.headers["X-INSTANA-T"], traceId) - assert("X-INSTANA-S" in response.headers) + self.assertIn("X-INSTANA-S", response.headers) self.assertEqual(response.headers["X-INSTANA-S"], server_span.s) - assert("X-INSTANA-L" in response.headers) + self.assertIn("X-INSTANA-L", response.headers) self.assertEqual(response.headers["X-INSTANA-L"], '1') - assert("Server-Timing" in response.headers) + self.assertIn("Server-Timing", response.headers) self.assertEqual(response.headers["Server-Timing"], "intid;desc=%s" % traceId) def test_get_500(self): @@ -288,7 +288,7 @@ async def test(): return e.response response = tornado.ioloop.IOLoop.current().run_sync(test) - assert isinstance(response, tornado.httpclient.HTTPResponse) + self.assertIsInstance(response, tornado.httpclient.HTTPResponse) time.sleep(0.5) spans = self.recorder.queued_spans() @@ -331,13 +331,13 @@ async def test(): self.assertTrue(type(client_span.stack) is list) self.assertTrue(len(client_span.stack) > 1) - assert("X-INSTANA-T" in response.headers) + self.assertIn("X-INSTANA-T", response.headers) self.assertEqual(response.headers["X-INSTANA-T"], traceId) - assert("X-INSTANA-S" in response.headers) + self.assertIn("X-INSTANA-S", response.headers) self.assertEqual(response.headers["X-INSTANA-S"], server_span.s) - assert("X-INSTANA-L" in response.headers) + self.assertIn("X-INSTANA-L", response.headers) self.assertEqual(response.headers["X-INSTANA-L"], '1') - assert("Server-Timing" in response.headers) + self.assertIn("Server-Timing", response.headers) self.assertEqual(response.headers["Server-Timing"], "intid;desc=%s" % traceId) def test_get_504(self): @@ -349,7 +349,7 @@ async def test(): return e.response response = tornado.ioloop.IOLoop.current().run_sync(test) - assert isinstance(response, tornado.httpclient.HTTPResponse) + self.assertIsInstance(response, tornado.httpclient.HTTPResponse) time.sleep(0.5) spans = self.recorder.queued_spans() @@ -392,13 +392,13 @@ async def test(): self.assertTrue(type(client_span.stack) is list) self.assertTrue(len(client_span.stack) > 1) - assert("X-INSTANA-T" in response.headers) + self.assertIn("X-INSTANA-T", response.headers) self.assertEqual(response.headers["X-INSTANA-T"], traceId) - assert("X-INSTANA-S" in response.headers) + self.assertIn("X-INSTANA-S", response.headers) self.assertEqual(response.headers["X-INSTANA-S"], server_span.s) - assert("X-INSTANA-L" in response.headers) + self.assertIn("X-INSTANA-L", response.headers) self.assertEqual(response.headers["X-INSTANA-L"], '1') - assert("Server-Timing" in response.headers) + self.assertIn("Server-Timing", response.headers) self.assertEqual(response.headers["Server-Timing"], "intid;desc=%s" % traceId) def test_get_with_params_to_scrub(self): @@ -407,7 +407,7 @@ async def test(): return await self.http_client.fetch(testenv["tornado_server"] + "/?secret=yeah") response = tornado.ioloop.IOLoop.current().run_sync(test) - assert isinstance(response, tornado.httpclient.HTTPResponse) + self.assertIsInstance(response, tornado.httpclient.HTTPResponse) time.sleep(0.5) spans = self.recorder.queued_spans() @@ -451,11 +451,11 @@ async def test(): self.assertTrue(type(client_span.stack) is list) self.assertTrue(len(client_span.stack) > 1) - assert("X-INSTANA-T" in response.headers) + self.assertIn("X-INSTANA-T", response.headers) self.assertEqual(response.headers["X-INSTANA-T"], traceId) - assert("X-INSTANA-S" in response.headers) + self.assertIn("X-INSTANA-S", response.headers) self.assertEqual(response.headers["X-INSTANA-S"], server_span.s) - assert("X-INSTANA-L" in response.headers) + self.assertIn("X-INSTANA-L", response.headers) self.assertEqual(response.headers["X-INSTANA-L"], '1') - assert("Server-Timing" in response.headers) + self.assertIn("Server-Timing", response.headers) self.assertEqual(response.headers["Server-Timing"], "intid;desc=%s" % traceId) diff --git a/tests/frameworks/test_wsgi.py b/tests/frameworks/test_wsgi.py index 25dbaa5aa..3c66b79bf 100644 --- a/tests/frameworks/test_wsgi.py +++ b/tests/frameworks/test_wsgi.py @@ -43,21 +43,21 @@ def test_get_request(self): urllib3_span = spans[1] test_span = spans[2] - assert response + self.assertTrue(response) self.assertEqual(200, response.status) - assert 'X-INSTANA-T' in response.headers - assert(int(response.headers['X-INSTANA-T'], 16)) + self.assertIn('X-INSTANA-T', response.headers) + self.assertTrue(int(response.headers['X-INSTANA-T'], 16)) self.assertEqual(response.headers['X-INSTANA-T'], wsgi_span.t) - assert 'X-INSTANA-S' in response.headers - assert(int(response.headers['X-INSTANA-S'], 16)) + self.assertIn('X-INSTANA-S', response.headers) + self.assertTrue(int(response.headers['X-INSTANA-S'], 16)) self.assertEqual(response.headers['X-INSTANA-S'], wsgi_span.s) - assert 'X-INSTANA-L' in response.headers + self.assertIn('X-INSTANA-L', response.headers) self.assertEqual(response.headers['X-INSTANA-L'], '1') - assert 'Server-Timing' in response.headers + self.assertIn('Server-Timing', response.headers) server_timing_value = "intid;desc=%s" % wsgi_span.t self.assertEqual(response.headers['Server-Timing'], server_timing_value) @@ -121,21 +121,21 @@ def test_complex_request(self): urllib3_span = spans[3] test_span = spans[4] - assert response + self.assertTrue(response) self.assertEqual(200, response.status) - assert 'X-INSTANA-T' in response.headers - assert(int(response.headers['X-INSTANA-T'], 16)) + self.assertIn('X-INSTANA-T', response.headers) + self.assertTrue(int(response.headers['X-INSTANA-T'], 16)) self.assertEqual(response.headers['X-INSTANA-T'], wsgi_span.t) - assert 'X-INSTANA-S' in response.headers - assert(int(response.headers['X-INSTANA-S'], 16)) + self.assertIn('X-INSTANA-S', response.headers) + self.assertTrue(int(response.headers['X-INSTANA-S'], 16)) self.assertEqual(response.headers['X-INSTANA-S'], wsgi_span.s) - assert 'X-INSTANA-L' in response.headers + self.assertIn('X-INSTANA-L', response.headers) self.assertEqual(response.headers['X-INSTANA-L'], '1') - assert 'Server-Timing' in response.headers + self.assertIn('Server-Timing', response.headers) server_timing_value = "intid;desc=%s" % wsgi_span.t self.assertEqual(response.headers['Server-Timing'], server_timing_value) @@ -188,21 +188,21 @@ def test_custom_header_capture(self): urllib3_span = spans[1] test_span = spans[2] - assert response + self.assertTrue(response) self.assertEqual(200, response.status) - assert 'X-INSTANA-T' in response.headers - assert(int(response.headers['X-INSTANA-T'], 16)) + self.assertIn('X-INSTANA-T', response.headers) + self.assertTrue(int(response.headers['X-INSTANA-T'], 16)) self.assertEqual(response.headers['X-INSTANA-T'], wsgi_span.t) - assert 'X-INSTANA-S' in response.headers - assert(int(response.headers['X-INSTANA-S'], 16)) + self.assertIn('X-INSTANA-S', response.headers) + self.assertTrue(int(response.headers['X-INSTANA-S'], 16)) self.assertEqual(response.headers['X-INSTANA-S'], wsgi_span.s) - assert 'X-INSTANA-L' in response.headers + self.assertIn('X-INSTANA-L', response.headers) self.assertEqual(response.headers['X-INSTANA-L'], '1') - assert 'Server-Timing' in response.headers + self.assertIn('Server-Timing', response.headers) server_timing_value = "intid;desc=%s" % wsgi_span.t self.assertEqual(response.headers['Server-Timing'], server_timing_value) @@ -228,9 +228,9 @@ def test_custom_header_capture(self): self.assertIsNone(wsgi_span.data["http"]["error"]) self.assertIsNone(wsgi_span.stack) - assert "X-Capture-This" in wsgi_span.data["http"]["header"] + self.assertIn("X-Capture-This", wsgi_span.data["http"]["header"]) self.assertEqual("this", wsgi_span.data["http"]["header"]["X-Capture-This"]) - assert "X-Capture-That" in wsgi_span.data["http"]["header"] + self.assertIn("X-Capture-That", wsgi_span.data["http"]["header"]) self.assertEqual("that", wsgi_span.data["http"]["header"]["X-Capture-That"]) def test_secret_scrubbing(self): @@ -246,21 +246,21 @@ def test_secret_scrubbing(self): urllib3_span = spans[1] test_span = spans[2] - assert response + self.assertTrue(response) self.assertEqual(200, response.status) - assert 'X-INSTANA-T' in response.headers - assert(int(response.headers['X-INSTANA-T'], 16)) + self.assertIn('X-INSTANA-T', response.headers) + self.assertTrue(int(response.headers['X-INSTANA-T'], 16)) self.assertEqual(response.headers['X-INSTANA-T'], wsgi_span.t) - assert 'X-INSTANA-S' in response.headers - assert(int(response.headers['X-INSTANA-S'], 16)) + self.assertIn('X-INSTANA-S', response.headers) + self.assertTrue(int(response.headers['X-INSTANA-S'], 16)) self.assertEqual(response.headers['X-INSTANA-S'], wsgi_span.s) - assert 'X-INSTANA-L' in response.headers + self.assertIn('X-INSTANA-L', response.headers) self.assertEqual(response.headers['X-INSTANA-L'], '1') - assert 'Server-Timing' in response.headers + self.assertIn('Server-Timing', response.headers) server_timing_value = "intid;desc=%s" % wsgi_span.t self.assertEqual(response.headers['Server-Timing'], server_timing_value) @@ -294,7 +294,7 @@ def test_with_incoming_context(self): response = self.http.request('GET', testenv["wsgi_server"] + '/', headers=request_headers) - assert response + self.assertTrue(response) self.assertEqual(200, response.status) spans = self.recorder.queued_spans() @@ -305,18 +305,18 @@ def test_with_incoming_context(self): self.assertEqual(wsgi_span.t, '0000000000000001') self.assertEqual(wsgi_span.p, '0000000000000001') - assert 'X-INSTANA-T' in response.headers - assert(int(response.headers['X-INSTANA-T'], 16)) + self.assertIn('X-INSTANA-T', response.headers) + self.assertTrue(int(response.headers['X-INSTANA-T'], 16)) self.assertEqual(response.headers['X-INSTANA-T'], wsgi_span.t) - assert 'X-INSTANA-S' in response.headers - assert(int(response.headers['X-INSTANA-S'], 16)) + self.assertIn('X-INSTANA-S', response.headers) + self.assertTrue(int(response.headers['X-INSTANA-S'], 16)) self.assertEqual(response.headers['X-INSTANA-S'], wsgi_span.s) - assert 'X-INSTANA-L' in response.headers + self.assertIn('X-INSTANA-L', response.headers) self.assertEqual(response.headers['X-INSTANA-L'], '1') - assert 'Server-Timing' in response.headers + self.assertIn('Server-Timing', response.headers) server_timing_value = "intid;desc=%s" % wsgi_span.t self.assertEqual(response.headers['Server-Timing'], server_timing_value) @@ -327,7 +327,7 @@ def test_with_incoming_mixed_case_context(self): response = self.http.request('GET', testenv["wsgi_server"] + '/', headers=request_headers) - assert response + self.assertTrue(response) self.assertEqual(200, response.status) spans = self.recorder.queued_spans() @@ -338,18 +338,18 @@ def test_with_incoming_mixed_case_context(self): self.assertEqual(wsgi_span.t, '0000000000000001') self.assertEqual(wsgi_span.p, '0000000000000001') - assert 'X-INSTANA-T' in response.headers - assert(int(response.headers['X-INSTANA-T'], 16)) + self.assertIn('X-INSTANA-T', response.headers) + self.assertTrue(int(response.headers['X-INSTANA-T'], 16)) self.assertEqual(response.headers['X-INSTANA-T'], wsgi_span.t) - assert 'X-INSTANA-S' in response.headers - assert(int(response.headers['X-INSTANA-S'], 16)) + self.assertIn('X-INSTANA-S', response.headers) + self.assertTrue(int(response.headers['X-INSTANA-S'], 16)) self.assertEqual(response.headers['X-INSTANA-S'], wsgi_span.s) - assert 'X-INSTANA-L' in response.headers + self.assertIn('X-INSTANA-L', response.headers) self.assertEqual(response.headers['X-INSTANA-L'], '1') - assert 'Server-Timing' in response.headers + self.assertIn('Server-Timing', response.headers) server_timing_value = "intid;desc=%s" % wsgi_span.t self.assertEqual(response.headers['Server-Timing'], server_timing_value) @@ -366,20 +366,20 @@ def test_response_headers(self): urllib3_span = spans[1] test_span = spans[2] - assert response + self.assertTrue(response) self.assertEqual(200, response.status) - assert 'X-INSTANA-T' in response.headers - assert(int(response.headers['X-INSTANA-T'], 16)) + self.assertIn('X-INSTANA-T', response.headers) + self.assertTrue(int(response.headers['X-INSTANA-T'], 16)) self.assertEqual(response.headers['X-INSTANA-T'], wsgi_span.t) - assert 'X-INSTANA-S' in response.headers - assert(int(response.headers['X-INSTANA-S'], 16)) + self.assertIn('X-INSTANA-S', response.headers) + self.assertTrue(int(response.headers['X-INSTANA-S'], 16)) self.assertEqual(response.headers['X-INSTANA-S'], wsgi_span.s) - assert 'X-INSTANA-L' in response.headers + self.assertIn('X-INSTANA-L', response.headers) self.assertEqual(response.headers['X-INSTANA-L'], '1') - assert 'Server-Timing' in response.headers + self.assertIn('Server-Timing', response.headers) server_timing_value = "intid;desc=%s" % wsgi_span.t self.assertEqual(response.headers['Server-Timing'], server_timing_value) diff --git a/tests/platforms/test_lambda.py b/tests/platforms/test_lambda.py index c330b3a7e..a5a25c099 100644 --- a/tests/platforms/test_lambda.py +++ b/tests/platforms/test_lambda.py @@ -135,7 +135,7 @@ def test_has_options(self): self.create_agent_and_setup_tracer() self.assertTrue(hasattr(self.agent, 'options')) self.assertTrue(isinstance(self.agent.options, AWSLambdaOptions)) - assert(self.agent.options.endpoint_proxy == { }) + self.assertDictEqual(self.agent.options.endpoint_proxy, { }) def test_get_handler(self): os.environ["LAMBDA_HANDLER"] = "tests.lambda_handler" @@ -174,7 +174,7 @@ def test_agent_extra_http_headers(self): def test_custom_proxy(self): os.environ["INSTANA_ENDPOINT_PROXY"] = "http://myproxy.123" self.create_agent_and_setup_tracer() - assert(self.agent.options.endpoint_proxy == { 'https': "http://myproxy.123" }) + self.assertDictEqual(self.agent.options.endpoint_proxy, { 'https': "http://myproxy.123" }) def test_custom_service_name(self): os.environ['INSTANA_SERVICE_NAME'] = "Legion" @@ -189,9 +189,9 @@ def test_custom_service_name(self): result = lambda_handler(event, self.context) os.environ.pop('INSTANA_SERVICE_NAME') - assert isinstance(result, dict) - assert 'headers' in result - assert 'Server-Timing' in result['headers'] + self.assertIsInstance(result, dict) + self.assertIn('headers', result) + self.assertIn('Server-Timing', result['headers']) time.sleep(1) payload = self.agent.collector.prepare_payload() @@ -218,7 +218,7 @@ def test_custom_service_name(self): self.assertIsNotNone(span.d) server_timing_value = "intid;desc=%s" % span.t - assert result['headers']['Server-Timing'] == server_timing_value + self.assertEqual(result['headers']['Server-Timing'], server_timing_value) self.assertEqual({'hl': True, 'cp': 'aws', 'e': 'arn:aws:lambda:us-east-2:12345:function:TestPython:1'}, span.f) @@ -254,9 +254,9 @@ def test_api_gateway_trigger_tracing(self): # The original Lambda handler is set in os.environ["LAMBDA_HANDLER"] result = lambda_handler(event, self.context) - assert isinstance(result, dict) - assert 'headers' in result - assert 'Server-Timing' in result['headers'] + self.assertIsInstance(result, dict) + self.assertIn('headers', result) + self.assertIn('Server-Timing', result['headers']) time.sleep(1) payload = self.agent.collector.prepare_payload() @@ -283,7 +283,7 @@ def test_api_gateway_trigger_tracing(self): self.assertIsNotNone(span.d) server_timing_value = "intid;desc=%s" % span.t - assert result['headers']['Server-Timing'] == server_timing_value + self.assertEqual(result['headers']['Server-Timing'], server_timing_value) self.assertEqual({'hl': True, 'cp': 'aws', 'e': 'arn:aws:lambda:us-east-2:12345:function:TestPython:1'}, span.f) @@ -359,9 +359,9 @@ def test_application_lb_trigger_tracing(self): # The original Lambda handler is set in os.environ["LAMBDA_HANDLER"] result = lambda_handler(event, self.context) - assert isinstance(result, dict) - assert 'headers' in result - assert 'Server-Timing' in result['headers'] + self.assertIsInstance(result, dict) + self.assertIn('headers', result) + self.assertIn('Server-Timing', result['headers']) time.sleep(1) payload = self.agent.collector.prepare_payload() @@ -388,7 +388,7 @@ def test_application_lb_trigger_tracing(self): self.assertIsNotNone(span.d) server_timing_value = "intid;desc=%s" % span.t - assert result['headers']['Server-Timing'] == server_timing_value + self.assertEqual(result['headers']['Server-Timing'], server_timing_value) self.assertEqual({'hl': True, 'cp': 'aws', 'e': 'arn:aws:lambda:us-east-2:12345:function:TestPython:1'}, span.f) @@ -422,9 +422,9 @@ def test_cloudwatch_trigger_tracing(self): # The original Lambda handler is set in os.environ["LAMBDA_HANDLER"] result = lambda_handler(event, self.context) - assert isinstance(result, dict) - assert 'headers' in result - assert 'Server-Timing' in result['headers'] + self.assertIsInstance(result, dict) + self.assertIn('headers', result) + self.assertIn('Server-Timing', result['headers']) time.sleep(1) payload = self.agent.collector.prepare_payload() @@ -451,7 +451,7 @@ def test_cloudwatch_trigger_tracing(self): self.assertIsNotNone(span.d) server_timing_value = "intid;desc=%s" % span.t - assert result['headers']['Server-Timing'] == server_timing_value + self.assertEqual(result['headers']['Server-Timing'], server_timing_value) self.assertEqual({'hl': True, 'cp': 'aws', 'e': 'arn:aws:lambda:us-east-2:12345:function:TestPython:1'}, span.f) @@ -487,9 +487,9 @@ def test_cloudwatch_logs_trigger_tracing(self): # The original Lambda handler is set in os.environ["LAMBDA_HANDLER"] result = lambda_handler(event, self.context) - assert isinstance(result, dict) - assert 'headers' in result - assert 'Server-Timing' in result['headers'] + self.assertIsInstance(result, dict) + self.assertIn('headers', result) + self.assertIn('Server-Timing', result['headers']) time.sleep(1) payload = self.agent.collector.prepare_payload() @@ -516,7 +516,7 @@ def test_cloudwatch_logs_trigger_tracing(self): self.assertIsNotNone(span.d) server_timing_value = "intid;desc=%s" % span.t - assert result['headers']['Server-Timing'] == server_timing_value + self.assertEqual(result['headers']['Server-Timing'], server_timing_value) self.assertEqual({'hl': True, 'cp': 'aws', 'e': 'arn:aws:lambda:us-east-2:12345:function:TestPython:1'}, span.f) @@ -554,9 +554,9 @@ def test_s3_trigger_tracing(self): # The original Lambda handler is set in os.environ["LAMBDA_HANDLER"] result = lambda_handler(event, self.context) - assert isinstance(result, dict) - assert 'headers' in result - assert 'Server-Timing' in result['headers'] + self.assertIsInstance(result, dict) + self.assertIn('headers', result) + self.assertIn('Server-Timing', result['headers']) time.sleep(1) payload = self.agent.collector.prepare_payload() @@ -583,7 +583,7 @@ def test_s3_trigger_tracing(self): self.assertIsNotNone(span.d) server_timing_value = "intid;desc=%s" % span.t - assert result['headers']['Server-Timing'] == server_timing_value + self.assertEqual(result['headers']['Server-Timing'], server_timing_value) self.assertEqual({'hl': True, 'cp': 'aws', 'e': 'arn:aws:lambda:us-east-2:12345:function:TestPython:1'}, span.f) @@ -620,9 +620,9 @@ def test_sqs_trigger_tracing(self): # The original Lambda handler is set in os.environ["LAMBDA_HANDLER"] result = lambda_handler(event, self.context) - assert isinstance(result, dict) - assert 'headers' in result - assert 'Server-Timing' in result['headers'] + self.assertIsInstance(result, dict) + self.assertIn('headers', result) + self.assertIn('Server-Timing', result['headers']) time.sleep(1) payload = self.agent.collector.prepare_payload() @@ -649,7 +649,7 @@ def test_sqs_trigger_tracing(self): self.assertIsNotNone(span.d) server_timing_value = "intid;desc=%s" % span.t - assert result['headers']['Server-Timing'] == server_timing_value + self.assertEqual(result['headers']['Server-Timing'], server_timing_value) self.assertEqual({'hl': True, 'cp': 'aws', 'e': 'arn:aws:lambda:us-east-2:12345:function:TestPython:1'}, span.f) @@ -693,24 +693,24 @@ def test_read_query_params_with_bad_event(self): def test_arn_parsing(self): ctx = MockContext() - assert(normalize_aws_lambda_arn(ctx) == "arn:aws:lambda:us-east-2:12345:function:TestPython:1") + self.assertEqual(normalize_aws_lambda_arn(ctx), "arn:aws:lambda:us-east-2:12345:function:TestPython:1") # Without version should return a fully qualified ARN (with version) ctx.invoked_function_arn = "arn:aws:lambda:us-east-2:12345:function:TestPython" - assert(normalize_aws_lambda_arn(ctx) == "arn:aws:lambda:us-east-2:12345:function:TestPython:1") + self.assertEqual(normalize_aws_lambda_arn(ctx), "arn:aws:lambda:us-east-2:12345:function:TestPython:1") # Fully qualified already with the '$LATEST' special tag ctx.invoked_function_arn = "arn:aws:lambda:us-east-2:12345:function:TestPython:$LATEST" - assert(normalize_aws_lambda_arn(ctx) == "arn:aws:lambda:us-east-2:12345:function:TestPython:$LATEST") + self.assertEqual(normalize_aws_lambda_arn(ctx), "arn:aws:lambda:us-east-2:12345:function:TestPython:$LATEST") def test_agent_default_log_level(self): self.create_agent_and_setup_tracer() - assert self.agent.options.log_level == logging.WARNING + self.assertEqual(self.agent.options.log_level, logging.WARNING) def test_agent_custom_log_level(self): os.environ['INSTANA_LOG_LEVEL'] = "eRror" self.create_agent_and_setup_tracer() - assert self.agent.options.log_level == logging.ERROR + self.assertEqual(self.agent.options.log_level, logging.ERROR) def __validate_result_and_payload_for_gateway_v2_trace(self, result, payload): self.assertIsInstance(result, dict) @@ -740,7 +740,7 @@ def __validate_result_and_payload_for_gateway_v2_trace(self, result, payload): self.assertIsNotNone(span.d) server_timing_value = "intid;desc=%s" % span.t - assert result['headers']['Server-Timing'] == server_timing_value + self.assertEqual(result['headers']['Server-Timing'], server_timing_value) self.assertEqual({'hl': True, 'cp': 'aws', 'e': 'arn:aws:lambda:us-east-2:12345:function:TestPython:1'}, span.f)