def test_pep257(test_case): """Run domain-specific tests from test.py file.""" case_module = __import__('test_cases.{0}'.format(test_case), globals=globals(), locals=locals(), fromlist=['expectation'], level=1) results = list( check([ os.path.join(os.path.dirname(__file__), 'test_cases', test_case + '.py') ], select=set(ErrorRegistry.get_error_codes()))) for error in results: assert isinstance(error, Error) results = set([(e.definition.name, e.message) for e in results]) assert case_module.expectation.expected == results
def test_pep257(test_case): """Run domain-specific tests from test.py file.""" case_module = __import__('test_cases.{}'.format(test_case), globals=globals(), locals=locals(), fromlist=['expectation'], level=1) test_case_dir = os.path.normcase(os.path.dirname(__file__)) test_case_file = os.path.join(test_case_dir, 'test_cases', test_case + '.py') results = list(check([test_case_file], select=set(ErrorRegistry.get_error_codes()), ignore_decorators=re.compile('wraps'))) for error in results: assert isinstance(error, Error) results = set([(e.definition.name, e.message) for e in results]) assert case_module.expectation.expected == results
def test_complex_file(test_case): """Run domain-specific tests from test.py file.""" case_module = __import__('test_cases.{}'.format(test_case), globals=globals(), locals=locals(), fromlist=['expectation'], level=1) test_case_dir = os.path.normcase(os.path.dirname(__file__)) test_case_file = os.path.join(test_case_dir, 'test_cases', test_case + '.py') results = list( check([test_case_file], select=set(ErrorRegistry.get_error_codes()), ignore_decorators=re.compile('wraps'))) for error in results: assert isinstance(error, Error) results = {(e.definition.name, e.message) for e in results} assert case_module.expectation.expected == results
def generate_error_code_table(): from pydocstyle.violations import ErrorRegistry with open(os.path.join('snippets', 'error_code_table.rst'), 'wt') as outf: outf.write(ErrorRegistry.to_rst())