diff --git a/CHANGELOG b/CHANGELOG index 07da9a1e4..840a79406 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ NEXT ----------- +- Improve assertion rewriting cache invalidation precision. + - fixed issue561: adapt autouse fixture example for python3. - fixed issue453: assertion rewriting issue with __repr__ containing diff --git a/_pytest/assertion/rewrite.py b/_pytest/assertion/rewrite.py index cb8acc187..c59927906 100644 --- a/_pytest/assertion/rewrite.py +++ b/_pytest/assertion/rewrite.py @@ -134,12 +134,12 @@ class AssertionRewritingHook(object): co = _read_pyc(fn_pypath, pyc, state.trace) if co is None: state.trace("rewriting %r" % (fn,)) - co = _rewrite_test(state, fn_pypath) + source_stat, co = _rewrite_test(state, fn_pypath) if co is None: # Probably a SyntaxError in the test. return None if write: - _make_rewritten_pyc(state, fn_pypath, pyc, co) + _make_rewritten_pyc(state, source_stat, pyc, co) else: state.trace("found cached rewritten pyc for %r" % (fn,)) self.modules[name] = co, pyc @@ -192,13 +192,12 @@ class AssertionRewritingHook(object): pkg_resources.register_loader_type(cls, pkg_resources.DefaultProvider) -def _write_pyc(state, co, source_path, pyc): +def _write_pyc(state, co, source_stat, pyc): # Technically, we don't have to have the same pyc format as # (C)Python, since these "pycs" should never be seen by builtin # import. However, there's little reason deviate, and I hope # sometime to be able to use imp.load_compiled to load them. (See # the comment in load_module above.) - mtime = int(source_path.mtime()) try: fp = open(pyc, "wb") except IOError: @@ -210,7 +209,9 @@ def _write_pyc(state, co, source_path, pyc): return False try: fp.write(imp.get_magic()) - fp.write(struct.pack("