On Sat, Mar 7, 2015 at 10:23 PM, Michael McNeil Forbes <michael.forbes+pyt...@gmail.com> wrote: > Dear Flake8ers, > > I am trying to run flake8 programmatically in a Test class as follows: > > import flake8.main > import nose.tools as nt > > class TestCodeFormat(object): > def setUp(self): > self.files = find_py_files(os.path.dirname(mmfutils.__file__)) > > def test_flake8_conformance(self): > # Pass in the files here so that config setup.cfg file gets found > style_guide = flake8.main.get_style_guide(paths=self.files) > result = style_guide.check_files() > nt.eq_(result.total_errors, 0, > "Found {0} code style errors (and warnings)." > .format(result.total_errors)) >
The code looks vaguely correct. I don't remember the behaviour of using get_style_guide without providing a list of default config files though (I doubt it affects this though). > The problem I am having is that there is no output when jobs > 1. This is > probably something to do with stdout flushing and multiprocessing when > running under nosetests. > > Is there any solution that will allow parallel processing with displayed > output. (I could change the error message to use result.messages or > something, but don't see an easy way of properly formatting output with > filenames and lines numbers etc.) nose may not support this usecase. > Thanks, > Michael. > > P.S. > > 1) Please let me know if I should file an issue. I thought this might be > resolved by #21 but even using the latest sources does not help. > > 2) flake8 and python setup.py flake8 both work fine, so another solution > would be if I can somehow trigger this from "python setup.py nosetests" or > "python setup.py test" but it seems to be something of a challenge to > customize setup.py commands. > > 3) Setting nose's nocapture=1 also works, but the errors then are not > deferred until the end of the tests and so can get lost. So if you do `python setup.py tests -s` then the errors will all be printed, correct? I suspect this is something to do with how flake8 defers printing and how nosetests expects to receive data on stdout. I'm not sure flake8 wants to support nose like this. _______________________________________________ code-quality mailing list code-quality@python.org https://mail.python.org/mailman/listinfo/code-quality