Thanks to visit codestin.com
Credit goes to github.com

Skip to content

TST: Make test_movie_writer_invalid_path locale-agnostic #27377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/matplotlib/tests/test_animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,9 +545,9 @@ def test_disable_cache_warning(anim):

def test_movie_writer_invalid_path(anim):
if sys.platform == "win32":
match_str = re.escape("[WinError 3] The system cannot find the path specified:")
match_str = r"\[WinError 3] .*'\\\\foo\\\\bar\\\\aardvark'"
else:
match_str = re.escape("[Errno 2] No such file or directory: '/foo")
Comment on lines -548 to -550
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know a merged this so too late 😓 but could these be combined in an or string?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could these be combined in an or string?

The two match strings could be combined into one string like this:

def test_movie_writer_invalid_path(anim):
    with pytest.raises(
        FileNotFoundError,
        match=r"\[(?:WinError 3|Errno 2)] .*'(?:\\\\foo\\\\bar\\\\aardvark|/foo)'",
    ):
        anim.save("/foo/bar/aardvark/thiscannotreallyexist.mp4",
                  writer=animation.FFMpegFileWriter())

but I think the explicit condition for win32 or else is easier to read and comprehend.

match_str = r"\[Errno 2] .*'/foo"
with pytest.raises(FileNotFoundError, match=match_str):
anim.save("/foo/bar/aardvark/thiscannotreallyexist.mp4",
writer=animation.FFMpegFileWriter())