tests/test-check-pyflakes.t
author Anton Shestakov <av6@dwimlabs.net>
Sat, 06 Jun 2020 19:12:49 +0800
branchstable
changeset 44958 f9099e210c57
parent 44957 1ca0d5cae9bc
child 44959 170f8a43b5b8
permissions -rw-r--r--
tests: consistently use pyflakes as a Python module We check availability of pyflakes as a module, and also running it for real as a module. Only fair to test filterpyflakes.py working correctly when using pyflakes as a module too. This is a graft of a similar fix that ended up on default. Differential Revision: https://phab.mercurial-scm.org/D8629

#require test-repo pyflakes hg10

  $ . "$TESTDIR/helpers-testrepo.sh"

run pyflakes on all tracked files ending in .py or without a file ending
(skipping binary file random-seed)

  $ cat > test.py <<EOF
  > print(undefinedname)
  > EOF
  $ $PYTHON -m pyflakes test.py 2>/dev/null | "$TESTDIR/filterpyflakes.py"
  test.py:1: undefined name 'undefinedname'
  
  $ cd "`dirname "$TESTDIR"`"

  $ testrepohg locate 'set:**.py or grep("^#!.*python")' \
  > -X hgext/fsmonitor/pywatchman \
  > -X mercurial/pycompat.py -X contrib/python-zstandard \
  > -X mercurial/thirdparty \
  > 2>/dev/null \
  > | xargs $PYTHON -m pyflakes 2>/dev/null | "$TESTDIR/filterpyflakes.py"
  contrib/perf.py:*: undefined name 'xrange' (glob) (?)
  mercurial/hgweb/server.py:*: undefined name 'reload' (glob) (?)
  mercurial/util.py:*: undefined name 'file' (glob) (?)
  mercurial/encoding.py:*: undefined name 'localstr' (glob) (?)