Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--newest-first forgets about existing nodeids when collection is filtered #5206

Closed
blueyed opened this issue May 3, 2019 · 1 comment · Fixed by #6004
Closed

--newest-first forgets about existing nodeids when collection is filtered #5206

blueyed opened this issue May 3, 2019 · 1 comment · Fixed by #6004
Labels
plugin: cache related to the cache builtin plugin type: bug problem that needs to be addressed

Comments

@blueyed
Copy link
Contributor

blueyed commented May 3, 2019

--newest-first (added via #3034) forgets about cached nodeids when e.g. run with some file as argument.

Code:

class NFPlugin(object):
""" Plugin which implements the --nf (run new-first) option """
def __init__(self, config):
self.config = config
self.active = config.option.newfirst
self.cached_nodeids = config.cache.get("cache/nodeids", [])
def pytest_collection_modifyitems(self, session, config, items):
if self.active:
new_items = OrderedDict()
other_items = OrderedDict()
for item in items:
if item.nodeid not in self.cached_nodeids:
new_items[item.nodeid] = item
else:
other_items[item.nodeid] = item
items[:] = self._get_increasing_order(
six.itervalues(new_items)
) + self._get_increasing_order(six.itervalues(other_items))
self.cached_nodeids = [x.nodeid for x in items if isinstance(x, pytest.Item)]

I think it should not forget about those - this makes it likely consider all others as new when running without args then again.

It should probably just add to the known items, and have a mechanism to garbage-collect them from time to time, but that is not really critical I suppose.

/cc @feuillemorte

@blueyed blueyed added type: bug problem that needs to be addressed plugin: cache related to the cache builtin plugin labels May 3, 2019
@blueyed
Copy link
Contributor Author

blueyed commented May 3, 2019

While at it nodeids could be renamed to known_nodeids maybe also, and a timestamp for its discovery and last collection (or something similar) could be added to the data then.

@blueyed blueyed changed the title --newest-first forgets about existing nodeids when collection is limited --newest-first forgets about existing nodeids when collection is filtered May 23, 2019
blueyed added a commit to blueyed/pytest that referenced this issue Oct 19, 2019
Caveat: does not forget about old nodeids

Fixes pytest-dev#5206
blueyed added a commit to blueyed/pytest that referenced this issue Oct 19, 2019
Caveat: does not forget about old nodeids

Fixes pytest-dev#5206
phloose pushed a commit to phloose/pytest that referenced this issue Oct 23, 2019
Caveat: does not forget about old nodeids

Fixes pytest-dev#5206
bors bot added a commit to duckinator/bork that referenced this issue Oct 25, 2019
68: Update pytest to 5.2.2 r=duckinator a=pyup-bot


This PR updates [pytest](https://pypi.org/project/pytest) from **5.2.1** to **5.2.2**.



<details>
  <summary>Changelog</summary>
  
  
   ### 5.2.2
   ```
   =========================

Bug Fixes
---------

- `5206 &lt;https://github.com/pytest-dev/pytest/issues/5206&gt;`_: Fix ``--nf`` to not forget about known nodeids with partial test selection.


- `5906 &lt;https://github.com/pytest-dev/pytest/issues/5906&gt;`_: Fix crash with ``KeyboardInterrupt`` during ``--setup-show``.


- `5946 &lt;https://github.com/pytest-dev/pytest/issues/5946&gt;`_: Fixed issue when parametrizing fixtures with numpy arrays (and possibly other sequence-like types).


- `6044 &lt;https://github.com/pytest-dev/pytest/issues/6044&gt;`_: Properly ignore ``FileNotFoundError`` exceptions when trying to remove old temporary directories,
  for instance when multiple processes try to remove the same directory (common with ``pytest-xdist``
  for example).
   ```
   
  
</details>


 

<details>
  <summary>Links</summary>
  
  - PyPI: https://pypi.org/project/pytest
  - Changelog: https://pyup.io/changelogs/pytest/
  - Homepage: https://docs.pytest.org/en/latest/
</details>



Co-authored-by: pyup-bot <github-bot@pyup.io>
bors bot added a commit to rehandalal/therapist that referenced this issue Oct 29, 2019
98: Update pytest to 5.2.2 r=rehandalal a=pyup-bot


This PR updates [pytest](https://pypi.org/project/pytest) from **5.2.1** to **5.2.2**.



<details>
  <summary>Changelog</summary>
  
  
   ### 5.2.2
   ```
   =========================

Bug Fixes
---------

- `5206 &lt;https://github.com/pytest-dev/pytest/issues/5206&gt;`_: Fix ``--nf`` to not forget about known nodeids with partial test selection.


- `5906 &lt;https://github.com/pytest-dev/pytest/issues/5906&gt;`_: Fix crash with ``KeyboardInterrupt`` during ``--setup-show``.


- `5946 &lt;https://github.com/pytest-dev/pytest/issues/5946&gt;`_: Fixed issue when parametrizing fixtures with numpy arrays (and possibly other sequence-like types).


- `6044 &lt;https://github.com/pytest-dev/pytest/issues/6044&gt;`_: Properly ignore ``FileNotFoundError`` exceptions when trying to remove old temporary directories,
  for instance when multiple processes try to remove the same directory (common with ``pytest-xdist``
  for example).
   ```
   
  
</details>


 

<details>
  <summary>Links</summary>
  
  - PyPI: https://pypi.org/project/pytest
  - Changelog: https://pyup.io/changelogs/pytest/
  - Homepage: https://docs.pytest.org/en/latest/
</details>



Co-authored-by: pyup-bot <github-bot@pyup.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: cache related to the cache builtin plugin type: bug problem that needs to be addressed
Projects
None yet
1 participant