From 0fe3ae4107555dea1717b2ad7e1561caa2df73f8 Mon Sep 17 00:00:00 2001 From: Cagri Yonca Date: Tue, 3 Sep 2024 12:40:53 +0300 Subject: [PATCH 1/2] refactor(pymysql): added instrumentation of pymysql Signed-off-by: Cagri Yonca --- src/instana/__init__.py | 2 +- src/instana/instrumentation/pymysql.py | 14 +++++++------- src/instana/span/registered_span.py | 7 ++++--- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/instana/__init__.py b/src/instana/__init__.py index 0f6988d1..1654f01f 100644 --- a/src/instana/__init__.py +++ b/src/instana/__init__.py @@ -177,7 +177,7 @@ def boot_agent(): pep0249, # noqa: F401 psycopg2, # noqa: F401 # pymongo, # noqa: F401 - # pymysql, # noqa: F401 + pymysql, # noqa: F401 # redis, # noqa: F401 # sqlalchemy, # noqa: F401 starlette_inst, # noqa: F401 diff --git a/src/instana/instrumentation/pymysql.py b/src/instana/instrumentation/pymysql.py index c4939cc4..50cf9b3d 100644 --- a/src/instana/instrumentation/pymysql.py +++ b/src/instana/instrumentation/pymysql.py @@ -2,17 +2,17 @@ # (c) Copyright Instana Inc. 2019 -from ..log import logger -from .pep0249 import ConnectionFactory +from instana.log import logger +from instana.instrumentation.pep0249 import ConnectionFactory try: - import pymysql # + import pymysql - cf = ConnectionFactory(connect_func=pymysql.connect, module_name='mysql') + cf = ConnectionFactory(connect_func=pymysql.connect, module_name="mysql") - setattr(pymysql, 'connect', cf) - if hasattr(pymysql, 'Connect'): - setattr(pymysql, 'Connect', cf) + setattr(pymysql, "connect", cf) + if hasattr(pymysql, "Connect"): + setattr(pymysql, "Connect", cf) logger.debug("Instrumenting pymysql") except ImportError: diff --git a/src/instana/span/registered_span.py b/src/instana/span/registered_span.py index 728d66a8..afb38a97 100644 --- a/src/instana/span/registered_span.py +++ b/src/instana/span/registered_span.py @@ -5,6 +5,7 @@ from instana.span.kind import ENTRY_SPANS, EXIT_SPANS, HTTP_SPANS, LOCAL_SPANS from opentelemetry.trace import SpanKind +from opentelemetry.semconv.trace import SpanAttributes class RegisteredSpan(BaseSpan): @@ -237,9 +238,9 @@ def _populate_exit_span_data(self, span) -> None: elif span.name == "mysql": self.data["mysql"]["host"] = span.attributes.pop("host", None) self.data["mysql"]["port"] = span.attributes.pop("port", None) - self.data["mysql"]["db"] = span.attributes.pop("db.name", None) - self.data["mysql"]["user"] = span.attributes.pop("db.user", None) - self.data["mysql"]["stmt"] = span.attributes.pop("db.statement", None) + self.data["mysql"]["db"] = span.attributes.pop(SpanAttributes.DB_NAME, None) + self.data["mysql"]["user"] = span.attributes.pop(SpanAttributes.DB_USER, None) + self.data["mysql"]["stmt"] = span.attributes.pop(SpanAttributes.DB_STATEMENT, None) self.data["mysql"]["error"] = span.attributes.pop("mysql.error", None) elif span.name == "postgres": From 609b3fbc38ca3e15c2f65343be11049f1378ebd3 Mon Sep 17 00:00:00 2001 From: Cagri Yonca Date: Tue, 3 Sep 2024 12:41:18 +0300 Subject: [PATCH 2/2] unittests(pymysql): added refactor of unittests Signed-off-by: Cagri Yonca --- tests/clients/test_pymysql.py | 380 +++++++++++++++++----------------- tests/conftest.py | 2 +- 2 files changed, 196 insertions(+), 186 deletions(-) diff --git a/tests/clients/test_pymysql.py b/tests/clients/test_pymysql.py index 4479b698..8e4793d5 100644 --- a/tests/clients/test_pymysql.py +++ b/tests/clients/test_pymysql.py @@ -1,26 +1,25 @@ # (c) Copyright IBM Corp. 2021 # (c) Copyright Instana Inc. 2020 -import logging -import unittest +import time +import pytest import pymysql -from ..helpers import testenv +from typing import Generator +from tests.helpers import testenv from instana.singletons import agent, tracer -logger = logging.getLogger(__name__) - -class TestPyMySQL(unittest.TestCase): - def setUp(self): - deprecated_param_name = self.shortDescription() == 'test_deprecated_parameter_db' +class TestPyMySQL: + @pytest.fixture(autouse=True) + def _resource(self) -> Generator[None, None, None]: kwargs = { - 'host': testenv['mysql_host'], - 'port': testenv['mysql_port'], - 'user': testenv['mysql_user'], - 'passwd': testenv['mysql_pw'], - 'database' if not deprecated_param_name else 'db': testenv['mysql_db'], + "host": testenv["mysql_host"], + "port": testenv["mysql_port"], + "user": testenv["mysql_user"], + "passwd": testenv["mysql_pw"], + "database": testenv["mysql_db"], } self.db = pymysql.connect(**kwargs) @@ -39,303 +38,314 @@ def setUp(self): END """ setup_cursor = self.db.cursor() - for s in database_setup_query.split('|'): - setup_cursor.execute(s) + for s in database_setup_query.split("|"): + setup_cursor.execute(s) self.cursor = self.db.cursor() - self.recorder = tracer.recorder + self.recorder = tracer.span_processor self.recorder.clear_spans() tracer.cur_ctx = None - - def tearDown(self): + yield if self.cursor and self.cursor.connection.open: - self.cursor.close() + self.cursor.close() if self.db and self.db.open: - self.db.close() + self.db.close() agent.options.allow_exit_as_root = False - def test_vanilla_query(self): + def test_vanilla_query(self) -> None: affected_rows = self.cursor.execute("""SELECT * from users""") - self.assertEqual(1, affected_rows) + assert affected_rows == 1 result = self.cursor.fetchone() - self.assertEqual(3, len(result)) + assert len(result) == 3 spans = self.recorder.queued_spans() - self.assertEqual(0, len(spans)) + assert len(spans) == 0 - def test_basic_query(self): - with tracer.start_active_span('test'): + def test_basic_query(self) -> None: + with tracer.start_as_current_span("test"): affected_rows = self.cursor.execute("""SELECT * from users""") result = self.cursor.fetchone() - self.assertEqual(1, affected_rows) - self.assertEqual(3, len(result)) + assert affected_rows == 1 + assert len(result) == 3 spans = self.recorder.queued_spans() - self.assertEqual(2, len(spans)) + assert len(spans) == 2 db_span, test_span = spans - self.assertEqual("test", test_span.data["sdk"]["name"]) - self.assertEqual(test_span.t, db_span.t) - self.assertEqual(db_span.p, test_span.s) + assert test_span.data["sdk"]["name"] == "test" + assert test_span.t == db_span.t + assert db_span.p == test_span.s - self.assertIsNone(db_span.ec) + assert not db_span.ec - self.assertEqual(db_span.n, "mysql") - self.assertEqual(db_span.data["mysql"]["db"], testenv['mysql_db']) - self.assertEqual(db_span.data["mysql"]["user"], testenv['mysql_user']) - self.assertEqual(db_span.data["mysql"]["stmt"], 'SELECT * from users') - self.assertEqual(db_span.data["mysql"]["host"], testenv['mysql_host']) - self.assertEqual(db_span.data["mysql"]["port"], testenv['mysql_port']) + assert db_span.n == "mysql" + assert db_span.data["mysql"]["db"] == testenv["mysql_db"] + assert db_span.data["mysql"]["user"] == testenv["mysql_user"] + assert db_span.data["mysql"]["stmt"] == "SELECT * from users" + assert db_span.data["mysql"]["host"] == testenv["mysql_host"] + assert db_span.data["mysql"]["port"] == testenv["mysql_port"] - def test_basic_query_as_root_exit_span(self): + def test_basic_query_as_root_exit_span(self) -> None: agent.options.allow_exit_as_root = True affected_rows = self.cursor.execute("""SELECT * from users""") result = self.cursor.fetchone() - self.assertEqual(1, affected_rows) - self.assertEqual(3, len(result)) + assert affected_rows == 1 + assert len(result) == 3 spans = self.recorder.queued_spans() - self.assertEqual(1, len(spans)) + assert len(spans) == 1 db_span = spans[0] - self.assertIsNone(db_span.ec) + assert not db_span.ec - self.assertEqual(db_span.n, "mysql") - self.assertEqual(db_span.data["mysql"]["db"], testenv['mysql_db']) - self.assertEqual(db_span.data["mysql"]["user"], testenv['mysql_user']) - self.assertEqual(db_span.data["mysql"]["stmt"], 'SELECT * from users') - self.assertEqual(db_span.data["mysql"]["host"], testenv['mysql_host']) - self.assertEqual(db_span.data["mysql"]["port"], testenv['mysql_port']) + assert db_span.n == "mysql" + assert db_span.data["mysql"]["db"] == testenv["mysql_db"] + assert db_span.data["mysql"]["user"] == testenv["mysql_user"] + assert db_span.data["mysql"]["stmt"] == "SELECT * from users" + assert db_span.data["mysql"]["host"] == testenv["mysql_host"] + assert db_span.data["mysql"]["port"] == testenv["mysql_port"] - def test_query_with_params(self): - with tracer.start_active_span('test'): + def test_query_with_params(self) -> None: + with tracer.start_as_current_span("test"): affected_rows = self.cursor.execute("""SELECT * from users where id=1""") result = self.cursor.fetchone() - self.assertEqual(1, affected_rows) - self.assertEqual(3, len(result)) + assert affected_rows == 1 + assert len(result) == 3 spans = self.recorder.queued_spans() - self.assertEqual(2, len(spans)) + assert len(spans) == 2 db_span, test_span = spans - self.assertEqual("test", test_span.data["sdk"]["name"]) - self.assertEqual(test_span.t, db_span.t) - self.assertEqual(db_span.p, test_span.s) + assert test_span.data["sdk"]["name"] == "test" + assert test_span.t == db_span.t + assert db_span.p == test_span.s - self.assertIsNone(db_span.ec) + assert not db_span.ec - self.assertEqual(db_span.n, "mysql") - self.assertEqual(db_span.data["mysql"]["db"], testenv['mysql_db']) - self.assertEqual(db_span.data["mysql"]["user"], testenv['mysql_user']) - self.assertEqual(db_span.data["mysql"]["stmt"], 'SELECT * from users where id=?') - self.assertEqual(db_span.data["mysql"]["host"], testenv['mysql_host']) - self.assertEqual(db_span.data["mysql"]["port"], testenv['mysql_port']) + assert db_span.n == "mysql" + assert db_span.data["mysql"]["db"] == testenv["mysql_db"] + assert db_span.data["mysql"]["user"] == testenv["mysql_user"] + assert db_span.data["mysql"]["stmt"] == "SELECT * from users where id=?" + assert db_span.data["mysql"]["host"] == testenv["mysql_host"] + assert db_span.data["mysql"]["port"] == testenv["mysql_port"] - def test_basic_insert(self): - with tracer.start_active_span('test'): + def test_basic_insert(self) -> None: + with tracer.start_as_current_span("test"): affected_rows = self.cursor.execute( - """INSERT INTO users(name, email) VALUES(%s, %s)""", - ('beaker', 'beaker@muppets.com')) + """INSERT INTO users(name, email) VALUES(%s, %s)""", + ("beaker", "beaker@muppets.com"), + ) - self.assertEqual(1, affected_rows) + assert affected_rows == 1 spans = self.recorder.queued_spans() - self.assertEqual(2, len(spans)) + assert len(spans) == 2 db_span, test_span = spans - self.assertEqual("test", test_span.data["sdk"]["name"]) - self.assertEqual(test_span.t, db_span.t) - self.assertEqual(db_span.p, test_span.s) - - self.assertIsNone(db_span.ec) - - self.assertEqual(db_span.n, "mysql") - self.assertEqual(db_span.data["mysql"]["db"], testenv['mysql_db']) - self.assertEqual(db_span.data["mysql"]["user"], testenv['mysql_user']) - self.assertEqual(db_span.data["mysql"]["stmt"], 'INSERT INTO users(name, email) VALUES(%s, %s)') - self.assertEqual(db_span.data["mysql"]["host"], testenv['mysql_host']) - self.assertEqual(db_span.data["mysql"]["port"], testenv['mysql_port']) - - def test_executemany(self): - with tracer.start_active_span('test'): - affected_rows = self.cursor.executemany("INSERT INTO users(name, email) VALUES(%s, %s)", - [('beaker', 'beaker@muppets.com'), ('beaker', 'beaker@muppets.com')]) + assert test_span.data["sdk"]["name"] == "test" + assert test_span.t == db_span.t + assert db_span.p == test_span.s + + assert not db_span.ec + + assert db_span.n == "mysql" + assert db_span.data["mysql"]["db"] == testenv["mysql_db"] + assert db_span.data["mysql"]["user"] == testenv["mysql_user"] + assert ( + db_span.data["mysql"]["stmt"] + == "INSERT INTO users(name, email) VALUES(%s, %s)" + ) + + assert db_span.data["mysql"]["host"] == testenv["mysql_host"] + assert db_span.data["mysql"]["port"] == testenv["mysql_port"] + + def test_executemany(self) -> None: + with tracer.start_as_current_span("test"): + affected_rows = self.cursor.executemany( + "INSERT INTO users(name, email) VALUES(%s, %s)", + [("beaker", "beaker@muppets.com"), ("beaker", "beaker@muppets.com")], + ) self.db.commit() - self.assertEqual(2, affected_rows) + assert affected_rows == 2 spans = self.recorder.queued_spans() - self.assertEqual(2, len(spans)) + assert len(spans) == 2 db_span, test_span = spans - self.assertEqual("test", test_span.data["sdk"]["name"]) - self.assertEqual(test_span.t, db_span.t) - self.assertEqual(db_span.p, test_span.s) + assert test_span.data["sdk"]["name"] == "test" + assert test_span.t == db_span.t + assert db_span.p == test_span.s - self.assertIsNone(db_span.ec) + assert not db_span.ec - self.assertEqual(db_span.n, "mysql") - self.assertEqual(db_span.data["mysql"]["db"], testenv['mysql_db']) - self.assertEqual(db_span.data["mysql"]["user"], testenv['mysql_user']) - self.assertEqual(db_span.data["mysql"]["stmt"], 'INSERT INTO users(name, email) VALUES(%s, %s)') - self.assertEqual(db_span.data["mysql"]["host"], testenv['mysql_host']) - self.assertEqual(db_span.data["mysql"]["port"], testenv['mysql_port']) + assert db_span.n == "mysql" + assert db_span.data["mysql"]["db"] == testenv["mysql_db"] + assert db_span.data["mysql"]["user"] == testenv["mysql_user"] + assert ( + db_span.data["mysql"]["stmt"] + == "INSERT INTO users(name, email) VALUES(%s, %s)" + ) + assert db_span.data["mysql"]["host"] == testenv["mysql_host"] + assert db_span.data["mysql"]["port"] == testenv["mysql_port"] - def test_call_proc(self): - with tracer.start_active_span('test'): - callproc_result = self.cursor.callproc('test_proc', ('beaker',)) + def test_call_proc(self) -> None: + with tracer.start_as_current_span("test"): + callproc_result = self.cursor.callproc("test_proc", ("beaker",)) - self.assertIsInstance(callproc_result, tuple) + assert isinstance(callproc_result, tuple) spans = self.recorder.queued_spans() - self.assertEqual(2, len(spans)) + assert len(spans) == 2 db_span, test_span = spans - self.assertEqual("test", test_span.data["sdk"]["name"]) - self.assertEqual(test_span.t, db_span.t) - self.assertEqual(db_span.p, test_span.s) + assert test_span.data["sdk"]["name"] == "test" + assert test_span.t == db_span.t + assert db_span.p == test_span.s - self.assertIsNone(db_span.ec) + assert not db_span.ec - self.assertEqual(db_span.n, "mysql") - self.assertEqual(db_span.data["mysql"]["db"], testenv['mysql_db']) - self.assertEqual(db_span.data["mysql"]["user"], testenv['mysql_user']) - self.assertEqual(db_span.data["mysql"]["stmt"], 'test_proc') - self.assertEqual(db_span.data["mysql"]["host"], testenv['mysql_host']) - self.assertEqual(db_span.data["mysql"]["port"], testenv['mysql_port']) + assert db_span.n == "mysql" + assert db_span.data["mysql"]["db"] == testenv["mysql_db"] + assert db_span.data["mysql"]["user"] == testenv["mysql_user"] + assert db_span.data["mysql"]["stmt"] == "test_proc" + assert db_span.data["mysql"]["host"] == testenv["mysql_host"] + assert db_span.data["mysql"]["port"] == testenv["mysql_port"] - def test_error_capture(self): + def test_error_capture(self) -> None: affected_rows = None try: - with tracer.start_active_span('test'): + with tracer.start_as_current_span("test"): affected_rows = self.cursor.execute("""SELECT * from blah""") except Exception: pass - self.assertIsNone(affected_rows) + assert not affected_rows spans = self.recorder.queued_spans() - self.assertEqual(2, len(spans)) + assert len(spans) == 2 db_span, test_span = spans - self.assertEqual("test", test_span.data["sdk"]["name"]) - self.assertEqual(test_span.t, db_span.t) - self.assertEqual(db_span.p, test_span.s) - self.assertEqual(1, db_span.ec) - - self.assertEqual(db_span.data["mysql"]["error"], u'(1146, "Table \'%s.blah\' doesn\'t exist")' % testenv['mysql_db']) - - self.assertEqual(db_span.n, "mysql") - self.assertEqual(db_span.data["mysql"]["db"], testenv['mysql_db']) - self.assertEqual(db_span.data["mysql"]["user"], testenv['mysql_user']) - self.assertEqual(db_span.data["mysql"]["stmt"], 'SELECT * from blah') - self.assertEqual(db_span.data["mysql"]["host"], testenv['mysql_host']) - self.assertEqual(db_span.data["mysql"]["port"], testenv['mysql_port']) - - def test_connect_cursor_ctx_mgr(self): - with tracer.start_active_span("test"): + assert test_span.data["sdk"]["name"] == "test" + assert test_span.t == db_span.t + assert db_span.p == test_span.s + assert db_span.ec == 2 + + assert ( + db_span.data["mysql"]["error"] + == f"(1146, \"Table '{testenv['mysql_db']}.blah' doesn't exist\")" + ) + + assert db_span.n == "mysql" + assert db_span.data["mysql"]["db"] == testenv["mysql_db"] + assert db_span.data["mysql"]["user"] == testenv["mysql_user"] + assert db_span.data["mysql"]["stmt"] == "SELECT * from blah" + assert db_span.data["mysql"]["host"] == testenv["mysql_host"] + assert db_span.data["mysql"]["port"] == testenv["mysql_port"] + + def test_connect_cursor_ctx_mgr(self) -> None: + with tracer.start_as_current_span("test"): with self.db as connection: with connection.cursor() as cursor: affected_rows = cursor.execute("""SELECT * from users""") - self.assertEqual(1, affected_rows) + assert affected_rows == 1 spans = self.recorder.queued_spans() - self.assertEqual(2, len(spans)) + assert len(spans) == 2 db_span, test_span = spans - self.assertEqual("test", test_span.data["sdk"]["name"]) - self.assertEqual(test_span.t, db_span.t) - self.assertEqual(db_span.p, test_span.s) + assert test_span.data["sdk"]["name"] == "test" + assert test_span.t == db_span.t + assert db_span.p == test_span.s - self.assertIsNone(db_span.ec) + assert not db_span.ec - self.assertEqual(db_span.n, "mysql") - self.assertEqual(db_span.data["mysql"]["db"], testenv["mysql_db"]) - self.assertEqual(db_span.data["mysql"]["user"], testenv["mysql_user"]) - self.assertEqual(db_span.data["mysql"]["stmt"], "SELECT * from users") - self.assertEqual(db_span.data["mysql"]["host"], testenv["mysql_host"]) - self.assertEqual(db_span.data["mysql"]["port"], testenv["mysql_port"]) + assert db_span.n == "mysql" + assert db_span.data["mysql"]["db"] == testenv["mysql_db"] + assert db_span.data["mysql"]["user"] == testenv["mysql_user"] + assert db_span.data["mysql"]["stmt"] == "SELECT * from users" + assert db_span.data["mysql"]["host"] == testenv["mysql_host"] + assert db_span.data["mysql"]["port"] == testenv["mysql_port"] - def test_connect_ctx_mgr(self): - with tracer.start_active_span("test"): + def test_connect_ctx_mgr(self) -> None: + with tracer.start_as_current_span("test"): with self.db as connection: cursor = connection.cursor() cursor.execute("""SELECT * from users""") spans = self.recorder.queued_spans() - self.assertEqual(2, len(spans)) + assert len(spans) == 2 db_span, test_span = spans - self.assertEqual("test", test_span.data["sdk"]["name"]) - self.assertEqual(test_span.t, db_span.t) - self.assertEqual(db_span.p, test_span.s) + assert test_span.data["sdk"]["name"] == "test" + assert test_span.t == db_span.t + assert db_span.p == test_span.s - self.assertIsNone(db_span.ec) + assert not db_span.ec - self.assertEqual(db_span.n, "mysql") - self.assertEqual(db_span.data["mysql"]["db"], testenv["mysql_db"]) - self.assertEqual(db_span.data["mysql"]["user"], testenv["mysql_user"]) - self.assertEqual(db_span.data["mysql"]["stmt"], "SELECT * from users") - self.assertEqual(db_span.data["mysql"]["host"], testenv["mysql_host"]) - self.assertEqual(db_span.data["mysql"]["port"], testenv["mysql_port"]) + assert db_span.n == "mysql" + assert db_span.data["mysql"]["db"] == testenv["mysql_db"] + assert db_span.data["mysql"]["user"] == testenv["mysql_user"] + assert db_span.data["mysql"]["stmt"] == "SELECT * from users" + assert db_span.data["mysql"]["host"] == testenv["mysql_host"] + assert db_span.data["mysql"]["port"] == testenv["mysql_port"] - def test_cursor_ctx_mgr(self): - with tracer.start_active_span("test"): + def test_cursor_ctx_mgr(self) -> None: + with tracer.start_as_current_span("test"): connection = self.db with connection.cursor() as cursor: cursor.execute("""SELECT * from users""") - spans = self.recorder.queued_spans() - self.assertEqual(2, len(spans)) + assert len(spans) == 2 db_span, test_span = spans - self.assertEqual("test", test_span.data["sdk"]["name"]) - self.assertEqual(test_span.t, db_span.t) - self.assertEqual(db_span.p, test_span.s) + assert test_span.data["sdk"]["name"] == "test" + assert test_span.t == db_span.t + assert db_span.p == test_span.s - self.assertIsNone(db_span.ec) + assert not db_span.ec - self.assertEqual(db_span.n, "mysql") - self.assertEqual(db_span.data["mysql"]["db"], testenv["mysql_db"]) - self.assertEqual(db_span.data["mysql"]["user"], testenv["mysql_user"]) - self.assertEqual(db_span.data["mysql"]["stmt"], "SELECT * from users") - self.assertEqual(db_span.data["mysql"]["host"], testenv["mysql_host"]) - self.assertEqual(db_span.data["mysql"]["port"], testenv["mysql_port"]) + assert db_span.n == "mysql" + assert db_span.data["mysql"]["db"] == testenv["mysql_db"] + assert db_span.data["mysql"]["user"] == testenv["mysql_user"] + assert db_span.data["mysql"]["stmt"] == "SELECT * from users" + assert db_span.data["mysql"]["host"] == testenv["mysql_host"] + assert db_span.data["mysql"]["port"] == testenv["mysql_port"] - def test_deprecated_parameter_db(self): + def test_deprecated_parameter_db(self) -> None: """test_deprecated_parameter_db""" - with tracer.start_active_span('test'): + with tracer.start_as_current_span("test"): affected_rows = self.cursor.execute("""SELECT * from users""") result = self.cursor.fetchone() - self.assertEqual(1, affected_rows) - self.assertEqual(3, len(result)) + assert affected_rows == 1 + assert len(result) == 3 spans = self.recorder.queued_spans() - self.assertEqual(2, len(spans)) + assert len(spans) == 2 db_span, test_span = spans - self.assertEqual("test", test_span.data["sdk"]["name"]) - self.assertEqual(test_span.t, db_span.t) - self.assertEqual(db_span.p, test_span.s) + assert test_span.data["sdk"]["name"] == "test" + assert test_span.t == db_span.t + assert db_span.p == test_span.s - self.assertIsNone(db_span.ec) + assert not db_span.ec - self.assertEqual(db_span.n, "mysql") - self.assertEqual(db_span.data["mysql"]["db"], testenv['mysql_db']) + assert db_span.n == "mysql" + assert db_span.data["mysql"]["db"] == testenv["mysql_db"] diff --git a/tests/conftest.py b/tests/conftest.py index 31bd4950..1e180620 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -42,7 +42,7 @@ collect_ignore_glob.append("*clients/test_google*") collect_ignore_glob.append("*clients/test_mysql*") collect_ignore_glob.append("*clients/test_pika*") -collect_ignore_glob.append("*clients/test_pym*") +collect_ignore_glob.append("*clients/test_pymongo*") collect_ignore_glob.append("*clients/test_redis*") collect_ignore_glob.append("*clients/test_sql*")