File: fix_test_microbit.patch

package info (click to toggle)
mu-editor 1.2.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 13,492 kB
  • sloc: python: 33,326; makefile: 154; xml: 32; sh: 7
file content (238 lines) | stat: -rw-r--r-- 10,458 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
Index: mu-editor/tests/modes/test_microbit.py
===================================================================
--- mu-editor.orig/tests/modes/test_microbit.py
+++ mu-editor/tests/modes/test_microbit.py
@@ -50,6 +50,7 @@ def test_DeviceFlasher_init():
     assert df.python_script == "script"
 
 
+@pytest.mark.skip("in debian, mu.contrib.uflash is replaced by uflash; so, mock.patch cannot work...")
 def test_DeviceFlasher_run():
     """
     Ensure the uflash.flash function is called as expected.
@@ -63,6 +64,7 @@ def test_DeviceFlasher_run():
     )
 
 
+@pytest.mark.skip("in debian, mu.contrib.uflash is replaced by uflash; so, mock.patch cannot work...")
 def test_DeviceFlasher_run_fail():
     """
     Ensure the on_flash_fail signal is emitted if an exception is thrown.
@@ -131,6 +133,7 @@ def test_flash_no_tab():
     assert mm.flash() is None
 
 
+@pytest.mark.skip("our debian packages do not know various MICROPYTHON_VERSION")
 def test_flash_with_attached_device_has_latest_firmware_v1(microbit):
     """
     There's NO need to use the DeviceFlasher if the board already has the
@@ -139,7 +142,7 @@ def test_flash_with_attached_device_has_
     version_info = {
         "sysname": "microbit",
         "nodename": "microbit",
-        "release": uflash.MICROPYTHON_V1_VERSION,
+        "release": uflash.MICROPYTHON_VERSION,
         "version": (
             "micro:bit v0.1.0-b'e10a5ff' on 2018-6-8; MicroPython "
             "v1.9.2-34-gd64154c73 on 2017-09-01"
@@ -169,6 +172,7 @@ def test_flash_with_attached_device_has_
         mm.copy_main.assert_called_once_with(b"foo")
 
 
+@pytest.mark.skip("our debian packages do not know various MICROPYTHON_VERSION")
 def test_flash_with_attached_device_has_latest_firmware_v2(microbit):
     """
     There's NO need to use the DeviceFlasher if the board already has the
@@ -177,7 +181,7 @@ def test_flash_with_attached_device_has_
     version_info = {
         "sysname": "microbit",
         "nodename": "microbit",
-        "release": uflash.MICROPYTHON_V2_VERSION,
+        "release": uflash.MICROPYTHON_VERSION,
         "version": (
             "micro:bit v2.0.0-beta.3+d6c01d0 on 2020-12-21; "
             "MicroPython v1.13 on 2020-12-21"
@@ -207,6 +211,7 @@ def test_flash_with_attached_device_has_
         mm.copy_main.assert_called_once_with(b"foo")
 
 
+@pytest.mark.skip("our debian packages do not know various MICROPYTHON_VERSION")
 def test_flash_device_has_latest_firmware_encounters_serial_problem(microbit):
     """
     If copy_main encounters an IOError (likely on Windows), revert to
@@ -215,7 +220,7 @@ def test_flash_device_has_latest_firmwar
     version_info = {
         "sysname": "microbit",
         "nodename": "microbit",
-        "release": uflash.MICROPYTHON_V1_VERSION,
+        "release": uflash.MICROPYTHON_VERSION,
         "version": (
             "micro:bit v0.1.0-b'e10a5ff' on 2018-6-8; MicroPython "
             "v1.9.2-34-gd64154c73 on 2017-09-01"
@@ -259,6 +264,7 @@ def test_flash_device_has_latest_firmwar
         mock_flasher.start.assert_called_once_with()
 
 
+@pytest.mark.skip("our debian packages do not know various MICROPYTHON_VERSION")
 def test_flash_with_attached_device_has_latest_firmware_encounters_problem(
     microbit,
 ):
@@ -268,7 +274,7 @@ def test_flash_with_attached_device_has_
     version_info = {
         "sysname": "microbit",
         "nodename": "microbit",
-        "release": uflash.MICROPYTHON_V1_VERSION,
+        "release": uflash.MICROPYTHON_VERSION,
         "version": (
             "micro:bit v0.1.0-b'e10a5ff' on 2018-6-8; MicroPython "
             "v1.9.2-34-gd64154c73 on 2017-09-01"
@@ -599,7 +605,7 @@ def test_force_flash_no_serial_connectio
     mock_flasher = mock.MagicMock()
     mock_flasher_class = mock.MagicMock(return_value=mock_flasher)
     with mock.patch(
-        "mu.contrib.uflash.find_microbit", return_value="/path/microbit"
+        "uflash.find_microbit", return_value="/path/microbit"
     ), mock.patch("mu.contrib.microfs.get_serial"), mock.patch(
         "mu.contrib.microfs.version", side_effect=IOError("bang")
     ), mock.patch(
@@ -633,7 +639,7 @@ def test_force_flash_empty_script(microb
     version_info = {
         "sysname": "microbit",
         "nodename": "microbit",
-        "release": uflash.MICROPYTHON_V1_VERSION,
+        "release": uflash.MICROPYTHON_VERSION,
         "version": (
             "micro:bit v0.1.0-b'e10a5ff' on 2018-6-8; MicroPython "
             "v1.9.2-34-gd64154c73 on 2017-09-01"
@@ -643,7 +649,7 @@ def test_force_flash_empty_script(microb
     mock_flasher = mock.MagicMock()
     mock_flasher_class = mock.MagicMock(return_value=mock_flasher)
     with mock.patch(
-        "mu.contrib.uflash.find_microbit", return_value="/path/microbit"
+        "uflash.find_microbit", return_value="/path/microbit"
     ), mock.patch("mu.contrib.microfs.get_serial"), mock.patch(
         "mu.contrib.microfs.version", return_value=version_info
     ), mock.patch(
@@ -679,7 +685,7 @@ def test_force_flash_user_specified_devi
     version_info = {
         "sysname": "microbit",
         "nodename": "microbit",
-        "release": uflash.MICROPYTHON_V1_VERSION,
+        "release": uflash.MICROPYTHON_VERSION,
         "version": (
             "micro:bit v0.1.0-b'e10a5ff' on 2018-6-8; MicroPython "
             "v1.9.2-34-gd64154c73 on 2017-09-01"
@@ -689,7 +695,7 @@ def test_force_flash_user_specified_devi
     mock_flasher = mock.MagicMock()
     mock_flasher_class = mock.MagicMock(return_value=mock_flasher)
     with mock.patch(
-        "mu.contrib.uflash.find_microbit", return_value=None
+        "uflash.find_microbit", return_value=None
     ), mock.patch("mu.contrib.microfs.get_serial"), mock.patch(
         "mu.contrib.microfs.version", return_value=version_info
     ), mock.patch(
@@ -724,11 +730,11 @@ def test_flash_path_specified_does_not_e
     in the specified location.
     """
     with mock.patch(
-        "mu.contrib.uflash.find_microbit", return_value=None
+        "uflash.find_microbit", return_value=None
     ), mock.patch("mu.logic.os.path.exists", return_value=False), mock.patch(
         "mu.logic.os.makedirs", return_value=None
     ), mock.patch(
-        "mu.contrib.uflash.save_hex", return_value=None
+        "uflash.save_hex", return_value=None
     ) as s:
         view = mock.MagicMock()
         view.current_tab.text = mock.MagicMock(return_value="")
@@ -757,8 +763,8 @@ def test_flash_without_device():
     helpful status message is enacted.
     """
     with mock.patch(
-        "mu.contrib.uflash.find_microbit", return_value=None
-    ), mock.patch("mu.contrib.uflash.save_hex", return_value=None) as s:
+        "uflash.find_microbit", return_value=None
+    ), mock.patch("uflash.save_hex", return_value=None) as s:
         view = mock.MagicMock()
         view.get_microbit_path = mock.MagicMock(return_value=None)
         view.current_tab.text = mock.MagicMock(return_value="")
@@ -794,7 +800,7 @@ def test_flash_script_too_big():
     editor = mock.MagicMock()
     editor.minify = True
     mm = MicrobitMode(editor, view)
-    with mock.patch("mu.contrib.uflash._MAX_SIZE", 8188):
+    with mock.patch("uflash._MAX_SIZE", 8188):
         mm.flash()
     view.show_message.assert_called_once_with(
         'Unable to flash "foo"',
@@ -815,7 +821,7 @@ def test_flash_script_too_big_no_minify(
     editor.minify = False
     mm = MicrobitMode(editor, view)
     with mock.patch("mu.modes.microbit.can_minify", False), mock.patch(
-        "mu.contrib.uflash._MAX_SIZE", 8188
+        "uflash._MAX_SIZE", 8188
     ):
         mm.flash()
     view.show_message.assert_called_once_with(
@@ -970,14 +976,14 @@ def test_flash_minify(microbit_v1_5):
     mm = MicrobitMode(editor, view)
     mm.set_buttons = mock.MagicMock()
     with mock.patch("mu.modes.microbit.DeviceFlasher"), mock.patch(
-        "mu.contrib.uflash._MAX_SIZE", 8188
+        "uflash._MAX_SIZE", 8188
     ), mock.patch("nudatus.mangle", return_value="") as m:
         mm.flash()
         m.assert_called_once_with(script)
 
     ex = TokenError("Bad", (1, 0))
     with mock.patch("nudatus.mangle", side_effect=ex) as m, mock.patch(
-        "mu.contrib.uflash._MAX_SIZE", 8188
+        "uflash._MAX_SIZE", 8188
     ):
         mm.flash()
         view.show_message.assert_called_with(
@@ -999,7 +1005,7 @@ def test_flash_minify_no_minify(microbit
     mm = MicrobitMode(editor, view)
     mm.set_buttons = mock.MagicMock()
     with mock.patch("mu.modes.microbit.can_minify", False), mock.patch(
-        "mu.contrib.uflash._MAX_SIZE", 8188
+        "uflash._MAX_SIZE", 8188
     ), mock.patch("nudatus.mangle", return_value="") as m:
         mm.flash()
         assert m.call_count == 0
@@ -1284,7 +1290,7 @@ def test_open_hex():
     mock_open = mock.mock_open()
     hex_extracted = "RECOVERED"
     with mock.patch("builtins.open", mock_open), mock.patch(
-        "mu.contrib.uflash.extract_script", return_value=hex_extracted
+        "uflash.extract_script", return_value=hex_extracted
     ) as extract_script:
         text, newline = mm.open_file("path_to_file.hex")
     assert text == hex_extracted
@@ -1302,7 +1308,7 @@ def test_open_ignore_non_hex():
     mm = MicrobitMode(editor, view)
     mock_open = mock.mock_open()
     with mock.patch("builtins.open", mock_open), mock.patch(
-        "mu.contrib.uflash.extract_script", return_value="Should not be called"
+        "uflash.extract_script", return_value="Should not be called"
     ) as extract_script:
         text, newline = mm.open_file("path_to_file.py")
     assert text is None
@@ -1312,7 +1318,7 @@ def test_open_ignore_non_hex():
 
     mock_open.reset_mock()
     with mock.patch("builtins.open", mock_open), mock.patch(
-        "mu.contrib.uflash.extract_script", return_value="Should not be called"
+        "uflash.extract_script", return_value="Should not be called"
     ) as extract_script:
         text, newline = mm.open_file("file_no_extension")
     assert text is None
@@ -1332,7 +1338,7 @@ def test_open_hex_with_exception():
     mock_open = mock.mock_open()
     mock_extract = mock.MagicMock(side_effect=Exception(":("))
     with mock.patch("builtins.open", mock_open), mock.patch(
-        "mu.contrib.uflash.extract_script", mock_extract
+        "uflash.extract_script", mock_extract
     ):
         text, newline = mm.open_file("path_to_file.hex")
     assert text is None