Hi Eduardo, i like the idea. A few notes:
* it's not compatible with pytest-xdist, is it? * i got BSDDB database corruption (i CTRL-Ced the run before) * can you add an example of a project layout and what one would call wrt to watch_pkg? I guess things don't work for me on pytest itself because it has a plugin-based dynamic namespace construction/imports so your AST scanning method does not really see the deps. A different method would be to try to record imports during the import and running of a test. Myself, i also experimented with specifying dependencies manually at some point which also solves the issue when invoking shell commands provided a project - i guess those would not naturally be found by your scanner. best, holger On Mon, Apr 25, 2011 at 23:40 +0800, Eduardo Schettino wrote: > Hi all, > > I have just pushed a new pytest plugin to pypi > (http://pypi.python.org/pypi/pytest-incremental). > > The idea is to execute your tests faster by executing not all of them > but only the "required" ones. > > This is very new (alpha), feedback is welcome :) > > Regards, > Eduardo > > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > > pytest-incremental > ==================== > > an incremental test runner (pytest plugin) > > > What is an "incremental test runner" ? > ======================================= > > When talking about build-tools it is common to refer to the terms: > > * initial (full) build - all files are compiled > * incremental build (or partial rebuild) - just changed files are compiled > * no-op build - no files are compiled (none changed since last execution) > > So an "incremental test runner" will only re-execute tests that were affected > by changes in the source code since last test execution. > > > How it works ? > ================ > > `pytest-incremental` is a `pytest <http://pytest.org/>`_ plugin. So if > you can run your test suite with pytest you can use > `pytest-incremental`. > > The plugin will analyse your python source files and through its > imports define the dependencies of the modules. `doit > <http://python-doit.sourceforge.net>`_ is used to keep track of the > dependencies and save results. The plugin will modify how pytest > collect your tests. pytest do the rest of the job of actually running > the tests and reporting the results. > > > Install > ========= > > pytest-incremental is tested on python 2.6, 2.7. > > ``pip install pytest-incremental``` > > ``python setup.py install`` > > local installation > -------------------- > > You can also just grab the plugin `module > <https://bitbucket.org/schettino72/pytest-incremental/src/tip/pytest_incremental.py>`_ > file and put in your project path. Then enable it (check `pytest docs > <http://pytest.org/plugins.html#requiring-loading-plugins-in-a-test-module-or-conftest-file>`_). > > > Usage > ====== > > Just pass the parameter ``--incremental`` when calling from the command line:: > > $ py.test --incremental > > > You can also enable it by default adding the following line to your > ``pytest.ini``:: > > [pytest] > addopts = --incremental > > > watched packages > ------------------ > > By default all modules collected by pytest will used as dependencies > if imported. In order to limit or extend the watched folders you must > use the parameter ``--watch-pkg`` > > > Limitations > ============== > > ``pytest-incremental`` looks for imports recursively to find > dependencies (using AST). But given the very dynamic nature of python > there are still some cases that a module can be affected by a module > that are not detected. > > * `from package import *` modules imported from __all__ in a package > are not counted as a dependency > * modules imported not using the *import* statement > * modules not explictitly imported but used at runtime (i.e. > conftest.py when running your tests with pytest) > * monkey-patching. (i.e. A imports X. B monkey-patches X. In this > case A might depend on B) > * others ? > > > Project Details > =============== > > - Project code + issue track on `bitbucket > <https://bitbucket.org/schettino72/pytest-incremental>`_ > - `Discussion group <http://groups.google.co.in/group/python-doit>`_ > _______________________________________________ > py-dev mailing list > py-dev@codespeak.net > http://codespeak.net/mailman/listinfo/py-dev > _______________________________________________ py-dev mailing list py-dev@codespeak.net http://codespeak.net/mailman/listinfo/py-dev