Skip to content

Instantly share code, notes, and snippets.

@terryjbates
Last active April 25, 2017 23:28
Show Gist options
  • Save terryjbates/5904f43072041234cf5d825c99a40f80 to your computer and use it in GitHub Desktop.
Save terryjbates/5904f43072041234cf5d825c99a40f80 to your computer and use it in GitHub Desktop.
Notes on creating a pep257 test function
# -*- coding: utf-8 -*-
"""Use tox or py.test to run the test-suite. Lifted straight from pydocstyle/test_integration.py."""
from __future__ import with_statement
from collections import namedtuple
import os
import sys
import mock
import shlex
import shutil
import pytest
import pathlib
import tempfile
import textwrap
import subprocess
from pydocstyle import checker, violations
__all__ = ()
requests.packages.urllib3.disable_warnings()
def test_pep257_conformance():
"""Test that we conform to PEP 257."""
base_dir = (pathlib.Path(__file__).parent / '..').resolve()
src_dirs = (base_dir, base_dir / 'tests')
src_files = []
for src_dir in src_dirs:
src_files.extend(str(path) for path in src_dir.glob('*.py'))
ignored = {'D104', 'D105'}
select = violations.conventions.pep257 - ignored
errors = list(checker.check(src_files, select=select))
assert errors == [], errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment