From 387220c1d67a88dde6d66e3581e6bd428cd10ed6 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Mon, 5 Jan 2015 15:52:02 -0800 Subject: [PATCH] Make pylast a package. Move tests into a directory. Start using pytest and tox. Use setuptools instead of distutils. --- .build | 1 + .travis.yml | 4 ++-- check.sh | 8 ++++---- pylast.py => pylast/__init__.py | 0 setup.py | 8 +++++--- tests/__init__.py | 0 test_pylast.py => tests/test_pylast.py | 0 tox.ini | 11 +++++++++++ 8 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 .build rename pylast.py => pylast/__init__.py (100%) create mode 100644 tests/__init__.py rename test_pylast.py => tests/test_pylast.py (100%) create mode 100644 tox.ini diff --git a/.build b/.build new file mode 100644 index 0000000..c227083 --- /dev/null +++ b/.build @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 9271b54..9efd262 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ install: - travis_retry pip install -r test_requirements.txt - travis_retry pip install coveralls -script: coverage run --source=pylast ./test_pylast.py +script: coverage run --source=pylast ./tests/test_pylast.py after_success: - coveralls @@ -24,7 +24,7 @@ after_script: - coverage report - ./check.sh - pip install clonedigger -- clonedigger pylast.py +- clonedigger pylast - grep "Clones detected" output.html - grep "lines are duplicates" output.html diff --git a/check.sh b/check.sh index 0e2c1d2..2aca7ef 100755 --- a/check.sh +++ b/check.sh @@ -1,10 +1,10 @@ -pyflakes pylast.py +pyflakes pylast echo --- -pyflakes test_pylast.py +pyflakes tests echo --- -pep8 test_pylast.py +pep8 pylast echo --- -pep8 pylast.py +pep8 tests # echo --- # clonedigger pylast.py # grep "Clones detected" output.html diff --git a/pylast.py b/pylast/__init__.py similarity index 100% rename from pylast.py rename to pylast/__init__.py diff --git a/setup.py b/setup.py index baadad3..8e73099 100755 --- a/setup.py +++ b/setup.py @@ -1,12 +1,14 @@ #!/usr/bin/env python +import os -from distutils.core import setup +from setuptools import setup, find_packages setup( name="pylast", version="1.0.0", author="Amr Hassan ", + tests_require=['mock', 'pytest', 'coverage', 'pep8', 'pyyaml', 'pyflakes'], description=("A Python interface to Last.fm " "(and other API compatible social networks)"), author_email="amr.hassan@gmail.com", @@ -24,8 +26,8 @@ setup( "Programming Language :: Python :: 3.4", ], keywords=["Last.fm", "music", "scrobble", "scrobbling"], - py_modules=("pylast",), + packages=find_packages(exclude=('tests*')), license="Apache2" - ) +) # End of file diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test_pylast.py b/tests/test_pylast.py similarity index 100% rename from test_pylast.py rename to tests/test_pylast.py diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..8565df0 --- /dev/null +++ b/tox.ini @@ -0,0 +1,11 @@ +[tox] +envlist = py34, py27 +recreate = False + +[testenv] +downloadcache = {homedir}/.pipcache +changedir = tests +deps = + pytest + mock +commands = py.test {posargs} \ No newline at end of file