1
0
mirror of https://github.com/httpie/cli.git synced 2024-11-24 08:22:22 +02:00

Added README reStructuredText validation.

This commit is contained in:
Jakub Roztocil 2012-08-07 17:15:06 +02:00
parent 22a10aec4a
commit 76feea2f68
2 changed files with 33 additions and 4 deletions

View File

@ -910,7 +910,7 @@ Please run the existing suite of tests before a pull request is submitted:
tox
Don't forget to add yourself to `AUTHORS`_.
Don't forget to add yourself to `AUTHORS.rst`_.
=======
@ -1016,5 +1016,5 @@ Changelog
.. _0.2.7: https://github.com/jkbr/httpie/compare/0.2.5...0.2.7
.. _0.2.8dev: https://github.com/jkbr/httpie/compare/0.2.7...master
.. _README for stable version: https://github.com/jkbr/httpie/tree/0.2.7#readme
.. _AUTHORS: https://github.com/jkbr/httpie/blob/master/AUTHORS.rst
.. _AUTHORS.rst: https://github.com/jkbr/httpie/blob/master/AUTHORS.rst
.. _LICENSE: https://github.com/jkbr/httpie/blob/master/LICENSE

View File

@ -19,13 +19,13 @@ To make it run faster and offline you can::
HTTPBIN_URL=http://localhost:5000 tox
"""
import subprocess
import os
import sys
import json
import argparse
import tempfile
import unittest
from requests import __version__ as requests_version
try:
from urllib.request import urlopen
except ImportError:
@ -41,7 +41,7 @@ except ImportError:
return test_method
return decorator
from requests import __version__ as requests_version
from requests.compat import is_windows, is_py26, bytes, str
@ -115,6 +115,26 @@ class TestEnvironment(Environment):
super(TestEnvironment, self).__init__(**kwargs)
def has_docutils():
try:
#noinspection PyUnresolvedReferences
import docutils
return True
except ImportError:
return False
def get_readme_errors():
p = subprocess.Popen([
'rst2pseudoxml.py',
'--report=1',
'--exit-status=1',
os.path.join(TESTS_ROOT, '..', 'README.rst')
], stderr=subprocess.PIPE, stdout=subprocess.PIPE)
err = p.communicate()[1]
if p.returncode:
return err
class BytesResponse(bytes):
stderr = json = exit_status = None
class StrResponse(str):
@ -1131,6 +1151,15 @@ class ArgumentParserTestCase(unittest.TestCase):
])
class READMETest(BaseTestCase):
@skipIf(not has_docutils(), 'docutils not installed')
def test_README_reStructuredText_valid(self):
errors = get_readme_errors()
self.assertFalse(errors, msg=errors)
if __name__ == '__main__':
#noinspection PyCallingNonCallable
unittest.main()