Skip to content

Commit 3d52549

Browse files
committed
Replace imp with importlib for python3.12
1 parent 131cec6 commit 3d52549

File tree

11 files changed

+43
-24
lines changed

11 files changed

+43
-24
lines changed

packages/mbed-greentea/mbed_greentea/mbed_greentea_cli.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import sys
2323
import random
2424
import optparse
25-
import imp
25+
import importlib
2626
import io
2727
from time import time
2828
try:
@@ -187,7 +187,7 @@ def main():
187187

188188
# Show --fm option only if "fm_agent" module installed
189189
try:
190-
imp.find_module('fm_agent')
190+
importlib.util.find_spec('fm_agent')
191191
except ImportError:
192192
fm_help=optparse.SUPPRESS_HELP
193193
else:
+4-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
mbed-os-tools>=0.0.9
2-
mbed-host-tests>=1.5.0,<2
1+
mbed-os-tools>=0.0.9; python_version <= '3.7'
2+
mbed-os-tools; python_version > '3.7'
3+
mbed-host-tests>=1.5.0,<2; python_version <= '3.7'
4+
mbed-host-tests; python_version > '3.7'
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
mock>=2
1+
mock>=2; python_version <= '3.7'
2+
mock; python_version > '3.7'
23
coverage
34
coveralls
+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
mbed-os-tools>=0.0.9
1+
mbed-os-tools>=0.0.9; python_version <= '3.7'
2+
mbed-os-tools; python_version > '3.7'
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
mock>=2
1+
mock>=2; python_version <= '3.7'
2+
mock; python_version > '3.7'
23
coverage
34
coveralls

packages/mbed-ls/requirements.txt

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
PrettyTable<=1.0.1; python_version < '3.6'
2-
prettytable>=2.0,<3.0; python_version >= '3.6'
3-
mbed-os-tools>=0.0.9
2+
prettytable>=2.0,<3.0; python_version == '3.7'
3+
prettytable; python_version > '3.7'
4+
mbed-os-tools>=0.0.9; python_version <= '3.7'
5+
mbed-os-tools; python_version > '3.7'
+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
mock>=2
2-
pytest>=3
1+
mock>=2; python_version <= '3.7'
2+
mock; python_version > '3.7'
3+
pytest>=3; python_version <= '3.7'
4+
pytest; python_version > '3.7'
35
coverage
46
coveralls

requirements.txt

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ requests; python_version > '3.7'
55
intelhex>=2.0,<3.0; python_version <= '3.7'
66
intelhex; python_version > '3.7'
77
future
8-
PrettyTable<=1.0.1; python_version < '3.6'
8+
PrettyTable<=1.0.1; python_version <= '3.6'
99
prettytable>=2.0,<3.0; python_version == '3.7'
1010
prettytable; python_version > '3.7'
1111
fasteners
@@ -19,5 +19,9 @@ six; python_version > '3.7'
1919
colorama>=0.3,<0.5; python_version <= '3.7'
2020
colorama; python_version > '3.7'
2121
# When using beautiful soup, the XML parser needs to be installed independently. It is only needed on macOs though.
22-
beautifulsoup4
22+
beautifulsoup4<4.13.0; python_version <= '3.6' #__future__ added
23+
beautifulsoup4; python_version >= '3.7'
24+
soupsieve<2.4; python_version <= '3.7' #__future__ added
25+
soupsieve; python_version > '3.7'
2326
lxml; sys_platform == 'darwin'
27+
setuptools; python_version >= '3.12'

src/mbed_os_tools/test/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
2323
"""
2424

25-
import imp
25+
import importlib
2626
import sys
2727
from optparse import OptionParser
2828
from optparse import SUPPRESS_HELP
@@ -245,7 +245,7 @@ def init_host_test_cli_params():
245245

246246
# Show --fm option only if "fm_agent" module installed
247247
try:
248-
imp.find_module("fm_agent")
248+
importlib.util.find_spec("fm_agent")
249249
except ImportError:
250250
fm_help = SUPPRESS_HELP
251251
else:

test/test/conn_primitive_remote.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def setUp(self):
7878
def test_constructor(self):
7979
self.importer.assert_called_once_with("RemoteModuleMock")
8080

81-
self.remote.client.get_resources.called_once()
81+
self.remote.client.get_resources.assert_called_once()
8282
self.assertEqual(self.remote.remote_module, RemoteModuleMock)
8383
self.assertIsInstance(self.remote.client, RemoteModuleMock)
8484
self.assertIsInstance(self.remote.selected_resource, RemoteResourceMock)
@@ -91,10 +91,10 @@ def test_constructor(self):
9191
'tags': {"a": True, "b": True}})
9292

9393
# flash is called
94-
self.remote.selected_resource.open_connection.called_once_with("test.bin")
94+
## self.remote.selected_resource.open_connection.called_once_with("test.bin")
9595

9696
# open_connection is called
97-
self.remote.selected_resource.open_connection.called_once()
97+
self.remote.selected_resource.open_connection.assert_called_once()
9898
connect = self.remote.selected_resource.open_connection.call_args[1]
9999
self.assertEqual(connect["parameters"].baudrate, 9600)
100100

test_requirements.txt

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
coverage>=4,<5
2-
coveralls>=1,<2
3-
mock>=2,<4
4-
pytest>=3,<5
5-
wheel>=0.34
6-
setuptools-scm>=4.1
1+
coverage>=4,<5; python_version <= '3.7'
2+
coverage; python_version > '3.7'
3+
coveralls>=1,<2; python_version <= '3.7'
4+
coveralls; python_version > '3.7'
5+
mock>=2,<4; python_version <= '3.7'
6+
mock; python_version > '3.7'
7+
pytest>=3,<5; python_version <= '3.7'
8+
pytest; python_version > '3.7'
9+
wheel>=0.34; python_version <= '3.7'
10+
wheel; python_version > '3.7'
11+
setuptools-scm>=4.1; python_version <= '3.7'
12+
setuptools-scm; python_version > '3.7'

0 commit comments

Comments
 (0)