Refs #35 - Fixed conversion of README from reStructuredText to HTML.

This commit is contained in:
Benoît Bryon 2013-05-28 14:40:46 +02:00
parent ce0569612b
commit 44f1ca3be3
3 changed files with 99 additions and 6 deletions

View file

@ -7,7 +7,7 @@ Changelog
Bugfixes and documentation improvements.
- Bug #34 - Improved support of files that do not implement modification time.
- Bug #35 - Fixed README conversion from reStructuredText to HTML (PyPI).
1.1 (2013-04-11)
----------------

10
README
View file

@ -15,7 +15,7 @@ proxy, via mechanisms such as Nginx's X-Accel.
Example
*******
In some :file:`urls.py`, serve files managed in a model:
In some ``urls.py``, serve files managed in a model:
.. code-block:: python
@ -30,7 +30,7 @@ In some :file:`urls.py`, serve files managed in a model:
url('^download/(?P<slug>[A-Za-z0-9_-]+)/$', download, name='download'),
)
More examples in the "demo" section!
More examples in the "demo" documentation!
*****
@ -45,10 +45,10 @@ Several views are provided to cover frequent use cases:
* ``HTTPDownloadView`` when you have an URL (the resource is proxied).
* ``VirtualDownloadView`` when you the file is generated on the fly.
See "views" section for details.
See "views" documentation for details.
See also "optimizations" documentation to get increased performances.
See also "optimizations" section to get increased performances.
**********
Ressources

93
tests/packaging.py Normal file
View file

@ -0,0 +1,93 @@
# -*- coding: utf-8 -*-
"""Tests around project's distribution and packaging."""
import os
import unittest
tests_dir = os.path.dirname(os.path.abspath(__file__))
project_dir = os.path.dirname(tests_dir)
build_dir = os.path.join(project_dir, 'var', 'docs', 'html')
class VersionTestCase(unittest.TestCase):
"""Various checks around project's version info."""
def get_version(self):
"""Return django_downloadview.__version__."""
from django_downloadview import __version__
return __version__
def test_version_present(self):
""":PEP:`396` - django_downloadview has __version__ attribute."""
try:
self.get_version()
except ImportError:
self.fail('django_downloadview package has no __version__.')
def test_version_match(self):
"""django_downloadview.__version__ matches pkg_resources info."""
try:
import pkg_resources
except ImportError:
self.fail('Cannot import pkg_resources module. It is part of '
'setuptools, which is a dependency of '
'django_downloadview.')
distribution = pkg_resources.get_distribution('django-downloadview')
installed_version = distribution.version
self.assertEqual(installed_version, self.get_version(),
'Version mismatch: django_downloadview.__version__ '
'is "%s" whereas pkg_resources tells "%s". '
'You may need to run ``make develop`` to update the '
'installed version in development environment.'
% (self.get_version(), installed_version))
def test_version_file(self):
"""django_downloadview.__version__ matches VERSION file info."""
version_file = os.path.join(project_dir, 'VERSION')
file_version = open(version_file).read().strip()
self.assertEqual(file_version, self.get_version(),
'Version mismatch: django_downloadview.__version__ '
'is "%s" whereas VERSION file tells "%s". '
'You may need to run ``make develop`` to update the '
'installed version in development environment.'
% (self.get_version(), file_version))
class ReadMeTestCase(unittest.TestCase):
"""Test suite around README file."""
def test_readme_build(self):
"""README builds to HTML without errors."""
# Run build.
import docutils.core
import docutils.io
source = open(os.path.join(project_dir, 'README')).read()
writer_name = 'html'
import sys
from StringIO import StringIO
stderr_backup = sys.stderr
sys.stderr = StringIO()
output, pub = docutils.core.publish_programmatically(
source=source,
source_class=docutils.io.StringInput,
source_path=None,
destination_class=docutils.io.StringOutput,
destination=None,
destination_path=None,
reader=None,
reader_name='standalone',
parser=None,
parser_name='restructuredtext',
writer=None,
writer_name=writer_name,
settings=None,
settings_spec=None,
settings_overrides=None,
config_section=None,
enable_exit_status=False)
sys.stderr = stderr_backup
errors = pub._stderr.stream.getvalue()
# Check result.
self.assertFalse(errors, "Docutils reported errors while building "
"readme content from reStructuredText to "
"HTML. So PyPI would display the readme as "
"text instead of HTML. Errors are:\n%s"
% errors)