Skip to content

Commit

Permalink
Changed setup.py to support the test command. You can now run tests via
Browse files Browse the repository at this point in the history
    python setup.py test

Defined test suite in piwikapi/tests/__init__.py
  • Loading branch information
halfdan committed Feb 14, 2013
1 parent fcea832 commit e0d076b
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 3 deletions.
27 changes: 27 additions & 0 deletions piwikapi/tests/__init__.py
@@ -0,0 +1,27 @@
import unittest
import doctest
import sys



def all_tests_suite():
suite = unittest.TestLoader().loadTestsFromNames([
'piwikapi.tests.analytics',
'piwikapi.tests.ecommerce',
'piwikapi.tests.goals',
'piwikapi.tests.request',
'piwikapi.tests.tracking',
])
return suite

def main():
runner = unittest.TextTestRunner(verbosity=1 + sys.argv.count('-v'))
suite = all_tests_suite()
raise SystemExit(not runner.run(suite).wasSuccessful())


if __name__ == '__main__':
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
main()
29 changes: 26 additions & 3 deletions setup.py
Expand Up @@ -3,6 +3,28 @@
except ImportError:
from distutils.core import setup

from distutils.core import Extension, Command


class TestCommand(Command):
user_options = []

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
import sys, subprocess
raise SystemExit(
subprocess.call([sys.executable,
# Turn on deprecation warnings
'-Wd',
'piwikapi/tests/__init__.py']))

cmdclass = dict(test=TestCommand)
kw = dict(cmdclass=cmdclass)
setup(
name = "piwikapi",
version = "0.2.2",
Expand All @@ -12,8 +34,8 @@
long_description = open("README.rst").read(),
license = "BSD",
url = "http://github.com/nkuttler/python-piwikapi",
packages = ['piwikapi'],
include_package_data = True,
packages = ['piwikapi', 'piwikapi.tests'],
# include_package_data = True,
classifiers = [
"Development Status :: 4 - Beta",
"Environment :: Web Environment",
Expand All @@ -22,5 +44,6 @@
"Operating System :: OS Independent",
"Programming Language :: Python",
],
zip_safe = True,
**kw
# zip_safe = True,
)

0 comments on commit e0d076b

Please sign in to comment.