Modernize tests

This commit is contained in:
Mathieu Le Marec - Pasquet 2012-05-20 22:23:24 +02:00
parent cd4ec6bb60
commit 01247083fc
13 changed files with 82 additions and 335 deletions

17
.gitignore vendored
View File

@ -1,17 +1,8 @@
*app.pyc
distribute*
.tox
tox.ini
t/
eggs
/.tox
\.*.cfg
b.sh
develop-eggs
parts
bin
*minitage*
*.egg-info
*.pyc
*.swp
build
/build
/venv
/.cache

View File

@ -1,14 +1,17 @@
sudo: false
language: python
python:
- 2.6
- 2.7
- 3.3
# matrix:
- 3.4
- 3.5
install:
- python bootstrap.py
- 'if [[ x"$(python -V 2>&1)" == x"Python 3"* ]];then ./bin/buildout -c py3.cfg;fi'
- 'if [[ x"$(python -V 2>&1)" == x"Python 2"* ]];then ./bin/buildout;fi'
script: bin/test
- pip install -r requirements/test.txt
script:
- pyver=$(python --version 2>&1 | awk '{print substr($2, 0, 3)}');
case $pyver in
2.7) tox -e "py${pyver//\.}-{std,coverage}";;
*) tox -e "py${pyver//\.}-std";;
esac
after_success:
- coveralls

View File

@ -1,6 +1,7 @@
include *.txt *.cfg *.rst
include *.txt *.cfg *.rst *.ini
recursive-include docs *
recursive-include requirements *
recursive-include src *
global-exclude *pyc

View File

@ -40,7 +40,7 @@ A simple example::
>>> print iter.get_next(datetime) # 2010-01-30 04:02:00
>>> print iter.get_next(datetime) # 2010-02-02 04:02:00
All you need to know is how to use the constructor and the get_next
All you need to know is how to use the constructor and the get_next
method, the signature of these methods are listed below::
>>> def __init__(self, cron_format, start_time=time.time())
@ -52,7 +52,7 @@ http://en.wikipedia.org/wiki/Cron for more details.::
>>> def get_next(self, ret_type=float)
get_next calculates the next value according to the cron expression and
returns an object of type 'ret_type'. ret_type should be a 'float' or a
returns an object of type 'ret_type'. ret_type should be a 'float' or a
'datetime' object.
Supported added for get_prev method. (>= 0.2.0)::
@ -71,9 +71,10 @@ Develop this package
git clone https://github.com/kiorky/croniter.git
cd croniter
python bootstrap.py -d
bin/buildout -vvvvvvN
bin/test
virtualenv --no-site-packages venv
. venv/bin/activate
pip install --upgrade -r requirements/test.txt
py.test src
Make a new release
@ -83,7 +84,9 @@ We use zest.fullreleaser, a great release infrastructure.
Do and follow these instructions
::
bin/fullrelease
. venv/bin/activate
pip install --upgrade -r requirements/release.txt
fullrelease
Contributors

View File

@ -1,170 +0,0 @@
##############################################################################
#
# Copyright (c) 2006 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Bootstrap a buildout-based project
Simply run this script in a directory containing a buildout.cfg.
The script accepts buildout command-line options, so you can
use the -c option to specify an alternate configuration file.
"""
import os
import shutil
import sys
import tempfile
from optparse import OptionParser
tmpeggs = tempfile.mkdtemp()
usage = '''\
[DESIRED PYTHON FOR BUILDOUT] bootstrap.py [options]
Bootstraps a buildout-based project.
Simply run this script in a directory containing a buildout.cfg, using the
Python that you want bin/buildout to use.
Note that by using --find-links to point to local resources, you can keep
this script from going over the network.
'''
parser = OptionParser(usage=usage)
parser.add_option("-v", "--version", help="use a specific zc.buildout version")
parser.add_option("-t", "--accept-buildout-test-releases",
dest='accept_buildout_test_releases',
action="store_true", default=False,
help=("Normally, if you do not specify a --version, the "
"bootstrap script and buildout gets the newest "
"*final* versions of zc.buildout and its recipes and "
"extensions for you. If you use this flag, "
"bootstrap and buildout will get the newest releases "
"even if they are alphas or betas."))
parser.add_option("-c", "--config-file",
help=("Specify the path to the buildout configuration "
"file to be used."))
parser.add_option("-f", "--find-links",
help=("Specify a URL to search for buildout releases"))
options, args = parser.parse_args()
######################################################################
# load/install setuptools
to_reload = False
try:
import pkg_resources
import setuptools
except ImportError:
ez = {}
try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
# XXX use a more permanent ez_setup.py URL when available.
exec(urlopen('https://bitbucket.org/pypa/setuptools/raw/0.7.2/ez_setup.py'
).read(), ez)
setup_args = dict(to_dir=tmpeggs, download_delay=0)
ez['use_setuptools'](**setup_args)
if to_reload:
reload(pkg_resources)
import pkg_resources
# This does not (always?) update the default working set. We will
# do it.
for path in sys.path:
if path not in pkg_resources.working_set.entries:
pkg_resources.working_set.add_entry(path)
######################################################################
# Install buildout
ws = pkg_resources.working_set
cmd = [sys.executable, '-c',
'from setuptools.command.easy_install import main; main()',
'-mZqNxd', tmpeggs]
find_links = os.environ.get(
'bootstrap-testing-find-links',
options.find_links or
('http://downloads.buildout.org/'
if options.accept_buildout_test_releases else None)
)
if find_links:
cmd.extend(['-f', find_links])
setuptools_path = ws.find(
pkg_resources.Requirement.parse('setuptools')).location
requirement = 'zc.buildout'
version = options.version
if version is None and not options.accept_buildout_test_releases:
# Figure out the most recent final version of zc.buildout.
import setuptools.package_index
_final_parts = '*final-', '*final'
def _final_version(parsed_version):
for part in parsed_version:
if (part[:1] == '*') and (part not in _final_parts):
return False
return True
index = setuptools.package_index.PackageIndex(
search_path=[setuptools_path])
if find_links:
index.add_find_links((find_links,))
req = pkg_resources.Requirement.parse(requirement)
if index.obtain(req) is not None:
best = []
bestv = None
for dist in index[req.project_name]:
distv = dist.parsed_version
if _final_version(distv):
if bestv is None or distv > bestv:
best = [dist]
bestv = distv
elif distv == bestv:
best.append(dist)
if best:
best.sort()
version = best[-1].version
if version:
requirement = '=='.join((requirement, version))
cmd.append(requirement)
import subprocess
if subprocess.call(cmd, env=dict(os.environ, PYTHONPATH=setuptools_path)) != 0:
raise Exception(
"Failed to execute command:\n%s",
repr(cmd)[1:-1])
######################################################################
# Import and run buildout
ws.add_entry(tmpeggs)
ws.require(requirement)
import zc.buildout.buildout
if not [a for a in args if '=' not in a]:
args.append('bootstrap')
# if -c was provided, we push it back into args for buildout' main function
if options.config_file is not None:
args[0:0] = ['-c', options.config_file]
zc.buildout.buildout.main(args)
shutil.rmtree(tmpeggs)

View File

@ -1,118 +0,0 @@
[buildout]
package-name = croniter
develop = .
versions=versions
parts =
scripts
omelette
coverage
report
test
report-xml
code-analysis
extensions =
mr.developer
auto-checkout =
test-eggs= ${buildout:package-name} [test]
eggs = ${buildout:package-name}
[sources]
[code-analysis]
recipe = plone.recipe.codeanalysis
directory = ${buildout:directory}/src
flake8-ignore=C901
[scripts]
recipe=zc.recipe.egg
eggs = ${buildout:eggs}
zest.releaser
ipython
tox
nose
interpreter = scripts
[test]
recipe=zc.recipe.egg
eggs = ${scripts:eggs}
croniter[test]
arguments= ['croniter']
scripts=test
entry-points=
test=nose:run_exit
[coverage]
recipe = zc.recipe.egg
eggs = coverage
initialization =
include = '--source=${buildout:directory}/src'
sys.argv = sys.argv[:] + ['run', include, 'bin/test', '--xml']
[report]
recipe = zc.recipe.egg
eggs = coverage
scripts = coverage=report
initialization =
sys.argv = sys.argv[:] + ['html', '-i']
[report-xml]
recipe = zc.recipe.egg
eggs = coverage
scripts = coverage=report-xml
initialization =
sys.argv = sys.argv[:] + ['xml', '-i']
[omelette]
recipe = collective.recipe.omelette
eggs = ${scripts:eggs}
[versions]
pytz = 2013.9
python-dateutil = 2.2
# buildout & test infra
zc.buildout = 2.2.1
zc.recipe.egg = 2.0.1
buildout-versions = 1.7
collective.recipe.omelette = 0.16
coverage = 3.7.1
ipython = 1.1.0
mr.developer = 1.28
plone.testing = 4.0.9
zc.recipe.testrunner = 2.0.0
zest.releaser = 3.50
six = 1.5.2
unittest2 = 0.5.1
zope.exceptions = 4.0.6
zope.interface = 4.0.5
zope.testing = 4.1.2
zope.testrunner = 4.4.1
zope.contentprovider = 4.0.0a1
zope.event = 4.0.2
zope.i18n = 4.0.0a4
zope.pagetemplate = 4.0.4
zope.proxy = 4.1.3
zope.publisher = 4.0.0a4
zope.schema = 4.4.0
zope.security = 4.0.0
zope.tales = 4.0.2
zope.traversing = 4.0.0a3
zptlint = 0.2.4
mccabe = 0.2.1
pep8 = 1.4.6
plone.recipe.codeanalysis = 1.0b6
pyflakes = 0.7.3
zope.contenttype = 4.0.1
zope.i18nmessageid = 4.0.2
zope.location = 4.0.2
zope.tal = 4.0.0
Unidecode = 0.04.14
flake8 = 2.1.0
i18ndude = 3.3.3
ordereddict = 1.1
plone.i18n = 2.0.9
transaction = 1.4.1
zope.browser = 2.0.2
zope.component = 4.1.0
zope.configuration = 4.0.2

View File

@ -1,9 +0,0 @@
[buildout]
extends=buildout.cfg
parts-=
omelette
code-analysis
[scripts]
eggs-=
ipython
zest.releaser

2
requirements/base.txt Normal file
View File

@ -0,0 +1,2 @@
python_dateutil
-e .

2
requirements/release.txt Normal file
View File

@ -0,0 +1,2 @@
-r base.txt
zest.releaser[recommended]>=6.7

7
requirements/test.txt Normal file
View File

@ -0,0 +1,7 @@
-r base.txt
pytz
pytest>=3.0.3
tox>=2.4.1
coverage>=4.2
mock>=2.0.0 # For Python 2
coveralls

View File

@ -1,2 +1,17 @@
[bdist_wheel]
universal = 1
[coverage:run]
source = .
branch = True
omit =
.tox/*
setup.py
**/**/tests*
**/**/test_*.py
[coverage:report]
exclude_lines =
pragma: no cover
raise AssertionError
raise NotImplementedError

View File

@ -8,6 +8,12 @@ def read(*rnames):
os.path.join('.', *rnames)
).read()
install_requires = [
a.strip()
for a in read('requirements/base.txt').splitlines()
if a.strip() and not a.startswith(('#', '-'))
]
long_description = "\n\n".join(
[
read('README.rst'),
@ -28,10 +34,7 @@ setup(
author_email='taichino@gmail.com, kiorky@cryptelium.net',
url='http://github.com/kiorky/croniter',
keywords='datetime, iterator, cron',
install_requires=[
"python-dateutil",
"setuptools",
],
install_requires=install_requires,
license="MIT License",
classifiers=[
"Development Status :: 4 - Beta",
@ -45,9 +48,4 @@ setup(
packages=find_packages('src'),
package_dir={'': 'src'},
include_package_data=True,
extras_require={
'test': [
"pytz",
],
},
)

22
tox.ini Normal file
View File

@ -0,0 +1,22 @@
[tox]
minversion = 2.3
envlist =
{py26,py27,py34,py35}-std
py27-coverage
skipsdist = true
[testenv]
usedevelop = true
deps =
-r{toxinidir}/requirements/test.txt
whitelist_externals = /bin/sh
setenv =
COVERAGE_FILE={envdir}/coverage_report
changedir = src
commands =
{py26,py27,py34,py35}-std: py.test -v .
py27-coverage: coverage erase
py27-coverage: sh -c 'cd .. && coverage run $(which py.test) -v src'
py27-coverage: coverage report