pytest-dev / pytest-incremental

py-test plugin: an incremental test runner
http://pytest-incremental.readthedocs.org
MIT License
42 stars 7 forks source link

KeyError in gen_outdated with `--inc-path` #2

Closed blueyed closed 9 years ago

blueyed commented 9 years ago

When using the plugin with --inc-path (which is required to use it on a subdir), I get a KeyError:

% py.test --inc --inc-path=project project
========================================================================== test session starts ==========================================================================
platform linux2 -- Python 2.7.8 -- py-1.4.26 -- pytest-2.6.4

plugins: django, cov, testmon, incremental, ipdb, stepwise, bdd, splinter, cache, mock, xdist
collected 50 items 
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "…/pyenv/project2/lib/python2.7/site-packages/_pytest/main.py", line 84, in wrap_session
INTERNALERROR>     doit(config, session)
INTERNALERROR>   File "…/pyenv/project2/lib/python2.7/site-packages/_pytest/main.py", line 121, in _main
INTERNALERROR>     config.hook.pytest_collection(session=session)
INTERNALERROR>   File "…/pyenv/project2/lib/python2.7/site-packages/_pytest/core.py", line 413, in __call__
INTERNALERROR>     return self._docall(methods, kwargs)
INTERNALERROR>   File "…/pyenv/project2/lib/python2.7/site-packages/_pytest/core.py", line 424, in _docall
INTERNALERROR>     res = mc.execute()
INTERNALERROR>   File "…/pyenv/project2/lib/python2.7/site-packages/_pytest/core.py", line 315, in execute
INTERNALERROR>     res = method(**kwargs)
INTERNALERROR>   File "…/pyenv/project2/lib/python2.7/site-packages/_pytest/main.py", line 125, in pytest_collection
INTERNALERROR>     return session.perform_collect()
INTERNALERROR>   File "…/pyenv/project2/lib/python2.7/site-packages/_pytest/main.py", line 548, in perform_collect
INTERNALERROR>     config=self.config, items=items)
INTERNALERROR>   File "…/pyenv/project2/lib/python2.7/site-packages/_pytest/core.py", line 413, in __call__
INTERNALERROR>     return self._docall(methods, kwargs)
INTERNALERROR>   File "…/pyenv/project2/lib/python2.7/site-packages/_pytest/core.py", line 424, in _docall
INTERNALERROR>     res = mc.execute()
INTERNALERROR>   File "…/pyenv/project2/lib/python2.7/site-packages/_pytest/core.py", line 315, in execute
INTERNALERROR>     res = method(**kwargs)
INTERNALERROR>   File "…/pytest-incremental/pytest_incremental.py", line 689, in pytest_collection_modifyitems
INTERNALERROR>     outdated = self.control.get_outdated()
INTERNALERROR>   File "…/pytest-incremental/pytest_incremental.py", line 536, in get_outdated
INTERNALERROR>     output_str = self._run_doit(outdated_tasks)
INTERNALERROR>   File "…/pytest-incremental/pytest_incremental.py", line 523, in _run_doit
INTERNALERROR>     cmd.parse_execute(sel_tasks)
INTERNALERROR>   File "…/pyenv/project2/lib/python2.7/site-packages/doit/cmd_base.py", line 122, in parse_execute
INTERNALERROR>     return self.execute(params, args)
INTERNALERROR>   File "…/pyenv/project2/lib/python2.7/site-packages/doit/cmd_base.py", line 405, in execute
INTERNALERROR>     return self._execute(**exec_params)
INTERNALERROR>   File "…/pyenv/project2/lib/python2.7/site-packages/doit/cmd_run.py", line 239, in _execute
INTERNALERROR>     return runner.run_all(self.control.task_dispatcher())
INTERNALERROR>   File "…/pyenv/project2/lib/python2.7/site-packages/doit/runner.py", line 238, in run_all
INTERNALERROR>     self.run_tasks(task_dispatcher)
INTERNALERROR>   File "…/pyenv/project2/lib/python2.7/site-packages/doit/runner.py", line 197, in run_tasks
INTERNALERROR>     node = task_dispatcher.generator.send(node)
INTERNALERROR>   File "…/pyenv/project2/lib/python2.7/site-packages/doit/control.py", line 554, in _dispatcher_generator
INTERNALERROR>     next_step = node.step()
INTERNALERROR>   File "…/pyenv/project2/lib/python2.7/site-packages/doit/control.py", line 285, in step
INTERNALERROR>     return next(self.generator)
INTERNALERROR>   File "…/pyenv/project2/lib/python2.7/site-packages/doit/control.py", line 294, in _func
INTERNALERROR>     for value in decorated(*args, **kwargs):
INTERNALERROR>   File "…/pyenv/project2/lib/python2.7/site-packages/doit/control.py", line 417, in _add_task
INTERNALERROR>     new_tasks = generate_tasks(basename, ref(), ref.__doc__)
INTERNALERROR>   File "…/pyenv/project2/lib/python2.7/site-packages/doit/loader.py", line 296, in generate_tasks
INTERNALERROR>     for task_dict, x_doc in flat_generator(gen_result, gen_doc):
INTERNALERROR>   File "…/pyenv/project2/lib/python2.7/site-packages/doit/loader.py", line 28, in flat_generator
INTERNALERROR>     for item in gen:
INTERNALERROR>   File "…/pytest-incremental/pytest_incremental.py", line 431, in gen_outdated
INTERNALERROR>     'file_dep': [n.name for n in nodes[test].all_deps()],
INTERNALERROR> KeyError: '…/project/app/test_views.py'

It works when changing to the "project" directory and only using --inc then.

schettino72 commented 9 years ago

Thanks! fixed:

https://github.com/pytest-dev/pytest-incremental/commit/7aa4a82fa16e982edbcedb7319a4d740b349218e

Note I am still planning some major features before release...

blueyed commented 9 years ago

Thanks!

Can you elaborate on the differences to https://github.com/tarpas/testmon?

schettino72 commented 9 years ago

Goal is the same as testmon but the implementation is completely different (with different results/tradeoff). I will write about that before I make a release.

The project you are trying this is open source? I am looking for a project to do a "case-study", if you have anything...

blueyed commented 9 years ago

Great.

The project you are trying this is open source?

Unfortunately not. And I am just experimenting a bit with pytest-incremental, after I've heard about testmon. It's nice to see so much development in this direction.. :)

sublee commented 9 years ago

I got same error on 0.4.2.

sublee commented 9 years ago

Oh, I forgot some package which should be watched. I think KeyError traceback is not friendly error message.

schettino72 commented 9 years ago

@sublee please:

sublee commented 9 years ago

@schettino72 It was my mistake. I have no issue anymore.