Permalink
Browse files

Merge pull request #18 from mcepl/clean_tests

replace testlib with good ol' unittest
  • Loading branch information...
2 parents 4381202 + d147ac2 commit 0c0965728a846aa0b9eb0724d1fce50ded5730ab @srid srid committed Mar 19, 2013
Showing with 68 additions and 825 deletions.
  1. +1 −1 MANIFEST.in
  2. +1 −5 Makefile.py
  3. +1 −1 {lib → }/appdirs.py
  4. +38 −14 setup.py
  5. 0 test/__init__.py
  6. +0 −28 test/api.doctests
  7. +0 −31 test/test.py
  8. +27 −0 test/test_api.py
  9. +0 −24 test/test_appdirs.py
  10. +0 −721 test/testlib.py
View
@@ -1,4 +1,4 @@
include README.rst
include CHANGES.rst
include LICENSE.txt
-recursive-include lib *.py
+include *.py
View
@@ -39,7 +39,7 @@ class cut_a_release(Task):
for details.
"""
proj_name = "appdirs"
- version_py_path = "lib/appdirs.py"
+ version_py_path = "appdirs.py"
version_module = "appdirs"
# XXX: this needs to be changed from .md to .rst format
@@ -163,8 +163,6 @@ def _get_next_version(self, version):
return version[:-len(str(last_bit))] + str(last_bit + 1)
def _get_version(self):
- lib_dir = join(dirname(abspath(__file__)), "lib")
- sys.path.insert(0, lib_dir)
try:
mod = __import__(self.version_module)
return mod.__version__
@@ -180,7 +178,6 @@ def make(self):
"build",
"MANIFEST",
"*.pyc",
- "lib/*.pyc",
]
for pattern in patterns:
p = join(self.dir, pattern)
@@ -201,7 +198,6 @@ def make(self):
% _setup_command_prefix(),
self.dir, self.log.debug)
- sys.path.insert(0, join(self.dir, "lib"))
url = "http://pypi.python.org/pypi/appdirs/"
import webbrowser
webbrowser.open_new(url)
@@ -11,7 +11,7 @@
# - Mac OS X: http://developer.apple.com/documentation/MacOSX/Conceptual/BPFileSystem/index.html
# - XDG spec for Un*x: http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
-__version_info__ = (1, 2, 0)
+__version_info__ = (1, 2, 1)
__version__ = '.'.join(map(str, __version_info__))
View
@@ -2,23 +2,49 @@
import sys
import os
-from setuptools import setup, find_packages
+from distutils.core import setup, Command
+import appdirs
+requires_list = []
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
+else:
+ if sys.version_info <= (2, 6):
+ requires_list.append("unittest2")
-_top_dir = os.path.dirname(os.path.abspath(__file__))
-sys.path.insert(0, os.path.join(_top_dir, "lib"))
-try:
- import appdirs
-finally:
- del sys.path[0]
-README = open(os.path.join(_top_dir, 'README.rst')).read()
-CHANGES = open(os.path.join(_top_dir, 'CHANGES.rst')).read()
+class RunTests(Command):
+ """New setup.py command to run all tests for the package.
+ """
+ description = "run all tests for the package"
+
+ user_options = []
+
+ def initialize_options(self):
+ pass
+
+ def finalize_options(self):
+ pass
+
+ def run(self):
+ tests = unittest.TestLoader().discover('.')
+ runner = unittest.TextTestRunner(verbosity=2)
+ runner.run(tests)
+
+
+def read(fname):
+ with open(os.path.join(os.path.dirname(__file__), fname)) as inf:
+ return "\n" + inf.read().replace("\r\n", "\n")
+
setup(name='appdirs',
version=appdirs.__version__,
- description='A small Python module for determining appropriate platform-specific dirs, e.g. a "user data dir".',
- long_description=README + '\n' + CHANGES,
+ description='A small Python module for determining appropriate " + \
+ "platform-specific dirs, e.g. a "user data dir".',
+ long_description=read('README.rst') + '\n' + read('CHANGES.rst'),
+ cmdclass={'test': RunTests},
classifiers=[c.strip() for c in """
Development Status :: 4 - Beta
Intended Audience :: Developers
@@ -34,6 +60,7 @@
Programming Language :: Python :: 3.2
Topic :: Software Development :: Libraries :: Python Modules
""".split('\n') if c.strip()],
+ requires=requires_list,
keywords='application directory log cache user',
author='Trent Mick',
author_email='trentm@gmail.com',
@@ -42,7 +69,4 @@
url='http://github.com/ActiveState/appdirs',
license='MIT',
py_modules=["appdirs"],
- package_dir={"": "lib"},
- include_package_data=True,
- zip_safe=False,
)
View
No changes.
View
@@ -1,28 +0,0 @@
-
->>> import appdirs
->>> hasattr(appdirs, "__version__")
-True
->>> hasattr(appdirs, "__version_info__")
-True
-
->>> type(appdirs.user_data_dir('MyApp', 'MyCompany')) == type('')
-True
->>> type(appdirs.site_data_dir('MyApp', 'MyCompany')) == type('')
-True
->>> type(appdirs.user_cache_dir('MyApp', 'MyCompany')) == type('')
-True
->>> type(appdirs.user_log_dir('MyApp', 'MyCompany')) == type('')
-True
-
-
->>> dirs = appdirs.AppDirs('MyApp', 'MyCompany', version='1.0')
->>> type(dirs.user_data_dir) == type('')
-True
->>> type(dirs.site_data_dir) == type('')
-True
->>> type(dirs.user_cache_dir) == type('')
-True
->>> type(dirs.user_log_dir) == type('')
-True
-
-
View
@@ -1,31 +0,0 @@
-#!/usr/bin/env python
-# Copyright (c) 2010 ActiveState Software Inc.
-# License: MIT (http://www.opensource.org/licenses/mit-license.php)
-
-"""The appdirs test suite entry point."""
-
-import os
-from os.path import exists, join, abspath, dirname, normpath
-import sys
-import logging
-
-import testlib
-
-log = logging.getLogger("test")
-testdir_from_ns = {
- None: os.curdir,
-}
-
-def setup():
- top_dir = dirname(dirname(abspath(__file__)))
- lib_dir = join(top_dir, "lib")
- sys.path.insert(0, lib_dir)
-
-if __name__ == "__main__":
- logging.basicConfig()
- setup()
- default_tags = []
- retval = testlib.harness(testdir_from_ns=testdir_from_ns,
- default_tags=default_tags)
- sys.exit(retval)
-
View
@@ -0,0 +1,27 @@
+import unittest
+import appdirs
+
+class Test_AppDir(unittest.TestCase):
+ def test_metadata(self):
+ self.assertTrue(hasattr(appdirs, "__version__"))
+ self.assertTrue(hasattr(appdirs, "__version_info__"))
+
+ def test_helpers(self):
+ self.assertTrue(isinstance(
+ appdirs.user_data_dir('MyApp', 'MyCompany'), str))
+ self.assertTrue(isinstance(
+ appdirs.site_data_dir('MyApp', 'MyCompany'), str))
+ self.assertTrue(isinstance(
+ appdirs.user_cache_dir('MyApp', 'MyCompany'), str))
+ self.assertTrue(isinstance(
+ appdirs.user_log_dir('MyApp', 'MyCompany'), str))
+
+ def test_dirs(self):
+ dirs = appdirs.AppDirs('MyApp', 'MyCompany', version='1.0')
+ self.assertTrue(isinstance(dirs.user_data_dir, str))
+ self.assertTrue(isinstance(dirs.site_data_dir, str))
+ self.assertTrue(isinstance(dirs.user_cache_dir, str))
+ self.assertTrue(isinstance(dirs.user_log_dir, str))
+
+if __name__=="__main__":
+ unittest.main()
View
@@ -1,24 +0,0 @@
-#!/usr/bin/env python
-# Copyright (c) 2010 ActiveState Software Inc.
-# License: MIT (http://www.opensource.org/licenses/mit-license.php)
-
-import os
-import sys
-from pprint import pprint
-import unittest
-import doctest
-
-from testlib import TestError, TestSkipped, tag
-
-
-class DocTestsTestCase(unittest.TestCase):
- def test_api(self):
- if sys.version_info[:2] < (2,4):
- raise TestSkipped("no DocFileTest in Python <=2.3")
- test = doctest.DocFileTest("api.doctests")
- test.runTest()
-
- def test_internal(self):
- import appdirs
- doctest.testmod(appdirs)
-
Oops, something went wrong.

0 comments on commit 0c09657

Please sign in to comment.