diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..2cf5b1f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +language: python +python: + - 2.7 +install: + - pip install -e . + - pip install coveralls +script: + - python setup.py test --coverage --pep8 --flakes + - coverage run --source=pylmod setup.py test +after_success: + coveralls diff --git a/pylmod/__init__.py b/pylmod/__init__.py index 7554ab2..51142f2 100644 --- a/pylmod/__init__.py +++ b/pylmod/__init__.py @@ -2,9 +2,24 @@ """ PyLmod is a module that implements MIT Learning Modules API in python """ +import os.path +from pkg_resources import get_distribution, DistributionNotFound from pylmod.client import Client from pylmod.stellargradebook import StellarGradeBook -VERSION = "0.1.0" # pragma: no cover + +try: + _dist = get_distribution('pylmod') + # Normalize case for Windows systems + dist_loc = os.path.normcase(_dist.location) + here = os.path.normcase(__file__) + if not here.startswith(os.path.join(dist_loc, 'pylmod')): + # not installed, but there is another version that *is* + raise DistributionNotFound +except DistributionNotFound: + __version__ = 'Please install this project with setup.py' +else: + __version__ = _dist.version + __all__ = ['Client', 'StellarGradeBook', ] diff --git a/pylmod/tests/__init__.py b/pylmod/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pylmod/tests/test_module.py b/pylmod/tests/test_module.py new file mode 100644 index 0000000..2b2fa94 --- /dev/null +++ b/pylmod/tests/test_module.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +""" +Testing of the module level stuff itself +""" +import unittest + +import semantic_version + + +class TestModule(unittest.TestCase): + """ + Test core module features, like asserting the version + and making sure we are exposing our classes + """ + + def test_version(self): + """ + Verify we have a valid semantic version + """ + import pylmod + semantic_version.Version(pylmod.__version__) + + def test_client_classes(self): + """ + Assert that Client is available from the base module + """ + import pylmod + self.assertTrue('Client' in dir(pylmod)) diff --git a/setup.py b/setup.py index 3ee994c..49ad802 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,12 @@ import sys -from setuptools import setup +from setuptools import setup, find_packages from setuptools.command.test import test as testcommand +with open('test_requirements.txt') as test_reqs: + tests_require = test_reqs.readlines(), + class PyTest(testcommand): user_options = testcommand.user_options[:] @@ -47,35 +50,28 @@ def run_tests(self): sys.exit(errno) -extra = dict(test_suite="pylmod.tests", - tests_require=["pytest-cov>=1.8.0", "pytest-pep8>=1.0.6", - "pytest-flakes>=0.2", "pytest>=2.6.3", - "pyflakes>=0.8.1", "pytest-cache>=1.0", - "httpretty>=0.8.3", "semantic_version>=2.3.1", - ], - cmdclass={"test": PyTest}, - install_requires=["requests>=2.5.1", ], - include_package_data=True, - zip_safe=True) - -VERSION = __import__('pylmod').VERSION - README = open('README.rst').read() setup( name='pylmod', - version=VERSION, + version='0.1.0', license='BSD', author='MIT ODL Engineering', author_email='odl-engineering@mit.edu', url="http://github.com/mitodl/pylmod", description="PyLmod is a Python Implementation of MIT Learning Modules", long_description=README, + packages=find_packages(), + install_requires=["requests>=2.5.1", ], classifiers=[ 'Development Status :: 2 - Pre-Alpha', 'Intended Audience :: Developers', 'Intended Audience :: Education', 'Programming Language :: Python', ], - **extra + test_suite="pylmod.tests", + tests_require=tests_require, + cmdclass={"test": PyTest}, + include_package_data=True, + zip_safe=True, ) diff --git a/test_requirements.txt b/test_requirements.txt new file mode 100644 index 0000000..b757493 --- /dev/null +++ b/test_requirements.txt @@ -0,0 +1,8 @@ +pytest-cov>=1.8.0 +pytest-pep8>=1.0.6, +pytest-flakes>=0.2, +pytest>=2.6.3, +pyflakes>=0.8.1, +pytest-cache>=1.0, +httpretty>=0.8.3, +semantic_version>=2.3.1