diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..54c66a0 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,9 @@ +[run] +source = zope.size + +[report] +exclude_lines = + pragma: no cover + if __name__ == '__main__': + raise NotImplementedError + self.fail diff --git a/.gitignore b/.gitignore index 6471d6c..605e07a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,5 +10,6 @@ bin build develop-eggs parts - +.coverage +htmlcov/ docs/_build/ diff --git a/.travis.yml b/.travis.yml index 2428b54..26ae120 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,14 +2,19 @@ language: python sudo: false python: - 2.7 - - 3.3 - 3.4 - 3.5 + - 3.6 - pypy - - pypy3 + - pypy3.5-5.8.0 install: - - pip install . + - pip install -U pip setuptools + - pip install -U coverage coveralls + - pip install -U -e .[test] script: - - python setup.py test -q + - coverage run setup.py -q test -q +after_success: + - coveralls notifications: email: false +cache: pip diff --git a/CHANGES.rst b/CHANGES.rst index 29e3a90..0ad2b4f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,9 +4,9 @@ Changes 4.2.0 (unreleased) ------------------ -- Add support for Python 3.5. +- Add support for Python 3.5 and 3.6. -- Drop support for Python 2.6 and 3.2. +- Drop support for Python 2.6, 3.2 and 3.3. 4.1.0 (2014-12-29) @@ -35,7 +35,7 @@ Changes - Add support for Python 3.2 and 3.3. -- Conditionally disable tests that require ``zope.configuration`` and +- Conditionally disable tests that require ``zope.configuration`` and ``zope.security``. diff --git a/MANIFEST.in b/MANIFEST.in index 1c92fd0..130ef25 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,15 @@ -include *.txt bootstrap.py buildout.cfg tox.ini -recursive-include src *.py *.txt *.zcml +include *.txt +include *.rst +include bootstrap.py +include buildout.cfg +include tox.ini +include .travis.yml +include .coveragerc + +recursive-include src *.py +recursive-include src *.txt +recursive-include src *.zcml + +recursive-include docs *.py +recursive-include docs *.rst +recursive-include docs Makefile diff --git a/README.rst b/README.rst index 64c2231..602447d 100644 --- a/README.rst +++ b/README.rst @@ -1,13 +1,25 @@ -``zope.size`` -============= +=============== + ``zope.size`` +=============== + +.. image:: https://img.shields.io/pypi/v/zope.size.svg + :target: https://pypi.python.org/pypi/zope.size/ + :alt: Latest release + +.. image:: https://img.shields.io/pypi/pyversions/zope.size.svg + :target: https://pypi.org/project/zope.size/ + :alt: Supported Python versions .. image:: https://travis-ci.org/zopefoundation/zope.size.png?branch=master :target: https://travis-ci.org/zopefoundation/zope.size .. image:: https://readthedocs.org/projects/zopesize/badge/?version=latest - :target: http://zopesize.readthedocs.io/en/latest/?badge=latest + :target: https://zopesize.readthedocs.io/en/latest/ :alt: Documentation Status +.. image:: https://coveralls.io/repos/github/zopefoundation/zope.size/badge.svg?branch=master + :target: https://coveralls.io/github/zopefoundation/zope.size?branch=master + This package provides a definition of simple interface that allows applications to retrieve the size of the object for displaying and for sorting. @@ -16,3 +28,5 @@ method that returns size in bytes. However, the adapter won't crash if an object doesn't have one and will show size as "not available" instead. Development is hosted at https://github.com/zopefoundation/zope.size + +Documentation is hosted at https://zopesize.readthedocs.io diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..2a9acf1 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal = 1 diff --git a/setup.py b/setup.py index 728ad89..651fa31 100644 --- a/setup.py +++ b/setup.py @@ -25,47 +25,56 @@ def read(*rnames): with open(os.path.join(os.path.dirname(__file__), *rnames)) as f: return f.read() +ZCML_REQUIRES = [ + 'zope.component[zcml]', + 'zope.configuration', + 'zope.security[zcml]', +] + +TESTS_REQUIRE = ZCML_REQUIRES + setup(name='zope.size', - version=read('version.txt'), - url='http://zopesize.readthedocs.io', + version=read('version.txt').strip(), + url='http://github.com/zopefoundation/zope.size', license='ZPL 2.1', description=\ 'Interfaces and simple adapter that give the size of an object', + keywords="size display human bytes", author='Zope Foundation and Contributors', author_email='zope-dev@zope.org', long_description=read('README.rst') + '\n\n' + read('CHANGES.rst'), classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: Zope Public License', - 'Programming Language :: Python', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: Implementation :: CPython', - 'Programming Language :: Python :: Implementation :: PyPy', - 'Natural Language :: English', - 'Operating System :: OS Independent', - 'Topic :: Internet :: WWW/HTTP', - 'Topic :: Software Development', - ], + 'Development Status :: 5 - Production/Stable', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: Zope Public License', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: Implementation :: CPython', + 'Programming Language :: Python :: Implementation :: PyPy', + 'Natural Language :: English', + 'Operating System :: OS Independent', + 'Topic :: Internet :: WWW/HTTP', + 'Topic :: Software Development', + ], packages=find_packages('src'), - package_dir = {'': 'src'}, + package_dir={'': 'src'}, namespace_packages=['zope'], - tests_require = [], + tests_require=TESTS_REQUIRE, test_suite='zope.size.tests.test_suite', - extras_require=dict( - zcml=[ - 'zope.component[zcml]', - 'zope.configuration', - 'zope.security[zcml]', - ]), - install_requires=['setuptools', - 'zope.interface', - 'zope.i18nmessageid'], - include_package_data = True, - zip_safe = False, - ) + extras_require={ + 'zcml': ZCML_REQUIRES, + 'test': TESTS_REQUIRE, + }, + install_requires=[ + 'setuptools', + 'zope.interface', + 'zope.i18nmessageid', + ], + include_package_data=True, + zip_safe=False, +) diff --git a/src/zope/__init__.py b/src/zope/__init__.py index de40ea7..2cdb0e4 100644 --- a/src/zope/__init__.py +++ b/src/zope/__init__.py @@ -1 +1 @@ -__import__('pkg_resources').declare_namespace(__name__) +__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover diff --git a/src/zope/size/tests.py b/src/zope/size/tests.py index 3456050..01267f0 100644 --- a/src/zope/size/tests.py +++ b/src/zope/size/tests.py @@ -18,11 +18,8 @@ from zope.size.interfaces import ISized import zope.size -try: - import zope.component - import zope.configuration.xmlconfig -except: - pass +import zope.component +import zope.configuration.xmlconfig class ZCMLTest(unittest.TestCase): @@ -31,7 +28,7 @@ def test_configure_zcml_should_be_loadable(self): try: zope.configuration.xmlconfig.XMLConfig( 'configure.zcml', zope.size)() - except Exception as e: + except Exception as e: # pragma: no cover self.fail(e) def test_configure_should_register_n_components(self): @@ -117,11 +114,4 @@ def test_byteDisplay(self): def test_suite(): - tests = [Test] - try: - import zope.configuration - tests.append(ZCMLTest) - except: - pass - - return unittest.TestSuite([unittest.makeSuite(cls) for cls in tests]) + return unittest.defaultTestLoader.loadTestsFromName(__name__) diff --git a/tox.ini b/tox.ini index 37e3d08..1e5cacd 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,19 @@ [tox] -envlist = py27,py33,py34,py35,pypy,pypy3 +envlist = py27,py34,py35,py36,pypy,pypy3 [testenv] -commands = python setup.py -q test -q -deps = zope.testrunner +commands = + python setup.py -q test -q +deps = + .[test] + +[testenv:coverage] +usedevelop = true +basepython = + python2.7 +commands = + coverage run setup.py -q test -q + coverage report --fail-under=100 +deps = + {[testenv]deps} + coverage