Skip to content

Commit

Permalink
Merge b16a78b into c2077da
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Howitz committed Feb 21, 2019
2 parents c2077da + b16a78b commit b9b2047
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 32 deletions.
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ python:
- 3.5
- 3.6
- pypy-5.6.0
matrix:
include:
- python: 3.6
name: "Flake8"
install: pip install -U flake8
script: flake8 --doctests src setup.py
after_success:
script:
- COVERAGE_PROCESS_START=.coveragerc coverage run -m zope.testrunner --test-path=src -vv

Expand Down
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
2.0.1 (unreleased)
==================

- Nothing changed yet.
- Flake8 the code.


2.0.0 (2017-06-21)
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
import os
from setuptools import setup, find_packages


def read(*rnames):
with open(os.path.join(os.path.dirname(__file__), *rnames)) as f:
return f.read()


name = "zc.recipe.cmmi"

setup(
Expand Down
2 changes: 1 addition & 1 deletion src/zc/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover
__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover
2 changes: 1 addition & 1 deletion src/zc/recipe/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover
__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover
14 changes: 8 additions & 6 deletions src/zc/recipe/cmmi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@
almost_environment_setting = re.compile(r'\w+=').match
not_starting_with_digit = re.compile(r'\D').match


def system(c):
subprocess.check_call(c, shell=True)


class Recipe(object):

def __init__(self, buildout, name, options):
Expand All @@ -52,7 +54,7 @@ def __init__(self, buildout, name, options):
environ = []
for token in self.options.get('environment', '').split():
if (almost_environment_setting(token) and
not_starting_with_digit(token)):
not_starting_with_digit(token)):
environ.append(token)
else:
if environ:
Expand Down Expand Up @@ -93,15 +95,15 @@ def __init__(self, buildout, name, options):
location = self.shared
else:
location = os.path.join(options.get(
'location', buildout['buildout']['parts-directory']), name)
'location', buildout['buildout']['parts-directory']), name)

options['location'] = location

def _state_hash(self):
# hash of our configuration state, so that e.g. different
# ./configure options will get a different build directory.
# Be sure to sort to keep a consistent order, since dictionary iteration order
# is never guaranteed.
# Be sure to sort to keep a consistent order, since dictionary
# iteration order is never guaranteed.
env = ''.join(['%s%s' % (key, value) for key, value
in sorted(self.environ.items())])
state = [self.url, self.extra_options, self.autogen,
Expand Down Expand Up @@ -174,7 +176,7 @@ def build(self):
self.patch, is_temp = download(
self.patch,
md5sum=self.options.get('patch-md5sum'))
except:
except Exception:
# If download/checksum of the patch fails, leaving
# the tmp dir won't be helpful.
shutil.rmtree(tmp)
Expand All @@ -198,7 +200,7 @@ def build(self):
shutil.rmtree(tmp)
finally:
os.chdir(here)
except:
except Exception:
shutil.rmtree(dest)
if os.path.exists(tmp):
logger.error("cmmi failed: %s", tmp)
Expand Down
44 changes: 22 additions & 22 deletions src/zc/recipe/cmmi/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@
import unittest
import doctest
from zope.testing import renormalizing
from zc.buildout.tests import easy_install_SetUp
from zc.buildout.tests import normalize_bang


def _as_bytes(s):
return s.encode('utf-8') if not isinstance(s, bytes) else s


def BytesIO(s):
return _BytesIO(_as_bytes(s))


def setUp(test):
zc.buildout.testing.buildoutSetUp(test)
zc.buildout.testing.install_develop('zc.recipe.cmmi', test)
Expand Down Expand Up @@ -66,16 +68,11 @@ def setUp(test):
info.mode = 0o755
tar.addfile(info, BytesIO(configure))


def tearDown(test):
zc.buildout.testing.buildoutTearDown(test)


def add(tar, name, src, mode=None):
info.size = len(src)
if mode is not None:
info.mode = mode
tar.addfile(info, BytesIO(src))

configure_template = """#!%s
import sys
print("configuring foo " + ' '.join(sys.argv[1:]))
Expand Down Expand Up @@ -111,14 +108,16 @@ def test_suite():
'http://localhost/'),
(re.compile('occured'), 'occurred'),
# Buildout or setuptools has a bug not closing .egg-link files,
# leading to issues being reported by PyPy, which naturally mess up
# doctests.
(re.compile('Exception IOError: IOError.*finalizer of <closed file.*'),
''),
# IGNORE_EXCEPTION_MODULE_IN_PYTHON2 fails because the output doesn't
# always look like a traceback.
(re.compile('subprocess.CalledProcessError'), 'CalledProcessError'),
]),
# leading to issues being reported by PyPy, which naturally
# mess up doctests.
(re.compile(
'Exception IOError: IOError.*finalizer of <closed file.*'),
''),
# IGNORE_EXCEPTION_MODULE_IN_PYTHON2 fails because the output
# doesn't always look like a traceback.
(re.compile('subprocess.CalledProcessError'),
'CalledProcessError'),
]),
optionflags=(doctest.ELLIPSIS
| doctest.NORMALIZE_WHITESPACE
| renormalizing.IGNORE_EXCEPTION_MODULE_IN_PYTHON2)
Expand All @@ -140,12 +139,13 @@ def test_suite():
(re.compile('extdemo[.]pyd'), 'extdemo.so'),
(re.compile('[0-9a-f]{40}'), '<BUILDID>'),
# Buildout or setuptools has a bug not closing .egg-link files,
# leading to issues being reported by PyPy, which naturally mess up
# doctests.
(re.compile('Exception IOError: IOError.*finalizer of <closed file.*'),
''),
# leading to issues being reported by PyPy, which naturally
# mess up doctests.
(re.compile(
'Exception IOError: IOError.*finalizer of <closed file.*'),
''),
]),
optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE
optionflags=doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE
),
doctest.DocFileSuite(
'misc.rst',
Expand All @@ -157,7 +157,7 @@ def test_suite():
'--prefix=/sample_buildout'),
(re.compile('http://localhost:[0-9]{4,5}/'),
'http://localhost/'),
]),
optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE
]),
optionflags=doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE
),
))
8 changes: 7 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
[tox]
envlist = py27,py34,py35,py36,pypy
envlist = flake8,py27,py34,py35,py36,pypy

[testenv]
commands =
zope-testrunner --test-path=src []
deps =
.[test]

[testenv:flake8]
basepython = python3.6
skip_install = true
deps = flake8
commands = flake8 --doctests src setup.py

0 comments on commit b9b2047

Please sign in to comment.