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

assertion rewriting should be sensitive of the pytest version #1671

Closed
RonnyPfannschmidt opened this issue Jun 25, 2016 · 5 comments

Comments

Projects
None yet
3 participants
@RonnyPfannschmidt
Copy link
Member

commented Jun 25, 2016

currently pytest updates do not trigger recreation of the cached bytecode
we should have the pytest version of part of it

@RonnyPfannschmidt RonnyPfannschmidt added this to the 3.1.0 milestone Jun 25, 2016

@RonnyPfannschmidt RonnyPfannschmidt modified the milestones: 3.1, 3.2 Jul 21, 2017

@nicoddemus

This comment has been minimized.

Copy link
Member

commented Feb 26, 2018

Any ideas how to do that @RonnyPfannschmidt? I don't think we can write anything to the byte code (I don't know the format to say that for sure though), do you suggest writing that information in a separate file perhaps?

@RonnyPfannschmidt

This comment has been minimized.

Copy link
Member Author

commented Feb 27, 2018

we should either add the pytest version to the cache tag in the filename, or make it part of the cached pyc file and recreate on different pytest versions

@nicoddemus

This comment has been minimized.

Copy link
Member

commented Feb 27, 2018

Oh we can control the generated filename? This seems like the correct approach then. 👍

@RonnyPfannschmidt RonnyPfannschmidt modified the milestones: 3.2, 3.5 Feb 27, 2018

@nicoddemus nicoddemus modified the milestones: 3.5, 3.6 Apr 13, 2018

@nicoddemus nicoddemus modified the milestones: 3.6, 3.7 Apr 26, 2018

@nicoddemus nicoddemus modified the milestones: 3.7, 3.8 Jul 9, 2018

@nicoddemus nicoddemus modified the milestones: 3.8, 3.9 Sep 21, 2018

@nicoddemus nicoddemus removed this from the 3.9 milestone Nov 8, 2018

@asottile

This comment has been minimized.

Copy link
Member

commented Jun 23, 2019

marking this one as easy, would just need someone to pick this up

The code hint is here:

# pytest caches rewritten pycs in __pycache__.
if hasattr(imp, "get_tag"):
PYTEST_TAG = imp.get_tag() + "-PYTEST"
else:
if hasattr(sys, "pypy_version_info"):
impl = "pypy"
else:
impl = "cpython"
ver = sys.version_info
PYTEST_TAG = "{}-{}{}-PYTEST".format(impl, ver[0], ver[1])
del ver, impl
PYC_EXT = ".py" + (__debug__ and "c" or "o")
PYC_TAIL = "." + PYTEST_TAG + PYC_EXT

Though my branch simplifies this a bit so you'll probably want to wait until #5468 lands

@nicoddemus

This comment has been minimized.

Copy link
Member

commented Jun 24, 2019

This would also resolve #4969 and make pytest-remove-stale-bytecode obsolete. 😁

(cc @sallner)

Nevermind, pytest-remove-stale-bytecode is not about removing only pyc files for tests, but for all files including user code. 👍

nicoddemus added a commit to nicoddemus/pytest that referenced this issue Jun 24, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.