From 58790c119eb3f8fbe97a97546dc19452490ed54f Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Fri, 19 Jun 2020 20:20:00 +0200 Subject: [PATCH] Fix issues of #136 --- parso/_compatibility.py | 4 ++-- test/test_cache.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/parso/_compatibility.py b/parso/_compatibility.py index 8a2d148..4c966d6 100644 --- a/parso/_compatibility.py +++ b/parso/_compatibility.py @@ -51,10 +51,10 @@ except NameError: # Python 2.7 (both IOError + OSError) FileNotFoundError = EnvironmentError try: - # Python 2.7 + # Python 3.3+ PermissionError = PermissionError except NameError: - # Python 3.3+ + # Python 2.7 (both IOError + OSError) PermissionError = EnvironmentError diff --git a/test/test_cache.py b/test/test_cache.py index 858091c..e1a0a9e 100644 --- a/test/test_cache.py +++ b/test/test_cache.py @@ -178,7 +178,7 @@ def test_inactive_cache(tmpdir, isolated_parso_cache): @skip_pypy -def test_permission_error(monkeypatch, recwarn): +def test_permission_error(monkeypatch): def save(*args, **kwargs): was_called[0] = True # Python 2... Use nonlocal instead raise PermissionError @@ -186,5 +186,6 @@ def test_permission_error(monkeypatch, recwarn): was_called = [False] monkeypatch.setattr(cache, '_save_to_file_system', save) - parse(path=__file__, cache=True, diff_cache=True) + with pytest.warns(Warning): + parse(path=__file__, cache=True, diff_cache=True) assert was_called[0]