You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
diffcone corpus --jobs no longer fails now and then with "git
worktree add: fatal: failed to read .git/worktrees/.../commondir": jobs
create and remove their checkouts one at a time.
Planning
A log call now counts as running what you hand the logging library:
handlers, filters, formatters, filter functions, record factories and
the methods of your logger classes (also on a plain getLogger value),
so tests reading what a handler captured are selected. A Logger
subclass's self.makeRecord(...) record holds what it was made of:
changing record.args or record.msg in place changes the logged
objects, while setting an attribute on the fresh record does not,
unless you install a record factory or give the logger class its own makeRecord. Before, a logging call through such a subclass made every
logged object and every logger written state.
A function changing what it gets through *args or **kwargs, or
through a new object holding an argument (box = Box(arg); box.items.append(x)), now changes what its callers passed, and a call
passing *items or **options passes what they hold. What a function
changes through an element of an argument it hands on (for o in objs: o.reset()) is now changed for its callers too.
A function you store on a logging handler, filter, formatter or logger
class under a callback's name (MyLogger.handle = f, or with setattr) now
runs as that callback when you log, and is followed when your own code
calls it by that name (self.emit(record)).
A change in place to what one of your functions returns now reaches
what the caller handed it, when the function returns that object or
part of it (r = wrap(p); r["items"].append(x), through further calls
and any of several returns, b.tag().add(x) where tag returns self, or the result handed to a function that changes it).
Setting an attribute on a new instance of your class (in __init__ or
later) no longer changes what you passed its constructor just because
the class defines __getattr__ or __getattribute__, which run when an
attribute is read, not when one is set; adding to an attribute of such
a class (self.n += 1, which reads it first) still counts.
A __new__ that calls super().__new__(cls) (a metaclass's included)
and sets attributes on what it gets back no longer counts as changing
its own class: that call runs the next __new__ in the class hierarchy,
whose own result is still followed.
With --evidence, what a function's decorators and default values do
(@app.command() registering it on app) no longer counts as something
a call of the function stores for later tests: that code runs when the
module defines the function. A change to the decorator, or to the code
it runs, still reaches the readers of what it writes.
A test module whose import-time code changes process state (so every
test depends on it) no longer has its own tests taken for code that
leaves state behind for other tests: what such a test stores is again
seen by that test alone, as in any other test module.
Reading an attribute of a library module through a project module that
imports it (store.json.dumps), or patching one by name
(monkeypatch.setattr(store.sys, "getfilesystemencoding", f)), no
longer counts as reading the whole module, so it no longer depends on
every store project code makes onto that module.
locals() at module level is treated as the module's namespace, like globals().
Code that imports a name your project installs a module under in sys.modules (sys.modules["compat"] = impl) now depends on the
installed module: imports of the name, attributes
read off it and names looked up on it. A plugin that pytest_plugins, -p or PYTEST_PLUGINS names this way is the installed module; one diffcone cannot follow
selects every test, with a plugin_installed note, and a plugin file
of that name outside your source roots is still reported. A plugin name
no file provides may also be what your code installs under a name it
computes: when that may be any module, the plugin selects every test;
when it is a module your code makes, every test depends on that code
(both with a plugin_installed note). Installs made only by a test or a
function-scoped fixture don't count, since they run after pytest loads
its plugins. When what is
installed may be any module (loaded from a computed path, or a module
your code was handed as an argument), code that imports the name sees
every change.
An install into sys.modules made by a function-scoped fixture or a
test, or undone after the test (monkeypatch.setitem(sys.modules, "extlib", fakes), mock.patch.dict), now counts for the tests that run
it, and only for them: code importing the name elsewhere does not depend
on it. A fixture that unloads modules and puts back the ones it saved
from a copy of sys.modules installs nothing new.
A module name built as "{0}.{1}".format(__name__, name) now counts as
a name under that module wherever a module is looked up by name
(importlib.import_module, sys.modules[...], an install), as f"{__name__}.{name}" already did.
A method called on a local name bound to {}, [], set() or dict()
is the builtin's own method: it no longer writes through every method of
that name in your code.
typing.cast(T, p) hands on p: changing the result changes p.
Plans can be slower and use more memory than with 0.5.0, since the
index now follows more writes (what logging calls back, *args,
returned arguments, installs in sys.modules). On one project whose
log calls share handlers through dictConfig, a plan with a warm cache
took 17 s and 1.5 GB against 6 s and 0.4 GB with 0.5.0, and a cold one
67 s and 1.9 GB against 53 s and 1.1 GB, for the same selection. Log
calls sharing a set of callbacks share one node in the index, which
keeps the logging part of that down.
Execution evidence
A plain function or method just added is no longer seen by code that
only reads signatures (inspect.signature(handler)): run as a module was
imported by a conftest, it made any new function or method select every
test. It is still followed when its def runs code at import (a
decorator), when it is a special method (__init__), when a class
holding it reads its namespace as it is created (a metaclass, __init_subclass__, __prepare__) or its module's top-level code looks
names up (register_all(globals())), and for inspect.signature(..., eval_str=True).
A store into sys.modules (sys.modules[name] = module, del sys.modules[name]) no longer counts as code that can look any name up:
a module that registers a file it loads by path that way, imported by a
conftest, made any new function or method select every test.
diffcone collect names what flagged the most tests as starting a
subprocess (always selected), with the line of the checkout that
started it and whether the process was still running when later tests
ran, one line each, ties in the order of their text.
A class that a changed function may write into, and that has no other
edge to it, is no longer read as its class body reading the change at
import, which escalated its module: a test class whose new test called
the function made every test count as code run at import, and a
write that code could reach, read in a pytest hook, selected every
test. The class is followed as written state instead: the code naming
it, its family's methods and the sites that can see it.
What a test stores (a module variable, a class attribute, an entry of a
shared list) is followed into code that runs outside the tests too: code
run at import that kept a reference to it, a hook that runs between
tests, a module a later test imports. Only the tests themselves were
taken to read it.
A class attribute a test writes by name (Settings.debug = True) now
reaches code reading .debug off an instance of the class.
Adding or deleting a member of a class, or changing its definition or
annotations, now reaches the code run when the class is created, when
that may read the class's namespace: a decorator (@dataclass, any
other) or a keyword (a metaclass) on the class or one of its bases, a
base outside your code (Enum, unittest.TestCase, abc.ABC, Protocol, NamedTuple, TypedDict), a base's __init_subclass__, or
a body that hands locals() or vars() to code
(register_all(locals())) or looks names up itself. Its module is
followed as code run at import, so adding a test method to a unittest.TestCase class, with a recording, selects the tests of its
module.
Evidence plans with many changes to code run at import are faster than
with 0.5.0 (a suite of 7 700 tests: 22 s down to 16 s, using 1.1 GB of
memory against 1.0 GB).
Recordings made with 0.5.0 still work.
Report
schema_version 5: a fallback that selects every target is written
once, in fallback_decisions, and each target's explanation names it
by its index ("fallback": 0) instead of repeating its detail. A
plan with 29 such fallbacks over 7 700 tests was 429 MB, 377 MB of it
those details. The text report lists the fallback decisions numbered
and points to them.
CI
The report action keeps only what the report reads of each artifact
as it downloads it (the context, the verdicts, and of a plan its counts,
recording and unselected targets) and reads that as it would the whole
artifact, instead of extracting the whole artifact: a window of a large
suite's runs, kept whole, ran the runner out of disk.
The report action tries each listing and download three times before
counting it as an error: one server error (HTTP 502) among 5 000
downloads made the next report read the whole window again.
The report action fails, instead of passing with a shorter window,
when it cannot list where the last report started: one failed request
made the report start at the last hours and the next one after it,
so runs between the two were never read. Those listings are retried,
and a failure counts as an error.