Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
FileNotFoundError
when the download_dir
is a non-existing nes…
…ted folder (#2910) * replace `os.mkdir` with `os.makedirs` to prevent `FileNotFoundError` when trying to use non-existing nested folders * add unittests for download_dir
- Loading branch information
Showing
3 changed files
with
22 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from nltk import download | ||
|
||
|
||
def test_downloader_using_existing_parent_download_dir(tmp_path): | ||
"""Test that download works properly when the parent folder of the download_dir exists""" | ||
|
||
download_dir = str(tmp_path.joinpath("another_dir")) | ||
download_status = download("mwa_ppdb", download_dir) | ||
assert download_status is True | ||
|
||
|
||
def test_downloader_using_non_existing_parent_download_dir(tmp_path): | ||
"""Test that download works properly when the parent folder of the download_dir does not exist""" | ||
|
||
download_dir = str( | ||
tmp_path.joinpath("non-existing-parent-folder", "another-non-existing-folder") | ||
) | ||
download_status = download("mwa_ppdb", download_dir) | ||
assert download_status is True |