Debian Codegraph @

debian/patches/01_use_python3_interpreter_in_tests.diff

raw
1 Description: Use python3 in tests
2 Some upstream tests call the python interpreter in a subprocess, e.g. to test
3 the custom `process` module or to run simple in-toto step or inspection
4 commands. In debian, where we only build for python3, "python" is not
5 available during build and thus makes those tests fail. This patch replaces
6 "python" with "python3" where applicable.
7 Forwarded: not-needed
8 Origin: upstream, https://github.com/in-toto/in-toto/commit/a7f4baf8d0186fa4a6314264707f4d5d1b3cecdc
9
10 Index: in_toto-1.4.0/tests/demo_files/demo.layout.template
11 ===================================================================
12 --- in_toto-1.4.0.orig/tests/demo_files/demo.layout.template
13 +++ in_toto-1.4.0/tests/demo_files/demo.layout.template
14 @@ -25,7 +25,7 @@
15 ],
16 "name": "untar",
17 "run": [
18 - "python",
19 + "python3",
20 "./scripts/tar",
21 "xfz",
22 "foo.tar.gz"
23 Index: in_toto-1.4.0/tests/test_in_toto_mock.py
24 ===================================================================
25 --- in_toto-1.4.0.orig/tests/test_in_toto_mock.py
26 +++ in_toto-1.4.0/tests/test_in_toto_mock.py
27 @@ -73,7 +73,7 @@ class TestInTotoMockTool(CliTestCase, Tm
28 def test_main_required_args(self):
29 """Test CLI command with required arguments."""
30
31 - args = ["--name", self.test_step, "--", "python", "--version"]
32 + args = ["--name", self.test_step, "--", "python3", "--version"]
33 self.assert_cli_sys_exit(args, 0)
34
35 self.assertTrue(os.path.exists(self.test_link))
36 Index: in_toto-1.4.0/tests/test_in_toto_run.py
37 ===================================================================
38 --- in_toto-1.4.0.orig/tests/test_in_toto_run.py
39 +++ in_toto-1.4.0/tests/test_in_toto_run.py
40 @@ -90,7 +90,7 @@ class TestInTotoRunTool(CliTestCase, TmpDirMixin, GPGKeysMixin, GenKeysMixin):
41 "--key",
42 self.rsa_key_path,
43 "--",
44 - "python",
45 + "python3",
46 "--version",
47 ]
48
49 @@ -111,7 +111,7 @@ class TestInTotoRunTool(CliTestCase, TmpDirMixin, GPGKeysMixin, GenKeysMixin):
50 self.test_artifact,
51 "--record-streams",
52 ]
53 - positional_args = ["--", "python", "--version"]
54 + positional_args = ["--", "python3", "--version"]
55
56 # Test and assert recorded artifacts
57 args1 = named_args + positional_args
58 @@ -171,7 +171,7 @@ class TestInTotoRunTool(CliTestCase, TmpDirMixin, GPGKeysMixin, GenKeysMixin):
59 "--metadata-directory",
60 tmp_dir,
61 "--",
62 - "python",
63 + "python3",
64 "--version",
65 ]
66
67 @@ -230,7 +230,7 @@ class TestInTotoRunTool(CliTestCase, TmpDirMixin, GPGKeysMixin, GenKeysMixin):
68 "--key-type",
69 key_type,
70 ]
71 - cmd = ["--", "python", "--version"]
72 + cmd = ["--", "python3", "--version"]
73
74 # Make sure the link file to be generated doesn't already exist
75 self.assertFalse(os.path.exists(link_path))
76 @@ -262,7 +262,7 @@ class TestInTotoRunTool(CliTestCase, TmpDirMixin, GPGKeysMixin, GenKeysMixin):
77 "--gpg-home",
78 self.gnupg_home,
79 "--",
80 - "python",
81 + "python3",
82 "--version",
83 ]
84
85 @@ -282,7 +282,7 @@ class TestInTotoRunTool(CliTestCase, TmpDirMixin, GPGKeysMixin, GenKeysMixin):
86 "--gpg-home",
87 self.gnupg_home,
88 "--",
89 - "python",
90 + "python3",
91 "--version",
92 ]
93
94 @@ -417,7 +417,7 @@ class TestInTotoRunToolWithDSSE(
95 self.rsa_key_path,
96 "--use-dsse",
97 "--",
98 - "python",
99 + "python3",
100 "--version",
101 ]
102
103 @@ -439,7 +439,7 @@ class TestInTotoRunToolWithDSSE(
104 "--record-streams",
105 "--use-dsse",
106 ]
107 - positional_args = ["--", "python", "--version"]
108 + positional_args = ["--", "python3", "--version"]
109
110 # Test and assert recorded artifacts
111 args1 = named_args + positional_args
112 @@ -491,7 +491,7 @@ class TestInTotoRunToolWithDSSE(
113 self.gnupg_home,
114 "--use-dsse",
115 "--",
116 - "python",
117 + "python3",
118 "--version",
119 ]
120
121 Index: in_toto-1.4.0/tests/test_runlib.py
122 ===================================================================
123 --- in_toto-1.4.0.orig/tests/test_runlib.py
124 +++ in_toto-1.4.0/tests/test_runlib.py
125 @@ -755,13 +755,13 @@ class TestInTotoRun(unittest.TestCase, TmpDirMixin):
126 def test_in_toto_run_verify_signature(self):
127 """Successfully run, verify signed metadata."""
128 link = in_toto_run(
129 - self.step_name, None, None, ["python", "--version"], True, self.key
130 + self.step_name, None, None, ["python3", "--version"], True, self.key
131 )
132 link.verify_signature(self.key)
133
134 def test_in_toto_run_no_signature(self):
135 """Successfully run, verify empty signature field."""
136 - link = in_toto_run(self.step_name, None, None, ["python", "--version"])
137 + link = in_toto_run(self.step_name, None, None, ["python3", "--version"])
138 self.assertFalse(len(link.signatures))
139
140 def test_in_toto_run_with_byproduct(self):
141 @@ -770,7 +770,7 @@ class TestInTotoRun(unittest.TestCase, TmpDirMixin):
142 self.step_name,
143 None,
144 None,
145 - ["python", "--version"],
146 + ["python3", "--version"],
147 record_streams=True,
148 )
149
150 @@ -792,7 +792,7 @@ class TestInTotoRun(unittest.TestCase, TmpDirMixin):
151 self.step_name,
152 None,
153 None,
154 - ["python", "--version"],
155 + ["python3", "--version"],
156 record_streams=False,
157 )
158 self.assertFalse(len(link.signed.byproducts.get("stdout")))
159 @@ -803,7 +803,7 @@ class TestInTotoRun(unittest.TestCase, TmpDirMixin):
160 self.step_name,
161 [self.test_artifact],
162 [self.test_artifact],
163 - ["python", "--version"],
164 + ["python3", "--version"],
165 True,
166 self.key,
167 )
168 @@ -822,7 +822,7 @@ class TestInTotoRun(unittest.TestCase, TmpDirMixin):
169 self.step_name,
170 [self.test_artifact],
171 [self.test_artifact],
172 - ["python", "--version"],
173 + ["python3", "--version"],
174 True,
175 self.key,
176 metadata_directory=tmp_dir,
177 @@ -844,7 +844,7 @@ class TestInTotoRun(unittest.TestCase, TmpDirMixin):
178 self.step_name,
179 [self.test_artifact],
180 [self.test_artifact],
181 - ["python", "--version"],
182 + ["python3", "--version"],
183 True,
184 self.key,
185 metadata_directory=tmp_dir,
186 @@ -861,7 +861,7 @@ class TestInTotoRun(unittest.TestCase, TmpDirMixin):
187 self.step_name,
188 [self.test_artifact],
189 [self.test_artifact],
190 - ["python", "--version"],
191 + ["python3", "--version"],
192 True,
193 self.key,
194 )
195 @@ -880,7 +880,7 @@ class TestInTotoRun(unittest.TestCase, TmpDirMixin):
196 self.step_name,
197 [self.test_artifact],
198 [self.test_artifact],
199 - ["python", "--version"],
200 + ["python3", "--version"],
201 )
202 self.assertEqual(
203 list(link.signed.materials.keys()),
204 @@ -894,7 +894,7 @@ class TestInTotoRun(unittest.TestCase, TmpDirMixin):
205 self.step_name,
206 [],
207 [],
208 - ["python", "--version"],
209 + ["python3", "--version"],
210 record_environment=True,
211 )
212 self.assertEqual(
213 @@ -918,7 +918,7 @@ class TestInTotoRun(unittest.TestCase, TmpDirMixin):
214 self.step_name,
215 paths,
216 paths,
217 - ["python", "--version"],
218 + ["python3", "--version"],
219 normalize_line_endings=True,
220 ).signed
221
222 @@ -939,7 +939,7 @@ class TestInTotoRun(unittest.TestCase, TmpDirMixin):
223 self.step_name,
224 None,
225 None,
226 - ["python", "--version"],
227 + ["python3", "--version"],
228 True,
229 "this-is-not-a-key",
230 )
231 @@ -951,7 +951,7 @@ class TestInTotoRun(unittest.TestCase, TmpDirMixin):
232 self.step_name,
233 None,
234 None,
235 - ["python", "--version"],
236 + ["python3", "--version"],
237 True,
238 self.key_pub,
239 )
240 @@ -963,7 +963,7 @@ class TestInTotoRun(unittest.TestCase, TmpDirMixin):
241 self.step_name,
242 None,
243 None,
244 - ["python", "--version"],
245 + ["python3", "--version"],
246 True,
247 self.key,
248 metadata_directory="nonexistentDir",
249 @@ -980,7 +980,7 @@ class TestInTotoRun(unittest.TestCase, TmpDirMixin):
250 self.step_name,
251 None,
252 None,
253 - ["python", "--version"],
254 + ["python3", "--version"],
255 True,
256 self.key,
257 metadata_directory=path,
258 @@ -998,7 +998,7 @@ class TestInTotoRun(unittest.TestCase, TmpDirMixin):
259 self.step_name,
260 None,
261 None,
262 - ["python", "--version"],
263 + ["python3", "--version"],
264 True,
265 self.key,
266 metadata_directory=tmp_dir,
267 @@ -1012,7 +1012,7 @@ class TestInTotoRun(unittest.TestCase, TmpDirMixin):
268 self.step_name,
269 None,
270 None,
271 - ["python", "--version"],
272 + ["python3", "--version"],
273 True,
274 self.key,
275 use_dsse=True,
276 Index: in_toto-1.4.0/tests/test_verifylib.py
277 ===================================================================
278 --- in_toto-1.4.0.orig/tests/test_verifylib.py
279 +++ in_toto-1.4.0/tests/test_verifylib.py
280 @@ -129,7 +129,7 @@ class TestRunAllInspections(unittest.TestCase, TmpDirMixin):
281 {
282 "name": "touch-bar",
283 "run": [
284 - "python",
285 + "python3",
286 os.path.join(scripts_directory, "touch"),
287 "bar",
288 ],
289 @@ -174,7 +174,7 @@ class TestRunAllInspections(unittest.TestCase, TmpDirMixin):
290 "inspect": [
291 {
292 "name": "non-zero-inspection",
293 - "run": ["python", "./scripts/expr", "1", "/", "0"],
294 + "run": ["python3", "./scripts/expr", "1", "/", "0"],
295 }
296 ],
297 }
298 @@ -990,7 +990,7 @@ class TestInTotoVerify(unittest.TestCase, TmpDirMixin):
299 # dump layout with failing inspection retval
300 layout = copy.deepcopy(layout_template)
301 layout.signed.inspect[0].run = [
302 - "python",
303 + "python3",
304 "./scripts/expr",
305 "1",
306 "/",