From 6245d48b69b2ad96f729c41f6901984a93eb2fb2 Mon Sep 17 00:00:00 2001 From: Dimitra Paraskevopoulou Date: Wed, 8 Dec 2021 11:24:33 +0100 Subject: [PATCH] Fix django urls import (#343) * fixing deprecated import * fix for django in python 2.7 * skip pymongo map_reduce test when testing on latest pymongo versions since the map_reduce functionality has been removed --- tests/apps/app_django.py | 15 +++++++++------ tests/clients/test_pymongo.py | 6 ++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/tests/apps/app_django.py b/tests/apps/app_django.py index 64274ddc4..3c0afd0f4 100755 --- a/tests/apps/app_django.py +++ b/tests/apps/app_django.py @@ -9,8 +9,11 @@ import time import opentracing import opentracing.ext.tags as ext +try: + from django.urls import re_path +except ImportError: + from django.conf.urls import url as re_path -from django.conf.urls import url from django.http import HttpResponse, Http404 filepath, extension = os.path.splitext(__file__) @@ -123,9 +126,9 @@ def complex(request): urlpatterns = [ - url(r'^$', index, name='index'), - url(r'^cause_error$', cause_error, name='cause_error'), - url(r'^another$', another), - url(r'^not_found$', not_found, name='not_found'), - url(r'^complex$', complex, name='complex') + re_path(r'^$', index, name='index'), + re_path(r'^cause_error$', cause_error, name='cause_error'), + re_path(r'^another$', another), + re_path(r'^not_found$', not_found, name='not_found'), + re_path(r'^complex$', complex, name='complex') ] diff --git a/tests/clients/test_pymongo.py b/tests/clients/test_pymongo.py index f205c320c..ca0a7bccf 100644 --- a/tests/clients/test_pymongo.py +++ b/tests/clients/test_pymongo.py @@ -6,6 +6,7 @@ import json import unittest import logging +import pytest from nose.tools import (assert_is_none, assert_is_not_none, assert_false, assert_true, assert_list_equal) @@ -18,6 +19,10 @@ logger = logging.getLogger(__name__) +pymongoversion = pytest.mark.skipif( + pymongo.version_tuple >= (4, 0), reason="map reduce is removed in pymongo 4.0" +) + class TestPyMongoTracer(unittest.TestCase): def setUp(self): @@ -169,6 +174,7 @@ def test_successful_aggregate_query(self): payload = json.loads(db_span.data["mongo"]["json"]) assert_true({"$match": {"type": "string"}} in payload, db_span.data["mongo"]["json"]) + @pymongoversion def test_successful_map_reduce_query(self): mapper = "function () { this.tags.forEach(function(z) { emit(z, 1); }); }" reducer = "function (key, values) { return len(values); }"