Code Duplication    Length = 16-18 lines in 2 locations

tests/test_path.py 2 locations

@@ 313-330 (lines=18) @@
310
                (root / 'a').unlink()
311
        assert root.listdir() == ['a']
312
        (root / 'a').chmod(stat.S_IWRITE)
313
        (root / 'a').unlink()
314
        assert root.listdir() == []
315
316
317
def test_unlink():
318
    files = """
319
        - a
320
        - b
321
    """
322
    with create_files(files) as _root:
323
        root = path.Path(_root)
324
        assert {p.relpath(root) for p in root} == {'a', 'b'}
325
326
        b = root / 'b'
327
        b.unlink()
328
        assert [p.relpath(root) for p in root] == ['a']
329
330
        a = root / 'a'
331
        a.remove()
332
        assert [p.relpath(root) for p in root] == []
333
@@ 295-310 (lines=16) @@
292
        root = path.Path(_root)
293
        t = time.time()
294
        _stat = root.utime()
295
        assert abs(_stat.st_atime - t) < 1
296
297
298
def test_chmod():
299
    files = """
300
        a
301
    """
302
    with create_files(files) as _root:
303
        root = path.Path(_root)
304
        (root / 'a').chmod(0o0400)  # only read for only current user
305
        # (root / 'a').chmod(stat.S_IREAD)
306
        if sys.platform == 'win32':
307
            # doesn't appear to be any way for a user to create a file that he
308
            # can't unlink on linux.
309
            with pytest.raises(OSError):
310
                (root / 'a').unlink()
311
        assert root.listdir() == ['a']
312
        (root / 'a').chmod(stat.S_IWRITE)
313
        (root / 'a').unlink()