| 965 | |
| 966 | @pytest.mark.skipif(not library.python.windows.on_win(), reason='Test hardlinks on windows') |
| 967 | def test_hardlink_or_copy(): |
| 968 | max_allowed_hard_links = 1023 |
| 969 | |
| 970 | def run(hardlink_function, dir): |
| 971 | src = r"test.txt" |
| 972 | with open(src, "w") as f: |
| 973 | f.write("test") |
| 974 | for i in range(max_allowed_hard_links + 1): |
| 975 | hardlink_function(src, os.path.join(dir, "{}.txt".format(i))) |
| 976 | |
| 977 | dir1 = library.python.fs.create_dirs("one") |
| 978 | with pytest.raises(WindowsError) as e: |
| 979 | run(library.python.fs.hardlink, dir1) |
| 980 | assert e.value.winerror == 1142 |
| 981 | assert len(os.listdir(dir1)) == max_allowed_hard_links |
| 982 | |
| 983 | dir2 = library.python.fs.create_dirs("two") |
| 984 | run(library.python.fs.hardlink_or_copy, dir2) |
| 985 | assert len(os.listdir(dir2)) == max_allowed_hard_links + 1 |
| 986 | |
| 987 | |
| 988 | def test_remove_tree_unicode(): |