Putting It All TogetherΒΆ
Our whole package, for reference, looks like this:
funniest/
funniest/
__init__.py
command_line.py
tests/
__init__.py
test_joke.py
test_command_line.py
MANIFEST.in
README.rst
setup.py
.gitignore
Here is the contents of each file:
funniest/__init__.py
from markdown import markdown
def joke():
return markdown(u'Wenn ist das Nunst\u00fcck git und Slotermeyer?'
u'Ja! ... **Beiherhund** das Oder die Flipperwaldt '
u'gersput.')
funniest/command_line.py
from . import joke
def main():
print joke()
funniest/tests/__init__.py
(empty)
funniest/tests/test_joke.py
from unittest import TestCase
import funniest
class TestJoke(TestCase):
def test_is_string(self):
s = funniest.joke()
self.assertTrue(isinstance(s, basestring))
funniest/tests/test_command_line.py
from unittest import TestCase
from funniest.command_line import main
class TestCmd(TestCase):
def test_basic(self):
main()
MANIFEST.in
include README.rst
README.rst
setup.py
from setuptools import setup
def readme():
with open('README.rst') as f:
return f.read()
setup(name='foo-test',
version='0.1',
description='The funniest joke in the world',
long_description=readme(),
classifiers=[
'Development Status :: 3 - Alpha',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 2.7',
'Topic :: Text Processing :: Linguistic',
],
keywords='funniest joke comedy flying circus',
url='http://github.com/storborg/funniest',
author='Foo',
author_email='foo@example.com',
license='MIT',
packages=['funniest'],
install_requires=[
'markdown',
],
test_suite='nose.collector',
tests_require=['nose', 'nose-cover3'],
entry_points={
'console_scripts': ['funniest-joke=funniest.command_line:main'],
},
include_package_data=True,
zip_safe=False)
.gitignore
# Compiled python modules.
*.pyc
# Setuptools distribution folder.
/dist/
# Python egg metadata, regenerated from source files by setuptools.
/*.egg-info
/*.egg