Skip to content

Commit

Permalink
fix caching of file-categorization logic #1041
Browse files Browse the repository at this point in the history
  • Loading branch information
bukzor committed Dec 20, 2017
1 parent 88c9ee7 commit 90e64ec
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTING.rst
Expand Up @@ -163,6 +163,7 @@ their individual contributions.
* `Alex Stapleton <https://www.github.com/public>`_
* `Alex Willmer <https://github.com/moreati>`_ (alex@moreati.org.uk)
* `Ben Peterson <https://github.com/killthrush>`_ (killthrush@hotmail.com_)
* `Buck Evan, copyright Google LLC <https://github.com/bukzor>`_
* `Charles O'Farrell <https://www.github.com/charleso>`_
* `Charlie Tanksley <https://www.github.com/charlietanksley>`_
* `Chris Down <https://chrisdown.name>`_
Expand Down
4 changes: 4 additions & 0 deletions RELEASE.rst
@@ -0,0 +1,4 @@
RELEASE_TYPE: patch

This release fixes :issue:`1044`, which slowed tests by up to 6%
due to broken caching.
5 changes: 3 additions & 2 deletions src/hypothesis/internal/escalation.py
Expand Up @@ -34,13 +34,14 @@ def belongs_to(package):
cache = {text_type: {}, binary_type: {}}

def accept(filepath):
ftype = type(filepath)
try:
return cache[type(filepath)][filepath]
return cache[ftype][filepath]
except KeyError:
pass
filepath = encoded_filepath(filepath)
result = os.path.abspath(filepath).startswith(root)
cache[type(filepath)][filepath] = result
cache[ftype][filepath] = result
return result
accept.__name__ = 'is_%s_file' % (package.__name__,)
return accept
Expand Down

0 comments on commit 90e64ec

Please sign in to comment.