spaCy/spacy/tests/test_symlink_windows.py
Shawn Cicoria 7601ae0cff fixes symbolic link on py3 and windows (#2949)
* fixes symbolic link on py3 and windows
during setup of spacy using command
python -m spacy link en_core_web_sm en
closes #2948

* Update spacy/compat.py

Co-Authored-By: cicorias <cicorias@users.noreply.github.com>
2018-11-24 15:34:23 +01:00

37 lines
828 B
Python

import os
from pathlib import Path
from ..compat import symlink_to, symlink_remove, path2str
import pytest
def target_local_path():
return './foo-target'
def link_local_path():
return './foo-symlink'
@pytest.fixture(scope='function')
def setup_target(request):
target = Path(target_local_path())
if not target.exists():
os.mkdir( path2str(target) )
# yield -- need to cleanup even if assertion fails
# https://github.com/pytest-dev/pytest/issues/2508#issuecomment-309934240
def cleanup():
symlink_remove( Path(link_local_path() ) )
os.rmdir( target_local_path() )
request.addfinalizer(cleanup)
def test_create_symlink_windows(setup_target):
target = Path(target_local_path())
link = Path(link_local_path())
assert target.exists()
symlink_to(link, target)
assert link.exists()