2014-04-24 14:07:31 +02:00
|
|
|
import os
|
2014-04-24 18:20:23 +02:00
|
|
|
import fnmatch
|
2014-04-24 14:07:31 +02:00
|
|
|
import subprocess
|
|
|
|
|
2014-04-24 15:17:23 +02:00
|
|
|
import pytest
|
|
|
|
|
2014-04-28 11:29:41 +02:00
|
|
|
from utils import TESTS_ROOT
|
2014-04-24 14:07:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
def has_docutils():
|
|
|
|
try:
|
2019-08-30 11:32:14 +02:00
|
|
|
# noinspection PyUnresolvedReferences,PyPackageRequirements
|
2014-04-24 14:07:31 +02:00
|
|
|
import docutils
|
|
|
|
return True
|
|
|
|
except ImportError:
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
2014-04-25 10:41:04 +02:00
|
|
|
def rst_filenames():
|
2019-08-30 11:32:14 +02:00
|
|
|
# noinspection PyShadowingNames
|
2014-04-24 18:20:23 +02:00
|
|
|
for root, dirnames, filenames in os.walk(os.path.dirname(TESTS_ROOT)):
|
|
|
|
if '.tox' not in root:
|
|
|
|
for filename in fnmatch.filter(filenames, '*.rst'):
|
|
|
|
yield os.path.join(root, filename)
|
2014-04-24 14:07:31 +02:00
|
|
|
|
|
|
|
|
2014-04-25 10:41:04 +02:00
|
|
|
filenames = list(rst_filenames())
|
|
|
|
assert filenames
|
2014-04-24 14:07:31 +02:00
|
|
|
|
2014-04-25 10:41:04 +02:00
|
|
|
|
|
|
|
@pytest.mark.skipif(not has_docutils(), reason='docutils not installed')
|
|
|
|
@pytest.mark.parametrize('filename', filenames)
|
2014-04-25 11:39:59 +02:00
|
|
|
def test_rst_file_syntax(filename):
|
2014-04-25 10:41:04 +02:00
|
|
|
p = subprocess.Popen(
|
|
|
|
['rst2pseudoxml.py', '--report=1', '--exit-status=1', filename],
|
2015-10-22 19:32:16 +02:00
|
|
|
stderr=subprocess.PIPE,
|
|
|
|
stdout=subprocess.PIPE
|
2014-04-25 10:41:04 +02:00
|
|
|
)
|
|
|
|
err = p.communicate()[1]
|
2016-03-03 10:22:12 +01:00
|
|
|
assert p.returncode == 0, err.decode('utf8')
|