forked from extern/httpie-cli
Switch to explicitly listed directories to search in for *.rst
#820
This commit is contained in:
parent
c82d9b629f
commit
5aa9ed795e
@ -1,12 +1,19 @@
|
|||||||
import os
|
import os
|
||||||
import fnmatch
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from glob import glob
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from utils import TESTS_ROOT
|
from utils import TESTS_ROOT
|
||||||
|
|
||||||
|
|
||||||
|
SOURCE_DIRECTORIES = [
|
||||||
|
'extras',
|
||||||
|
'httpie',
|
||||||
|
'tests',
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def has_docutils():
|
def has_docutils():
|
||||||
try:
|
try:
|
||||||
# noinspection PyUnresolvedReferences,PyPackageRequirements
|
# noinspection PyUnresolvedReferences,PyPackageRequirements
|
||||||
@ -17,25 +24,29 @@ def has_docutils():
|
|||||||
|
|
||||||
|
|
||||||
def rst_filenames():
|
def rst_filenames():
|
||||||
# noinspection PyShadowingNames
|
cwd = os.getcwd()
|
||||||
for root, dirnames, filenames in os.walk(os.path.dirname(TESTS_ROOT)):
|
os.chdir(TESTS_ROOT.parent)
|
||||||
if '.tox' not in root and 'site-packages' not in root:
|
try:
|
||||||
for filename in fnmatch.filter(filenames, '*.rst'):
|
yield from glob('*.rst')
|
||||||
yield os.path.join(root, filename)
|
for directory in SOURCE_DIRECTORIES:
|
||||||
|
yield from glob(f'{directory}/**/*.rst', recursive=True)
|
||||||
|
finally:
|
||||||
|
os.chdir(cwd)
|
||||||
|
|
||||||
|
|
||||||
filenames = list(rst_filenames())
|
filenames = list(sorted(rst_filenames()))
|
||||||
assert filenames
|
assert filenames
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(not has_docutils(), reason='docutils not installed')
|
@pytest.mark.skipif(not has_docutils(), reason='docutils not installed')
|
||||||
@pytest.mark.parametrize('filename', filenames)
|
@pytest.mark.parametrize('filename', filenames)
|
||||||
def test_rst_file_syntax(filename):
|
def test_rst_file_syntax(filename):
|
||||||
|
print(filename)
|
||||||
p = subprocess.Popen(
|
p = subprocess.Popen(
|
||||||
['rst2pseudoxml.py', '--report=1', '--exit-status=1', filename],
|
['rst2pseudoxml.py', '--report=1', '--exit-status=1', filename],
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
shell=True
|
shell=True,
|
||||||
)
|
)
|
||||||
err = p.communicate()[1]
|
err = p.communicate()[1]
|
||||||
assert p.returncode == 0, err.decode('utf8')
|
assert p.returncode == 0, err.decode('utf8')
|
||||||
|
@ -14,7 +14,7 @@ from httpie.context import Environment
|
|||||||
from httpie.core import main
|
from httpie.core import main
|
||||||
|
|
||||||
|
|
||||||
TESTS_ROOT = os.path.abspath(os.path.dirname(__file__))
|
TESTS_ROOT = Path(__file__).parent
|
||||||
CRLF = '\r\n'
|
CRLF = '\r\n'
|
||||||
COLOR = '\x1b['
|
COLOR = '\x1b['
|
||||||
HTTP_OK = '200 OK'
|
HTTP_OK = '200 OK'
|
||||||
|
Loading…
Reference in New Issue
Block a user