mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-08 13:45:01 +08:00
Trying to add a testsuite in pytest for the tests of pydocstyle.
This commit is contained in:
30
conftest.py
30
conftest.py
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user