Trying to add a testsuite in pytest for the tests of pydocstyle.

This commit is contained in:
Dave Halter
2017-06-04 21:10:57 +02:00
parent f13643b6cd
commit 660bbe1971
5 changed files with 50 additions and 15 deletions

View File

@@ -2,6 +2,7 @@ import tempfile
import shutil
import logging
import sys
import os
import pytest
@@ -34,6 +35,35 @@ def pytest_addoption(parser):
help="Enables the logging output.")
def pytest_generate_tests(metafunc):
if 'normalizer_issue_file' in metafunc.fixturenames:
base_dir = os.path.join(os.path.dirname(__file__), 'test', 'normalizer_issue_files')
cases = list(colllect_normalizer_tests(base_dir))
metafunc.parametrize(
'normalizer_issue_file',
cases,
ids=[c.name for c in cases]
)
class NormalizerIssueCase(object):
"""
Static Analysis cases lie in the static_analysis folder.
The tests also start with `#!`, like the goto_definition tests.
"""
def __init__(self, path):
self.path = path
self.name = os.path.basename(path)
def colllect_normalizer_tests(base_dir):
for f_name in os.listdir(base_dir):
if f_name.endswith(".py"):
path = os.path.join(base_dir, f_name)
yield NormalizerIssueCase(path)
def pytest_configure(config):
if config.option.logging:
root = logging.getLogger()