1
0
mirror of https://github.com/httpie/cli.git synced 2024-11-24 08:22:22 +02:00
httpie-cli/tests/test_docs.py
Roger Wernersson e8b22d8b51 exclude site-packages from .rst file scanning (#820)
make test fails when finding .rst files from site packages installed
in the virtual environment
2019-12-04 13:37:57 +01:00

42 lines
1.0 KiB
Python

import os
import fnmatch
import subprocess
import pytest
from utils import TESTS_ROOT
def has_docutils():
try:
# noinspection PyUnresolvedReferences,PyPackageRequirements
import docutils
return True
except ImportError:
return False
def rst_filenames():
# noinspection PyShadowingNames
for root, dirnames, filenames in os.walk(os.path.dirname(TESTS_ROOT)):
if '.tox' not in root and 'site-packages' not in root:
for filename in fnmatch.filter(filenames, '*.rst'):
yield os.path.join(root, filename)
filenames = list(rst_filenames())
assert filenames
@pytest.mark.skipif(not has_docutils(), reason='docutils not installed')
@pytest.mark.parametrize('filename', filenames)
def test_rst_file_syntax(filename):
p = subprocess.Popen(
['rst2pseudoxml.py', '--report=1', '--exit-status=1', filename],
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
shell=True
)
err = p.communicate()[1]
assert p.returncode == 0, err.decode('utf8')