Skip to content

Commit

Permalink
Death to hashitanyway
Browse files Browse the repository at this point in the history
  • Loading branch information
DRMacIver committed Mar 18, 2015
1 parent a4921b0 commit 550570a
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 316 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import hypothesis.internal.distributions as dist
from hypothesis.internal.compat import hrange, text_type
from hypothesis.internal.fixers import equal
from hypothesis.internal.hashitanyway import normal_hash, hash_everything
from hypothesis.searchstrategy.strategies import SearchStrategy, \
strategy, check_data_type

Expand All @@ -35,8 +34,6 @@
def equal_datetimes(x, y, fuzzy=False):
return (x.tzinfo == y.tzinfo) and (x == y)

hash_everything.extend(dt.datetime)(normal_hash)


def draw_day_for_month(random, year, month):
# Validate that we've not got a bad year or month
Expand Down
12 changes: 1 addition & 11 deletions src/hypothesis/database/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# END HEADER

from hypothesis.internal.fixers import nice_string
from hypothesis.internal.hashitanyway import HashItAnyway
from hypothesis.internal.tracker import Tracker
from hypothesis.searchstrategy.strategies import BadData, strategy
from hypothesis.database.formats import JSONFormat
Expand Down Expand Up @@ -90,7 +89,6 @@ def __init__(
'but backend expects data of type %s' % (
self.format.data_type(), self.backend.data_type()
)))
self.storage_cache = {}

def storage_for(self, descriptor):
"""Get a storage object corresponding to this descriptor.
Expand All @@ -99,18 +97,10 @@ def storage_for(self, descriptor):
x.storage_for(d). You can rely on that behaviour.
"""
key = HashItAnyway(descriptor)
try:
return self.storage_cache[key]
except KeyError:
pass

result = Storage(
return Storage(
descriptor=descriptor,
database=self,
backend=self.backend,
format=self.format,
strategy=strategy(descriptor),
)
self.storage_cache[key] = result
return result
10 changes: 0 additions & 10 deletions src/hypothesis/descriptortests.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@
from collections import namedtuple

from hypothesis import given
from hypothesis.errors import Exhausted
from hypothesis.database import ExampleDatabase
from hypothesis.settings import Settings
from hypothesis.internal.compat import text_type, integer_types
from hypothesis.internal.fixers import nice_string, actually_equal
from hypothesis.database.backend import SQLiteBackend
from hypothesis.internal.verifier import Verifier
from hypothesis.internal.hashitanyway import hash_everything
from hypothesis.searchstrategy.strategies import BuildContext, \
SearchStrategy, strategy

Expand Down Expand Up @@ -119,14 +117,6 @@ def is_basic(v):
supposedly_basic = strat.to_basic(value)
self.assertTrue(is_basic(supposedly_basic), repr(supposedly_basic))

def test_produces_two_distinct_hashes(self):
try:
verifier.falsify(
lambda x, y: hash_everything(x) == hash_everything(y),
descriptor, descriptor)
except Exhausted:
pass

@descriptor_test
def test_can_round_trip_through_the_database(self, template):
empty_db = ExampleDatabase(
Expand Down
116 changes: 0 additions & 116 deletions src/hypothesis/internal/hashitanyway.py

This file was deleted.

10 changes: 6 additions & 4 deletions src/hypothesis/internal/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@ def object_to_tracking_key(o):
class Tracker(object):

def __init__(self):
self.contents = {}
self.contents = set()

def __len__(self):
return len(self.contents)

def track(self, x):
k = object_to_tracking_key(x)
n = self.contents.get(k, 0) + 1
self.contents[k] = n
return n
if k in self.contents:
return 2
else:
self.contents.add(k)
return 1
48 changes: 0 additions & 48 deletions tests/common/mutate.py

This file was deleted.

124 changes: 0 additions & 124 deletions tests/test_hashitanyway.py

This file was deleted.

0 comments on commit 550570a

Please sign in to comment.