diff --git a/conf.py b/conf.py index b755ff5..d8a5706 100644 --- a/conf.py +++ b/conf.py @@ -105,7 +105,7 @@ # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". -#html_title = None +html_title = 'Python Packaging Tutorial' # A shorter title for the navigation bar. Default is the same as html_title. html_short_title = 'How To Package Your Python Code' diff --git a/index.rst b/index.rst index 6ed6dac..138d858 100644 --- a/index.rst +++ b/index.rst @@ -29,10 +29,3 @@ We'll walk through the basic steps of building up a contrived package **funniest .. note:: At this time, this documentation focuses on Python 2.x only, and may not be *as* applicable to packages targeted to Python 3.x. - - -Indices -======= - -* :ref:`genindex` -* :ref:`search` diff --git a/minimal.rst b/minimal.rst index 9b12670..6b85857 100644 --- a/minimal.rst +++ b/minimal.rst @@ -56,11 +56,11 @@ The main setup config file, ``setup.py``, should contain a single call to ``setu Now we can install the package locally (for use on our system), with:: - python setup.py install + $ python setup.py install We can also install the package with a symlink, so that changes to the source files will be immediately available to other users of the package on our system:: - python setup.py develop + $ python setup.py develop Anywhere else in our system using the same Python, we can do this now:: @@ -75,7 +75,7 @@ The ``setup.py`` script is also our main entrypoint to register the package name To "register" the package (this will reserve the name, upload package metadata, and create the pypi.python.org webpage):: - python setup.py register + $ python setup.py register If you haven't published things on PyPI before, you'll need to create an account by following the steps provided at this point. @@ -87,17 +87,17 @@ Although users can follow the URL link to find our git repository, we'll probabl First create a source distribution with:: - python setup.py sdist + $ python setup.py sdist This will create ``dist/funniest-0.1.tar.gz`` inside our top-level directory. If you like, copy that file to another host and try unpacking it and install it, just to verify that it works for you. That file can then be uploaded to PyPI with:: - python setup.py upload + $ python setup.py upload You can combine all of these steps, to update metadata and publish a new build in a single step:: - python setup.py register sdist upload + $ python setup.py register sdist upload Installing the Package diff --git a/testing.rst b/testing.rst index eb6ec40..ea1e06f 100644 --- a/testing.rst +++ b/testing.rst @@ -1,6 +1,42 @@ Let There Be Tests ------------------ -.. todo:: +The **funniest** package needs some tests. These should be placed in a submodule of ``funniest.`` so that they can be imported, but won't pollute the global namespace.:: - Explain basics of configuring nose, requiring it, and using the setup.py integration. + funniest/ + funniest/ + __init__.py + tests/ + __init__.py + test_joke.py + setup.py + ... + +The ``test_joke.py`` file is our first test file. Although it's overkill for now, we'll use a ``unittest.TestCase`` subclass to provide infrastructure for later development.:: + + from unittest import TestCase + + import funniest + + class TestJoke(TestCase): + def test_is_string(self): + s = funniest.joke() + self.assertTrue(isinstance(s, basestring)) + +The best way to get these tests going (particularly if you're not sure what to use) is `Nose `_. With those files added, it's just a matter of running this from the root of the repository:: + + $ nosetests + +To integrate this with our ``setup.py``, and ensure that Nose is installed when we run the tests, we'll add a few lines to ``setup()``:: + + setup( + ... + test_suite='nose.collector', + tests_require=['nose'], + ) + +Then, to run tests, we can simply do:: + + $ python setup.py test + +Setuptools will take care of installing nose and running the test suite.