From 76feea2f68e7afaca156bb9b6ed9700f33a1afc0 Mon Sep 17 00:00:00 2001 From: Jakub Roztocil Date: Tue, 7 Aug 2012 17:15:06 +0200 Subject: [PATCH] Added README reStructuredText validation. --- README.rst | 4 ++-- tests/tests.py | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 5ac59d7c..7f1b97e6 100644 --- a/README.rst +++ b/README.rst @@ -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 diff --git a/tests/tests.py b/tests/tests.py index 952aa5bd..762b9a81 100755 --- a/tests/tests.py +++ b/tests/tests.py @@ -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()