Skip to content
This repository has been archived by the owner on Feb 13, 2020. It is now read-only.

Commit

Permalink
Bug: FileDataGenerator used the full filename to generate the random …
Browse files Browse the repository at this point in the history
…seed.
  • Loading branch information
agroszer committed Apr 7, 2014
1 parent 4b4b323 commit 41f3904
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Expand Up @@ -5,7 +5,8 @@ CHANGES
2.1.1 (unreleased)
------------------

- Nothing changed yet.
- Bug: FileDataGenerator used the full filename to generate the random seed.
That is definitely going to break consistency/tests on someone else's system.


2.1.0 (2013-03-15)
Expand Down
4 changes: 3 additions & 1 deletion src/z3c/datagenerator/generator.py
Expand Up @@ -24,6 +24,7 @@

from z3c.datagenerator import interfaces


def consistent_hash(buf):
# Produce a hash of a string that behaves consistently in Python 32 and
# 64 bit. The "& 0xffffffff" interprets negative numbers as positive.
Expand Down Expand Up @@ -55,7 +56,8 @@ class FileDataGenerator(object):
path = os.path.dirname(__file__)

def __init__(self, seed, filename):
self.random = random.Random(consistent_hash(seed+filename))
justname = os.path.basename(filename)
self.random = random.Random(consistent_hash(seed+justname))
self.values = self._read(filename)

def get(self):
Expand Down

0 comments on commit 41f3904

Please sign in to comment.