Code Duplication    Length = 27-31 lines in 3 locations

tests/core/test_path_actions.py 3 locations

@@ 267-297 (lines=31) @@
264
        axn.reverse()
265
        assert not lexists(axn.target_full_path)
266
267
    def test_simple_LinkPathAction_softlink(self):
268
        if not softlink_supported(__file__, self.prefix) and on_win:
269
            pytest.skip("softlink not supported")
270
271
        source_full_path = make_test_file(self.pkgs_dir)
272
        target_short_path = source_short_path = basename(source_full_path)
273
274
        correct_sha256 = compute_sha256sum(source_full_path)
275
        correct_size_in_bytes = getsize(source_full_path)
276
        path_type = PathType.hardlink
277
278
        source_path_data = PathDataV1(
279
            _path = source_short_path,
280
            path_type=path_type,
281
            sha256=correct_sha256,
282
            size_in_bytes=correct_size_in_bytes,
283
        )
284
285
        axn = LinkPathAction({}, None, self.pkgs_dir, source_short_path, self.prefix,
286
                             target_short_path, LinkType.softlink, source_path_data)
287
288
        assert axn.target_full_path == join(self.prefix, target_short_path)
289
        axn.verify()
290
        axn.execute()
291
        assert isfile(axn.target_full_path)
292
        assert islink(axn.target_full_path)
293
        assert stat_nlink(axn.target_full_path) == 1
294
295
        axn.reverse()
296
        assert not lexists(axn.target_full_path)
297
        assert lexists(source_full_path)
298
299
    def test_simple_LinkPathAction_directory(self):
300
        target_short_path = join('a', 'nested', 'directory')
@@ 313-339 (lines=27) @@
310
        assert not lexists(dirname(axn.target_full_path))
311
        assert not lexists(dirname(dirname(axn.target_full_path)))
312
313
    def test_simple_LinkPathAction_copy(self):
314
        source_full_path = make_test_file(self.pkgs_dir)
315
        target_short_path = source_short_path = basename(source_full_path)
316
317
        correct_sha256 = compute_sha256sum(source_full_path)
318
        correct_size_in_bytes = getsize(source_full_path)
319
        path_type = PathType.hardlink
320
321
        source_path_data = PathDataV1(
322
            _path = source_short_path,
323
            path_type=path_type,
324
            sha256=correct_sha256,
325
            size_in_bytes=correct_size_in_bytes,
326
        )
327
328
        axn = LinkPathAction({}, None, self.pkgs_dir, source_short_path, self.prefix,
329
                             target_short_path, LinkType.copy, source_path_data)
330
331
        assert axn.target_full_path == join(self.prefix, target_short_path)
332
        axn.verify()
333
        axn.execute()
334
        assert isfile(axn.target_full_path)
335
        assert not islink(axn.target_full_path)
336
        assert stat_nlink(axn.target_full_path) == 1
337
338
        axn.reverse()
339
        assert not lexists(axn.target_full_path)
340
341
    # @pytest.mark.skipif(on_win, reason="unix-only test")
342
    # def test_CreateApplicationSoftlinkAction_basic_symlink_unix(self):
@@ 239-265 (lines=27) @@
236
            windows_exe_axn.reverse()
237
            assert not isfile(windows_exe_axn.target_full_path)
238
239
    def test_simple_LinkPathAction_hardlink(self):
240
        source_full_path = make_test_file(self.pkgs_dir)
241
        target_short_path = source_short_path = basename(source_full_path)
242
243
        correct_sha256 = compute_sha256sum(source_full_path)
244
        correct_size_in_bytes = getsize(source_full_path)
245
        path_type = PathType.hardlink
246
247
        source_path_data = PathDataV1(
248
            _path = source_short_path,
249
            path_type=path_type,
250
            sha256=correct_sha256,
251
            size_in_bytes=correct_size_in_bytes,
252
        )
253
254
        axn = LinkPathAction({}, None, self.pkgs_dir, source_short_path, self.prefix,
255
                             target_short_path, LinkType.hardlink, source_path_data)
256
257
        assert axn.target_full_path == join(self.prefix, target_short_path)
258
        axn.verify()
259
        axn.execute()
260
        assert isfile(axn.target_full_path)
261
        assert not islink(axn.target_full_path)
262
        assert stat_nlink(axn.target_full_path) == 2
263
264
        axn.reverse()
265
        assert not lexists(axn.target_full_path)
266
267
    def test_simple_LinkPathAction_softlink(self):
268
        if not softlink_supported(__file__, self.prefix) and on_win: