Skip to content

Commit b6bf2cb

Browse files
committed
remove 3.7 & 3.8 from tests
1 parent bb4c0e8 commit b6bf2cb

18 files changed

+150
-250
lines changed

eng/templates/official/jobs/ci-docker-consumption-tests.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,6 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
Python38:
16-
PYTHON_VERSION: '3.8'
17-
STORAGE_CONNECTION: $(LinuxStorageConnectionString38)
18-
COSMOSDB_CONNECTION: $(LinuxCosmosDBConnectionString38)
19-
EVENTHUB_CONNECTION: $(LinuxEventHubConnectionString38)
20-
SERVICEBUS_CONNECTION: $(LinuxServiceBusConnectionString38)
21-
SQL_CONNECTION: $(LinuxSqlConnectionString38)
22-
EVENTGRID_URI: $(LinuxEventGridTopicUriString38)
23-
EVENTGRID_CONNECTION: $(LinuxEventGridConnectionKeyString38)
2415
Python39:
2516
PYTHON_VERSION: '3.9'
2617
STORAGE_CONNECTION: $(LinuxStorageConnectionString39)

eng/templates/official/jobs/ci-docker-dedicated-tests.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,6 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
Python38:
16-
PYTHON_VERSION: '3.8'
17-
STORAGE_CONNECTION: $(LinuxStorageConnectionString38)
18-
COSMOSDB_CONNECTION: $(LinuxCosmosDBConnectionString38)
19-
EVENTHUB_CONNECTION: $(LinuxEventHubConnectionString38)
20-
SERVICEBUS_CONNECTION: $(LinuxServiceBusConnectionString38)
21-
SQL_CONNECTION: $(LinuxSqlConnectionString38)
22-
EVENTGRID_URI: $(LinuxEventGridTopicUriString38)
23-
EVENTGRID_CONNECTION: $(LinuxEventGridConnectionKeyString38)
2415
Python39:
2516
PYTHON_VERSION: '3.9'
2617
STORAGE_CONNECTION: $(LinuxStorageConnectionString39)

eng/templates/official/jobs/ci-e2e-tests.yml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,6 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
Python37:
16-
PYTHON_VERSION: '3.7'
17-
STORAGE_CONNECTION: $(LinuxStorageConnectionString37)
18-
COSMOSDB_CONNECTION: $(LinuxCosmosDBConnectionString37)
19-
EVENTHUB_CONNECTION: $(LinuxEventHubConnectionString37)
20-
SERVICEBUS_CONNECTION: $(LinuxServiceBusConnectionString37)
21-
SQL_CONNECTION: $(LinuxSqlConnectionString37)
22-
EVENTGRID_URI: $(LinuxEventGridTopicUriString37)
23-
EVENTGRID_CONNECTION: $(LinuxEventGridConnectionKeyString37)
24-
Python38:
25-
PYTHON_VERSION: '3.8'
26-
STORAGE_CONNECTION: $(LinuxStorageConnectionString38)
27-
COSMOSDB_CONNECTION: $(LinuxCosmosDBConnectionString38)
28-
EVENTHUB_CONNECTION: $(LinuxEventHubConnectionString38)
29-
SERVICEBUS_CONNECTION: $(LinuxServiceBusConnectionString38)
30-
SQL_CONNECTION: $(LinuxSqlConnectionString38)
31-
EVENTGRID_URI: $(LinuxEventGridTopicUriString38)
32-
EVENTGRID_CONNECTION: $(LinuxEventGridConnectionKeyString38)
3315
Python39:
3416
PYTHON_VERSION: '3.9'
3517
STORAGE_CONNECTION: $(LinuxStorageConnectionString39)

workers/tests/emulator_tests/test_deferred_bindings_blob_functions.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License.
3-
import sys
43
import time
5-
import unittest
64

75
from tests.utils import testutils
86

97

10-
@unittest.skipIf(sys.version_info.minor <= 8, "The base extension"
11-
"is only supported for 3.9+.")
128
class TestDeferredBindingsBlobFunctions(testutils.WebHostTestCase):
139

1410
@classmethod

workers/tests/emulator_tests/test_eventhub_batch_functions.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License.
33
import json
4-
import sys
54
import time
65
from datetime import datetime
7-
from unittest.case import skipIf
86

97
from dateutil import parser
108
from tests.utils import testutils
@@ -66,9 +64,6 @@ def test_eventhub_multiple(self):
6664

6765
self.assertDictEqual(all_row_keys_seen, row_keys_seen)
6866

69-
@skipIf(sys.version_info.minor == 7,
70-
"Using azure-eventhub SDK with the EventHub Emulator"
71-
"requires Python 3.8+")
7267
@testutils.retryable_test(3, 5)
7368
def test_eventhub_multiple_with_metadata(self):
7469
# Generate a unique event body for EventHub event
@@ -176,9 +171,6 @@ def test_eventhub_multiple(self):
176171

177172
self.assertDictEqual(all_row_keys_seen, row_keys_seen)
178173

179-
@skipIf(sys.version_info.minor == 7,
180-
"Using azure-eventhub SDK with the EventHub Emulator"
181-
"requires Python 3.8+")
182174
@testutils.retryable_test(3, 5)
183175
def test_eventhub_multiple_with_metadata(self):
184176
# Generate a unique event body for EventHub event

workers/tests/emulator_tests/test_eventhub_functions.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License.
33
import json
4-
import sys
54
import time
65

7-
from unittest import skipIf
8-
96
from tests.utils import testutils
107

118

@@ -55,9 +52,6 @@ def test_eventhub_trigger(self):
5552
# Check if the event body matches the initial data
5653
self.assertEqual(response, doc)
5754

58-
@skipIf(sys.version_info.minor == 7,
59-
"Using azure-eventhub SDK with the EventHub Emulator"
60-
"requires Python 3.8+")
6155
@testutils.retryable_test(3, 5)
6256
def test_eventhub_trigger_with_metadata(self):
6357
# Generate a unique event body for EventHub event

workers/tests/endtoend/test_eol_log.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
REQUEST_TIMEOUT_SEC = 5
1212

1313

14-
@skipIf(sys.version_info.minor >= 9,
15-
'3.9+ is supported.')
14+
@skipIf(sys.version_info.minor >= 10,
15+
'3.10+ is supported.')
1616
class TestEOLFunctions(testutils.WebHostTestCase):
1717

1818
@classmethod

workers/tests/endtoend/test_http_v2.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,6 @@ def send_request():
200200
@unittest.skipIf(is_envvar_true(DEDICATED_DOCKER_TEST)
201201
or is_envvar_true(CONSUMPTION_DOCKER_TEST),
202202
"Tests are flaky when running on Docker")
203-
@unittest.skipIf(sys.version_info.minor < 8, "HTTPv2"
204-
"is only supported for 3.8+.")
205203
@unittest.skipIf(sys.version_info.minor >= 13,
206204
"App Setting is not needed for 3.13+")
207205
class TestHttpFunctionsWithInitIndexingDisabled(testutils.WebHostTestCase):
Lines changed: 144 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,151 @@
11
import sys
22
import os
3+
import unittest
34
from unittest.mock import patch
45

56
from proxy_worker.utils.dependency import DependencyManager
7+
from tests.utils import testutils
68

79

8-
@patch("proxy_worker.utils.dependency.DependencyManager._get_cx_deps_path",
9-
return_value="/mock/cx/site-packages")
10-
@patch("proxy_worker.utils.dependency.DependencyManager._get_cx_working_dir",
11-
return_value="/mock/cx")
12-
@patch("proxy_worker.utils.dependency.DependencyManager._get_worker_deps_path",
13-
return_value="/mock/worker")
14-
@patch("proxy_worker.utils.dependency.logger")
15-
def test_use_worker_dependencies(mock_logger, mock_worker, mock_cx_dir, mock_cx_deps):
16-
sys.path = ["/mock/cx/site-packages", "/mock/cx", "/original"]
17-
18-
DependencyManager.initialize()
19-
DependencyManager.use_worker_dependencies()
20-
21-
assert sys.path[0] == "/mock/worker"
22-
assert "/mock/cx/site-packages" not in sys.path
23-
assert "/mock/cx" not in sys.path
24-
25-
mock_logger.info.assert_any_call(
26-
'Applying use_worker_dependencies:'
27-
' worker_dependencies: %s,'
28-
' customer_dependencies: %s,'
29-
' working_directory: %s',
30-
"/mock/worker", "/mock/cx/site-packages", "/mock/cx"
31-
)
32-
33-
34-
@patch("proxy_worker.utils.dependency.DependencyManager._get_cx_deps_path",
35-
return_value="/mock/cx/site-packages")
36-
@patch("proxy_worker.utils.dependency.DependencyManager._get_worker_deps_path",
37-
return_value="/mock/worker")
38-
@patch("proxy_worker.utils.dependency.DependencyManager._get_cx_working_dir",
39-
return_value="/mock/cx")
40-
@patch("proxy_worker.utils.dependency.DependencyManager.is_in_linux_consumption",
41-
return_value=False)
42-
@patch("proxy_worker.utils.dependency.is_envvar_true", return_value=False)
43-
@patch("proxy_worker.utils.dependency.logger")
44-
def test_prioritize_customer_dependencies(mock_logger, mock_env, mock_linux,
45-
mock_cx_dir, mock_worker, mock_cx_deps):
46-
sys.path = ["/mock/worker", "/some/old/path"]
47-
48-
DependencyManager.initialize()
49-
DependencyManager.prioritize_customer_dependencies("/override/cx")
50-
51-
assert sys.path[0] == "/mock/cx/site-packages"
52-
assert sys.path[1] == "/mock/worker"
53-
expected_path = os.path.abspath("/override/cx")
54-
assert expected_path in sys.path
55-
56-
assert any(
57-
"Finished prioritize_customer_dependencies" in str(call[0][0])
58-
for call in mock_logger.info.call_args_list
59-
)
10+
class TestDependency(unittest.TestCase):
11+
12+
@patch("proxy_worker.utils.dependency.DependencyManager._get_cx_deps_path",
13+
return_value="/mock/cx/site-packages")
14+
@patch("proxy_worker.utils.dependency.DependencyManager._get_cx_working_dir",
15+
return_value="/mock/cx")
16+
@patch("proxy_worker.utils.dependency.DependencyManager._get_worker_deps_path",
17+
return_value="/mock/worker")
18+
@patch("proxy_worker.utils.dependency.logger")
19+
def test_use_worker_dependencies(mock_logger, mock_worker, mock_cx_dir,
20+
mock_cx_deps):
21+
sys.path = ["/mock/cx/site-packages", "/mock/cx", "/original"]
22+
23+
DependencyManager.initialize()
24+
DependencyManager.use_worker_dependencies()
25+
26+
assert sys.path[0] == "/mock/worker"
27+
assert "/mock/cx/site-packages" not in sys.path
28+
assert "/mock/cx" not in sys.path
29+
30+
mock_logger.info.assert_any_call(
31+
'Applying use_worker_dependencies:'
32+
' worker_dependencies: %s,'
33+
' customer_dependencies: %s,'
34+
' working_directory: %s',
35+
"/mock/worker", "/mock/cx/site-packages", "/mock/cx"
36+
)
37+
38+
@patch("proxy_worker.utils.dependency.DependencyManager._get_cx_deps_path",
39+
return_value="/mock/cx/site-packages")
40+
@patch("proxy_worker.utils.dependency.DependencyManager._get_worker_deps_path",
41+
return_value="/mock/worker")
42+
@patch("proxy_worker.utils.dependency.DependencyManager._get_cx_working_dir",
43+
return_value="/mock/cx")
44+
@patch("proxy_worker.utils.dependency.DependencyManager.is_in_linux_consumption",
45+
return_value=False)
46+
@patch("proxy_worker.utils.dependency.is_envvar_true", return_value=False)
47+
@patch("proxy_worker.utils.dependency.logger")
48+
def test_prioritize_customer_dependencies(mock_logger, mock_env, mock_linux,
49+
mock_cx_dir, mock_worker, mock_cx_deps):
50+
sys.path = ["/mock/worker", "/some/old/path"]
51+
52+
DependencyManager.initialize()
53+
DependencyManager.prioritize_customer_dependencies("/override/cx")
54+
55+
assert sys.path[0] == "/mock/cx/site-packages"
56+
assert sys.path[1] == "/mock/worker"
57+
expected_path = os.path.abspath("/override/cx")
58+
assert expected_path in sys.path
59+
60+
assert any(
61+
"Finished prioritize_customer_dependencies" in str(call[0][0])
62+
for call in mock_logger.info.call_args_list
63+
)
64+
65+
66+
class TestProtobufImports(unittest.TestCase):
67+
def setUp(self):
68+
self._patch_environ = patch.dict('os.environ', os.environ.copy())
69+
self._patch_sys_path = patch('sys.path', [])
70+
self._patch_importer_cache = patch.dict('sys.path_importer_cache', {})
71+
self._patch_modules = patch.dict('sys.modules', {})
72+
self._customer_func_path = os.path.abspath(
73+
os.path.join(
74+
testutils.UNIT_TESTS_ROOT, 'resources', 'customer_func_path'
75+
)
76+
)
77+
self._worker_deps_path = os.path.abspath(
78+
os.path.join(
79+
testutils.UNIT_TESTS_ROOT, 'resources', 'worker_deps_path'
80+
)
81+
)
82+
self._customer_deps_path = os.path.abspath(
83+
os.path.join(
84+
testutils.UNIT_TESTS_ROOT, 'resources', 'customer_deps_path'
85+
)
86+
)
87+
88+
self._patch_environ.start()
89+
self._patch_sys_path.start()
90+
self._patch_importer_cache.start()
91+
self._patch_modules.start()
92+
93+
def tearDown(self):
94+
self._patch_environ.stop()
95+
self._patch_sys_path.stop()
96+
self._patch_importer_cache.stop()
97+
self._patch_modules.stop()
98+
DependencyManager.cx_deps_path = ''
99+
DependencyManager.cx_working_dir = ''
100+
DependencyManager.worker_deps_path = ''
101+
102+
@unittest.skipIf(sys.version_info.minor != 13,
103+
"The worker brings different protobuf versions"
104+
"between 3.13 and 3.14.")
105+
def test_newrelic_protobuf_import_scenario_worker_deps_313(self):
106+
# https://github.com/Azure/azure-functions-python-worker/issues/1339
107+
# newrelic checks if protobuf has been imported and based on the
108+
# version it finds, imports a specific pb2 file.
109+
110+
# protobuf is brought through the worker's deps.
111+
# Setup paths
112+
DependencyManager.worker_deps_path = self._worker_deps_path
113+
DependencyManager.cx_deps_path = "" # No customer deps
114+
DependencyManager.cx_working_dir = self._customer_func_path
115+
116+
DependencyManager.prioritize_customer_dependencies()
117+
118+
# protobuf v5 is found
119+
from google.protobuf import __version__
120+
121+
protobuf_version = tuple(int(v) for v in __version__.split("."))
122+
self.assertIsNotNone(protobuf_version)
123+
self.assertEqual(protobuf_version[0], 5)
124+
125+
@unittest.skipIf(sys.version_info.minor != 13,
126+
"The worker brings different protobuf versions"
127+
"between 3.13 and 3.14.")
128+
def test_newrelic_protobuf_import_scenario_user_deps_313(self):
129+
# https://github.com/Azure/azure-functions-python-worker/issues/1339
130+
# newrelic checks if protobuf has been imported and based on the
131+
# version it finds, imports a specific pb2 file.
132+
133+
# protobuf is brought through the user's deps.
134+
# Setup paths
135+
DependencyManager.worker_deps_path = self._worker_deps_path
136+
DependencyManager.cx_deps_path = self._customer_deps_path
137+
DependencyManager.cx_working_dir = self._customer_func_path
138+
139+
DependencyManager.prioritize_customer_dependencies()
140+
141+
# protobuf is found from worker deps, but newrelic won't find it
142+
from google.protobuf import __version__
143+
144+
protobuf_version = tuple(int(v) for v in __version__.split("."))
145+
self.assertIsNotNone(protobuf_version)
146+
147+
# newrelic tries to import protobuf v3
148+
self.assertEqual(protobuf_version[0], 3)
149+
150+
# newrelic tries to import protobuf 5
151+
self.assertNotEqual(protobuf_version[0], 5)

workers/tests/unittests/test_datumref.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import sys
1+
22
import unittest
33
from http.cookies import SimpleCookie
4-
from unittest import skipIf
54

65
from dateutil import parser
76
from dateutil.parser import ParserError
@@ -67,8 +66,6 @@ def test_parse_cookie_attr_same_site_explicit_none(self):
6766
def test_parse_to_rpc_http_cookie_list_none(self):
6867
self.assertEqual(parse_to_rpc_http_cookie_list(None), None)
6968

70-
@skipIf(sys.version_info < (3, 8, 0),
71-
"Skip the tests for Python 3.7 and below")
7269
def test_parse_to_rpc_http_cookie_list_valid(self):
7370
headers = [
7471
'foo=bar; Path=/some/path; Secure; HttpOnly; Domain=123; '

0 commit comments

Comments
 (0)