Skip to content

Commit 694612b

Browse files
committed
Merge remote-tracking branch 'origin/main' into develop-11.0.0
2 parents 7271b2e + 4de44ee commit 694612b

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

newrelic/api/web_transaction.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,27 @@ def _parse_time_stamp(time_stamp):
7171
TRUE_VALUES = {"on", "true", "1"}
7272
FALSE_VALUES = {"off", "false", "0"}
7373

74+
DEPRECATED_ENVIRON_SETTINGS = (
75+
"newrelic.set_background_task",
76+
"newrelic.suppress_apdex_metric",
77+
"newrelic.suppress_transaction_trace",
78+
"newrelic.capture_request_params",
79+
"newrelic.disable_browser_autorum",
80+
)
81+
7482

7583
def _lookup_environ_setting(environ, name, default=False):
7684
if name not in environ:
7785
return default
7886

87+
# Check for deprecated WSGI environ dictionary setting
88+
if name in DEPRECATED_ENVIRON_SETTINGS:
89+
warnings.warn(
90+
f"Environ setting '{name}' is deprecated and will be removed in a future release.",
91+
DeprecationWarning,
92+
stacklevel=2,
93+
)
94+
7995
flag = environ[name]
8096

8197
if isinstance(flag, str):

tests/external_httplib/test_urllib.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import os
15+
import sys
1616

1717
import pytest
1818

1919
try:
2020
import urllib.request as urllib
21-
except:
21+
except ImportError:
2222
import urllib
2323

2424
from testing_support.external_fixtures import cache_outgoing_headers, insert_incoming_headers
@@ -29,6 +29,14 @@
2929

3030
from newrelic.api.background_task import background_task
3131

32+
# Since Python 3.3, `urllib.URLopener()` has been deprecated in favor of
33+
# `urllib.request.urlopen`. In Python 3.14, `urllib.URLopener()` will be
34+
# removed. `urllib.request.urlopen` corresponds to the old `urllib2.urlopen`
35+
36+
SKIP_IF_PYTHON_3_14_OR_ABOVE = pytest.mark.skipif(
37+
sys.version_info[0:2] >= (3, 14), reason="urllib.URLopener() is removed in Python 3.14 and above"
38+
)
39+
3240

3341
@pytest.fixture(scope="session")
3442
def metrics(server):
@@ -44,6 +52,7 @@ def metrics(server):
4452
return scoped, rollup
4553

4654

55+
@SKIP_IF_PYTHON_3_14_OR_ABOVE
4756
def test_urlopener_http_request(server, metrics):
4857
@validate_transaction_metrics(
4958
"test_urllib:test_urlopener_http_request",
@@ -59,6 +68,7 @@ def _test():
5968
_test()
6069

6170

71+
@SKIP_IF_PYTHON_3_14_OR_ABOVE
6272
def test_urlopener_https_request(server, metrics):
6373
@validate_transaction_metrics(
6474
"test_urllib:test_urlopener_https_request",
@@ -77,6 +87,7 @@ def _test():
7787
_test()
7888

7989

90+
@SKIP_IF_PYTHON_3_14_OR_ABOVE
8091
def test_urlopener_http_request_with_port(server):
8192
scoped = [(f"External/localhost:{server.port}/urllib/", 1)]
8293

@@ -110,6 +121,7 @@ def _test():
110121
]
111122

112123

124+
@SKIP_IF_PYTHON_3_14_OR_ABOVE
113125
@validate_transaction_metrics(
114126
"test_urllib:test_urlopener_file_request",
115127
scoped_metrics=_test_urlopener_file_request_scoped_metrics,
@@ -123,6 +135,7 @@ def test_urlopener_file_request():
123135
opener.open(file_uri)
124136

125137

138+
@SKIP_IF_PYTHON_3_14_OR_ABOVE
126139
@background_task()
127140
@cache_outgoing_headers
128141
@validate_cross_process_headers
@@ -131,6 +144,7 @@ def test_urlopener_cross_process_request(server):
131144
opener.open(f"http://localhost:{server.port}/")
132145

133146

147+
@SKIP_IF_PYTHON_3_14_OR_ABOVE
134148
@cat_enabled
135149
def test_urlopener_cross_process_response(server):
136150
_test_urlopener_cross_process_response_scoped_metrics = [

tests/external_httplib/test_urllib2.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import os
1615
import urllib.request as urllib2
1716

1817
import pytest

0 commit comments

Comments
 (0)