Skip to content

Commit ab79042

Browse files
committed
Reorganize package structure. Use coverage in tox.ini
1 parent d5e5216 commit ab79042

8 files changed

+83
-26
lines changed

.gitignore

+14-12
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,20 @@
33
# Packages
44
*.egg
55
*.egg-info
6-
/dist
7-
/build
8-
/eggs
9-
/parts
10-
/bin
11-
/var
12-
/sdist
13-
/develop-eggs
6+
/.eggs/
7+
/dist/
8+
/build/
9+
/eggs/
10+
/parts/
11+
/bin/
12+
/var/
13+
/sdist/
14+
/develop-eggs/
15+
/lib/
16+
/lib64/
17+
/include/
18+
/local/
1419
/.installed.cfg
15-
/lib
16-
/lib64
17-
/include
18-
/local
1920

2021
# Installer logs
2122
/pip-selfcheck.json
@@ -25,6 +26,7 @@
2526
/.coverage
2627
/.tox
2728
/nosetests.xml
29+
/coverage_html/
2830

2931
# Sphinx docs
3032
/doc/_build

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ python:
99
- "3.5"
1010
- "pypy"
1111

12-
script: python mpd_test.py
12+
script: python -m unittest mpd.tests

mpd/__init__.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# python-mpd2: Python MPD client library
2+
#
3+
# Copyright (C) 2008-2010 J. Alexander Treuman <[email protected]>
4+
# Copyright (C) 2012 J. Thalheim <[email protected]>
5+
# Copyright (C) 2016 Robert Niederreiter <[email protected]>
6+
#
7+
# python-mpd2 is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU Lesser General Public License as published by
9+
# the Free Software Foundation, either version 3 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# python-mpd2 is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU Lesser General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU Lesser General Public License
18+
# along with python-mpd2. If not, see <http://www.gnu.org/licenses/>.
19+
20+
from mpd.base import CommandError
21+
from mpd.base import CommandListError
22+
from mpd.base import ConnectionError
23+
from mpd.base import IteratingError
24+
from mpd.base import MPDClient
25+
from mpd.base import MPDError
26+
from mpd.base import PendingCommandError
27+
from mpd.base import ProtocolError
28+
from mpd.base import VERSION
29+

mpd.py mpd/base.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# python-mpd2: Python MPD client library
2+
#
23
# Copyright (C) 2008-2010 J. Alexander Treuman <[email protected]>
34
# Copyright (C) 2012 J. Thalheim <[email protected]>
5+
# Copyright (C) 2016 Robert Niederreiter <[email protected]>
46
#
57
# python-mpd2 is free software: you can redistribute it and/or modify
68
# it under the terms of the GNU Lesser General Public License as published by

mpd_test.py mpd/tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class TestMPDClient(unittest.TestCase):
3939
longMessage = True
4040

4141
def setUp(self):
42-
self.socket_patch = mock.patch("mpd.socket")
42+
self.socket_patch = mock.patch("mpd.base.socket")
4343
self.socket_mock = self.socket_patch.start()
4444
self.socket_mock.getaddrinfo.return_value = [range(5)]
4545

setup.cfg

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[sdist]
2-
formats=bztar,gztar,zip
2+
formats = bztar,gztar,zip
33

44
[build_sphinx]
55
source-dir = doc/
@@ -8,3 +8,6 @@ all_files = 1
88

99
[upload_sphinx]
1010
upload-dir = doc/_build/html
11+
12+
[easy_install]
13+

setup.py

+22-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
#! /usr/bin/env python
22

3-
from distutils.core import setup
43
from setuptools import Extension
4+
from setuptools import find_packages
5+
from setuptools import setup
56
from setuptools.command.test import test as TestCommand
6-
import sys,os
77
import mpd
8+
import os
9+
import sys
10+
811

912
if sys.version_info[0] == 2:
1013
from io import open
1114

15+
16+
VERSION = ".".join(map(str, mpd.VERSION))
17+
1218
CLASSIFIERS = [
1319
"Development Status :: 5 - Production/Stable",
1420
"Intended Audience :: Developers",
@@ -23,6 +29,7 @@
2329
LICENSE = """\
2430
Copyright (C) 2008-2010 J. Alexander Treuman <[email protected]>
2531
Copyright (C) 2012 J. Thalheim <[email protected]>
32+
Copyright (C) 2016 Robert Niederreiter <[email protected]>
2633
2734
python-mpd2 is free software: you can redistribute it and/or modify
2835
it under the terms of the GNU Lesser General Public License as published by
@@ -36,37 +43,43 @@
3643
along with python-mpd2. If not, see <http://www.gnu.org/licenses/>.\
3744
"""
3845

46+
3947
class Tox(TestCommand):
48+
4049
def finalize_options(self):
4150
TestCommand.finalize_options(self)
4251
self.test_args = []
4352
self.test_suite = True
53+
4454
def run_tests(self):
4555
#import here, cause outside the eggs aren't loaded
4656
import tox
4757
errno = tox.cmdline(self.test_args)
4858
sys.exit(errno)
4959

60+
5061
def read(fname):
51-
return open(os.path.join(os.path.dirname(__file__), fname), encoding="utf8").read()
62+
with open(os.path.join(os.path.dirname(__file__), fname),
63+
encoding="utf8") as fd:
64+
return fd.read()
5265

53-
VERSION = ".".join(map(str, mpd.VERSION))
5466

5567
setup(
5668
name="python-mpd2",
5769
version=VERSION,
5870
description="A Python MPD client library",
5971
long_description=read('README.rst'),
72+
classifiers=CLASSIFIERS,
6073
author="J. Thalheim",
6174
author_email="[email protected]",
75+
license="GNU Lesser General Public License v3 (LGPLv3)",
6276
url="https://github.com/Mic92/python-mpd2",
63-
download_url="https://github.com/Mic92/python-mpd2/archive/v%s.zip" % VERSION,
64-
py_modules=["mpd", "mpd_test"],
65-
classifiers=CLASSIFIERS,
66-
#license=LICENSE,
77+
packages=find_packages(),
78+
zip_safe=True,
6779
keywords=["mpd"],
80+
test_suite="mpd.tests",
6881
tests_require=['tox'],
69-
cmdclass = {'test': Tox},
82+
cmdclass={'test': Tox}
7083
)
7184

7285
# vim: set expandtab shiftwidth=4 softtabstop=4 textwidth=79:

tox.ini

+10-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,17 @@ envlist = py26,py27,py32,py33,py34,py35,pypy
33

44
[testenv]
55
deps = mock
6-
commands = python mpd_test.py
6+
coverage
7+
commands = coverage erase
8+
coverage run mpd/tests.py
9+
coverage report
10+
coverage html -d coverage_html/{envname}
711

812
[testenv:py26]
913
deps = mock
1014
unittest2
11-
commands = python mpd_test.py
15+
coverage
16+
commands = coverage erase
17+
coverage run mpd/tests.py
18+
coverage report
19+
coverage html -d coverage_html/{envname}

0 commit comments

Comments
 (0)