Skip to content

Commit

Permalink
Merge pull request #18 from mcepl/clean_tests
Browse files Browse the repository at this point in the history
replace testlib with good ol' unittest
  • Loading branch information
Sridhar Ratnakumar committed Mar 19, 2013
2 parents 4381202 + d147ac2 commit 0c09657
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 825 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
@@ -1,4 +1,4 @@
include README.rst
include CHANGES.rst
include LICENSE.txt
recursive-include lib *.py
include *.py
6 changes: 1 addition & 5 deletions Makefile.py
Expand Up @@ -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
Expand Down Expand Up @@ -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__
Expand All @@ -180,7 +178,6 @@ def make(self):
"build",
"MANIFEST",
"*.pyc",
"lib/*.pyc",
]
for pattern in patterns:
p = join(self.dir, pattern)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/appdirs.py → appdirs.py
Expand Up @@ -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__))


Expand Down
52 changes: 38 additions & 14 deletions setup.py
Expand Up @@ -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
Expand All @@ -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',
Expand All @@ -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,
)
Empty file added test/__init__.py
Empty file.
28 changes: 0 additions & 28 deletions test/api.doctests

This file was deleted.

31 changes: 0 additions & 31 deletions test/test.py

This file was deleted.

27 changes: 27 additions & 0 deletions test/test_api.py
@@ -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()
24 changes: 0 additions & 24 deletions test/test_appdirs.py

This file was deleted.

0 comments on commit 0c09657

Please sign in to comment.