Skip to content

Commit

Permalink
Turn off doctest checking by default.
Browse files Browse the repository at this point in the history
  • Loading branch information
exarkun committed Feb 17, 2014
1 parent 1fc3faf commit 5207ca6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions NEWS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ UNRELEASED:
- Fix caret position on SyntaxError.
- Fix crash on Python 2.x with some doctest SyntaxError.
- Add tox.ini.
- The `PYFLAKES_NODOCTEST` environment variable has been replaced with the
`PYFLAKES_DOCTEST` environment variable (with the opposite meaning).
Doctest checking is now disabled by default; set the environment variable
to enable it.


0.7.3 (2013-07-02):
- Do not report undefined name for generator expression and dict or
Expand Down
5 changes: 3 additions & 2 deletions pyflakes/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,15 @@ class Checker(object):
nodeDepth = 0
offset = None
traceTree = False
withDoctest = ('PYFLAKES_NODOCTEST' not in os.environ)

builtIns = set(builtin_vars).union(_MAGIC_GLOBALS)
_customBuiltIns = os.environ.get('PYFLAKES_BUILTINS')
if _customBuiltIns:
builtIns.update(_customBuiltIns.split(','))
del _customBuiltIns

def __init__(self, tree, filename='(none)', builtins=None):
def __init__(self, tree, filename='(none)', builtins=None,
withDoctest='PYFLAKES_DOCTEST' in os.environ):
self._nodeHandlers = {}
self._deferredFunctions = []
self._deferredAssignments = []
Expand All @@ -248,6 +248,7 @@ def __init__(self, tree, filename='(none)', builtins=None):
self.filename = filename
if builtins:
self.builtIns = self.builtIns.union(builtins)
self.withDoctest = withDoctest
self.scopeStack = [ModuleScope()]
self.exceptHandlers = [()]
self.futuresAllowed = True
Expand Down
4 changes: 3 additions & 1 deletion pyflakes/test/harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@

class TestCase(unittest.TestCase):

withDoctest = False

def flakes(self, input, *expectedOutputs, **kw):
tree = compile(textwrap.dedent(input), "<test>", "exec", PyCF_ONLY_AST)
w = checker.Checker(tree, **kw)
w = checker.Checker(tree, withDoctest=self.withDoctest, **kw)
outputs = [type(o) for o in w.messages]
expectedOutputs = list(expectedOutputs)
outputs.sort(key=lambda t: t.__name__)
Expand Down
2 changes: 2 additions & 0 deletions pyflakes/test/test_doctests.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

class Test(TestOther, TestImports, TestUndefinedNames):

withDoctest = True

def doctestify(self, input):
lines = []
for line in textwrap.dedent(input).splitlines():
Expand Down

0 comments on commit 5207ca6

Please sign in to comment.