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

Commit

Permalink
- Switched code base to use random2, so that Python 2 and 3 have …
Browse files Browse the repository at this point in the history
…the same

  output. No need for running different test files now.

- Simplified and unified test setup.
  • Loading branch information
strichter committed Mar 15, 2013
1 parent 61c8f48 commit 833debc
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 17 deletions.
7 changes: 5 additions & 2 deletions CHANGES.rst
Expand Up @@ -2,10 +2,13 @@
CHANGES
=======

2.0.2 (unreleased)
2.1.0 (unreleased)
------------------

- Nothing changed yet.
- Switched code base to use ``random2``, so that Python 2 and 3 have the same
output. No need for running different test files now.

- Simplified and unified test setup.


2.0.1 (2013-02-12)
Expand Down
6 changes: 5 additions & 1 deletion buildout.cfg
@@ -1,8 +1,12 @@
[buildout]
develop = .
parts = test
parts = test py

[test]
recipe = zc.recipe.testrunner
eggs = z3c.datagenerator [test]

[py]
recipe = zc.recipe.egg
eggs = z3c.datagenerator [test]
interpreter = py
5 changes: 3 additions & 2 deletions setup.py
Expand Up @@ -20,7 +20,7 @@ def read(*rnames):

setup (
name='z3c.datagenerator',
version='2.0.2.dev0',
version='2.1.0.dev0',
author = "Stephan Richter and the Zope Community",
author_email = "zope3-dev@zope.org",
description = "Datagenerator for Testing and Sample Data",
Expand Down Expand Up @@ -57,11 +57,12 @@ def read(*rnames):
test = ['zope.testing'],
),
install_requires = [
'random2',
'setuptools',
'zope.interface',
'zope.schema',
],
zip_safe = False,
tests_require = ['zope.testing'],
test_suite = 'z3c.datagenerator.tests.test_doc.test_suite',
test_suite = 'z3c.datagenerator.tests.test_suite',
)
2 changes: 1 addition & 1 deletion src/z3c/datagenerator/README.rst
Expand Up @@ -73,7 +73,7 @@ This generator creates last names from a predefined set.
>>> gen = demographics.LastNameGenerator('seed')

>>> gen.get()
u'Lambert'
u'Lambert'
>>> gen.getMany(3)
[u'Oliver', u'Meyer', u'Jones']

Expand Down
4 changes: 3 additions & 1 deletion src/z3c/datagenerator/README3.rst
Expand Up @@ -3,7 +3,9 @@ Data Generators
===============

:Note: This is the Python 3 version of the documentation. The random number
generator changed, so that the output will differ!
generator changed, so that the output will differ! For now, we are
using `random2` as long as we support Python 2, but once that support
is dropped, the README.txt cann be replaced with this file.

Data Generators are meant to create data for your application quickly. They
are most useful for generating sample data. Sample Data, in turn, allows you
Expand Down
2 changes: 1 addition & 1 deletion src/z3c/datagenerator/demographics.py
Expand Up @@ -15,7 +15,7 @@
__docformat__ = "reStructuredText"
import io
import os
import random
import random2 as random
import zope.interface

from z3c.datagenerator import generator
Expand Down
4 changes: 2 additions & 2 deletions src/z3c/datagenerator/generator.py
Expand Up @@ -18,9 +18,9 @@
import math
import io
import os
import random
from zlib import crc32
import random2 as random
import zope.interface
from zlib import crc32

from z3c.datagenerator import interfaces

Expand Down
2 changes: 1 addition & 1 deletion src/z3c/datagenerator/net.py
Expand Up @@ -14,7 +14,7 @@
"""Demographics Data Generators"""
__docformat__ = "reStructuredText"
import os
import random
import random2 as random
import zope.interface

from z3c.datagenerator import demographics, generator, interfaces
Expand Down
Expand Up @@ -13,16 +13,25 @@
##############################################################################
"""Test Setup"""
import doctest
import re
import sys
import unittest
from zope.testing.doctestunit import DocFileSuite
from zope.testing import renormalizing

checker = renormalizing.RENormalizing([
# Python 3 unicode removed the "u".
(re.compile("(?<![a-zA-Z])u('.*?')"),
r"\1"),
])


def test_suite():
filename = 'README3.rst' if sys.version_info[0] == 3 else 'README.rst'
return unittest.TestSuite((
DocFileSuite('../'+filename,
optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
),
doctest.DocFileSuite(
'README.rst',
checker=checker,
optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
),
))

if __name__ == '__main__':
Expand Down
1 change: 0 additions & 1 deletion src/z3c/datagenerator/tests/__init__.py

This file was deleted.

1 change: 1 addition & 0 deletions tox.ini
Expand Up @@ -8,5 +8,6 @@ commands =
# without explicit deps, setup.py test will download a bunch of eggs into $PWD
# (and it seems I can't use zope.dottedname[testing] here, so forget DRY)
deps =
random2
zope.testing

0 comments on commit 833debc

Please sign in to comment.