Skip to content

Commit

Permalink
Merge 479414c into 48e7c1c
Browse files Browse the repository at this point in the history
  • Loading branch information
ericpre committed Feb 2, 2021
2 parents 48e7c1c + 479414c commit c159bee
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Expand Up @@ -13,6 +13,7 @@ RELEASE_next_patch (Unreleased)
* Pass keyword argument to the image IO plugins (`#2627 <https://github.com/hyperspy/hyperspy/pull/2627>`_)
* Drop support for numpy<1.16, in line with NEP 29 and fix protochip reader for numpy 1.20 (`#2616 <https://github.com/hyperspy/hyperspy/pull/2616>`_)
* Run test suite against upstream dependencies (numpy, scipy, scikit-learn and scikit-image) (`#2616 <https://github.com/hyperspy/hyperspy/pull/2616>`_)
* Improve error message when file not found (`#2597 <https://github.com/hyperspy/hyperspy/pull/2597>`_)

Changelog
*********
Expand Down
3 changes: 2 additions & 1 deletion hyperspy/io.py
Expand Up @@ -314,14 +314,15 @@ def load(filenames=None,
raise ValueError("No file provided to reader")

if isinstance(filenames, str):
pattern = filenames
if escape_square_brackets:
filenames = _escape_square_brackets(filenames)

filenames = natsorted([f for f in glob.glob(filenames)
if os.path.isfile(f)])

if not filenames:
raise ValueError('No filename matches this pattern')
raise ValueError(f'No filename matches the pattern "{pattern}"')

elif isinstance(filenames, Path):
# Just convert to list for now, pathlib.Path not
Expand Down
6 changes: 3 additions & 3 deletions hyperspy/tests/io/test_io.py
Expand Up @@ -98,7 +98,7 @@ def test_glob_wildcards():
for f in fnames:
s.save(f)

with pytest.raises(ValueError, match="No filename matches this pattern"):
with pytest.raises(ValueError, match="No filename matches the pattern"):
_ = hs.load(fnames[0])

t = hs.load([fnames[0]])
Expand All @@ -113,7 +113,7 @@ def test_glob_wildcards():
t = hs.load(os.path.join(dirpath, "temp[*].hspy"), escape_square_brackets=True,)
assert len(t) == 2

with pytest.raises(ValueError, match="No filename matches this pattern"):
with pytest.raises(ValueError, match="No filename matches the pattern"):
_ = hs.load(os.path.join(dirpath, "temp[*].hspy"))

# Test pathlib.Path
Expand All @@ -137,7 +137,7 @@ def test_file_not_found_error():
if os.path.exists(temp_fname):
os.remove(temp_fname)

with pytest.raises(ValueError, match="No filename matches this pattern"):
with pytest.raises(ValueError, match='No filename matches the pattern'):
_ = hs.load(temp_fname)

with pytest.raises(FileNotFoundError):
Expand Down

0 comments on commit c159bee

Please sign in to comment.