Skip to content

Commit

Permalink
Added newly introduced compile_pattern method to flavour classes
Browse files Browse the repository at this point in the history
- copied original versions from _PosixFlavour/_WindowsFlavour
  into respective fake classes
- use newest available Python version in Travis builds
- see #508
  • Loading branch information
mrbean-bremen committed Jan 1, 2020
1 parent 5e7288d commit 90850d1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
14 changes: 7 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
script:
- ./.travis/run_tests.sh
- ./.travis/run_pytest_plugin_test.sh
python: 3.5
python: 3.5.9
env:
- PYTHON=py35
- PY_VERSION=3.5.9
Expand All @@ -38,7 +38,7 @@ jobs:
- ./.travis/run_tests.sh
- ./.travis/run_pytest_fixture_test.sh
- ./.travis/run_pytest_plugin_test.sh
python: 3.6
python: 3.6.9
env:
- PYTHON=py36
- PY_VERSION=3.6.9
Expand All @@ -48,7 +48,7 @@ jobs:
- ./.travis/run_tests.sh
- ./.travis/run_pytest_fixture_test.sh
- ./.travis/run_pytest_plugin_test.sh
python: 3.7
python: 3.7.5
dist: xenial
sudo: true
env:
Expand All @@ -60,12 +60,12 @@ jobs:
- ./.travis/run_tests.sh
- ./.travis/run_pytest_fixture_test.sh
- ./.travis/run_pytest_plugin_test.sh
python: 3.8
python: 3.8.1
dist: xenial
sudo: true
env:
- PYTHON=py38
- PY_VERSION=3.8.0
- PY_VERSION=3.8.1

- stage: test
script:
Expand Down Expand Up @@ -96,7 +96,7 @@ jobs:
language: generic
env:
- PYTHON=py37
- PY_VERSION=3.7.5
- PY_VERSION=3.7.6

- stage: test
script:
Expand All @@ -107,7 +107,7 @@ jobs:
language: generic
env:
- PYTHON=py38
- PY_VERSION=3.8.0
- PY_VERSION=3.8.1

- stage: test
script:
Expand Down
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ the proposed changes so you can be ready.
#### Fixes
* Fixed behavior of `os.makedirs` in write-protected directory
(see [#507](../../issues/507))
* Adapted fake `pathlib` to changes in Python 3.7.6/3.8.1
(see [#508](../../issues/508))

## [Version 3.7](https://pypi.python.org/pypi/pyfakefs/3.7)

Expand Down
9 changes: 8 additions & 1 deletion pyfakefs/fake_pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
(including PurePosixPath, PosixPath, PureWindowsPath and WindowsPath)
get the properties of the underlying fake filesystem.
"""

import fnmatch
import os
import re

try:
from urllib.parse import quote_from_bytes as urlquote_from_bytes
Expand Down Expand Up @@ -404,6 +405,9 @@ def gethomedir(self, username):
userhome = self.join(parts)
return userhome

def compile_pattern(self, pattern):
return re.compile(fnmatch.translate(pattern), re.IGNORECASE).fullmatch


class _FakePosixFlavour(_FakeFlavour):
"""Flavour used by PurePosixPath with some Unix specific implementations
Expand Down Expand Up @@ -435,6 +439,9 @@ def gethomedir(self, username):
raise RuntimeError("Can't determine home directory "
"for %r" % username)

def compile_pattern(self, pattern):
return re.compile(fnmatch.translate(pattern)).fullmatch


path_module = pathlib.Path if pathlib else object

Expand Down
3 changes: 2 additions & 1 deletion pyfakefs/tests/fake_pathlib_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,8 +683,8 @@ def test_glob(self):
[self.path(self.make_path('foo', 'all_tests.py')),
self.path(self.make_path('foo', 'setup.py'))])

@unittest.skipIf(not is_windows, 'Windows specific test')
def test_glob_case_windows(self):
self.check_windows_only()
self.create_file(self.make_path('foo', 'setup.py'))
self.create_file(self.make_path('foo', 'all_tests.PY'))
self.create_file(self.make_path('foo', 'README.md'))
Expand All @@ -695,6 +695,7 @@ def test_glob_case_windows(self):
self.path(self.make_path('foo', 'example.Py')),
self.path(self.make_path('foo', 'setup.py'))])

@unittest.skipIf(is_windows, 'Posix specific test')
def test_glob_case_posix(self):
self.check_posix_only()
self.create_file(self.make_path('foo', 'setup.py'))
Expand Down

0 comments on commit 90850d1

Please sign in to comment.