fname
stringlengths
63
176
rel_fname
stringclasses
706 values
line
int64
-1
4.5k
name
stringlengths
1
81
kind
stringclasses
2 values
category
stringclasses
2 values
info
stringlengths
0
77.9k
⌀
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/__init__.py
src/_pytest/assertion/__init__.py
111
set_session
ref
function
assertstate.hook.set_session(session)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/__init__.py
src/_pytest/assertion/__init__.py
114
hookimpl
ref
function
@hookimpl(tryfirst=True, hookwrapper=True)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/__init__.py
src/_pytest/assertion/__init__.py
115
pytest_runtest_protocol
def
function
def pytest_runtest_protocol(item: Item) -> Generator[None, None, None]: """Setup the pytest_assertrepr_compare and pytest_assertion_pass hooks. The rewrite module will use util._reprcompare if it exists to use custom reporting via the pytest_assertrepr_compare hook. This sets up this custom comparison...
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/__init__.py
src/_pytest/assertion/__init__.py
125
callbinrepr
def
function
def callbinrepr(op, left: object, right: object) -> Optional[str]: """Call the pytest_assertrepr_compare hook and prepare the result. This uses the first result from the hook and then ensures the following: * Overly verbose explanations are truncated unless configured otherwise ...
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/__init__.py
src/_pytest/assertion/__init__.py
140
pytest_assertrepr_compare
ref
function
hook_result = ihook.pytest_assertrepr_compare(
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/__init__.py
src/_pytest/assertion/__init__.py
145
truncate_if_required
ref
function
new_expl = truncate.truncate_if_required(new_expl, item)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/__init__.py
src/_pytest/assertion/__init__.py
148
getvalue
ref
function
if item.config.getvalue("assertmode") == "rewrite":
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/__init__.py
src/_pytest/assertion/__init__.py
157
get_hookimpls
ref
function
if ihook.pytest_assertion_pass.get_hookimpls():
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/__init__.py
src/_pytest/assertion/__init__.py
159
call_assertion_pass_hook
def
function
def call_assertion_pass_hook(lineno: int, orig: str, expl: str) -> None: ihook.pytest_assertion_pass(item=item, lineno=lineno, orig=orig, expl=expl) util._assertion_pass = call_assertion_pass_hook yield util._reprcompare, util._assertion_pass = saved_assert_hooks util._config ...
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/__init__.py
src/_pytest/assertion/__init__.py
160
pytest_assertion_pass
ref
function
ihook.pytest_assertion_pass(item=item, lineno=lineno, orig=orig, expl=expl)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/__init__.py
src/_pytest/assertion/__init__.py
170
pytest_sessionfinish
def
function
def pytest_sessionfinish(session: "Session") -> None: assertstate = session.config.stash.get(assertstate_key, None) if assertstate: if assertstate.hook is not None: assertstate.hook.set_session(None)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/__init__.py
src/_pytest/assertion/__init__.py
174
set_session
ref
function
assertstate.hook.set_session(None)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/__init__.py
src/_pytest/assertion/__init__.py
177
pytest_assertrepr_compare
def
function
def pytest_assertrepr_compare( config: Config, op: str, left: Any, right: Any
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/__init__.py
src/_pytest/assertion/__init__.py
180
assertrepr_compare
ref
function
return util.assertrepr_compare(config=config, op=op, left=left, right=right)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
56
AssertionRewritingHook
def
class
__init__ set_session find_spec create_module exec_module _early_rewrite_bailout _should_rewrite _is_marked_for_rewrite mark_rewrite _warn_already_imported get_data
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
62
getini
ref
function
self.fnpats = config.getini("python_files")
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
75
set_session
def
function
def set_session(self, session: Optional[Session]) -> None: self.session = session self._session_paths_checked = _False # Indirection so we can mock calls to find_spec originated from the hook during testing _find_spec = importlib.machinery.PathFinder.find_spec def find_spec( se...
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
91
_early_rewrite_bailout
ref
function
if self._early_rewrite_bailout(name, state):
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
93
trace
ref
function
state.trace("find_module called for: %s" % name)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
115
_should_rewrite
ref
function
if not self._should_rewrite(name, fn, state):
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
125
create_module
def
function
def create_module( self, spec: importlib.machinery.ModuleSpec ) -> Optional[types.ModuleType]: return None # default behaviour is fine def exec_module(self, module: types.ModuleType) -> None: assert module.__spec__ is not None assert module.__spec__.origin is not None ...
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
130
exec_module
def
function
def exec_module(self, module: types.ModuleType) -> None: assert module.__spec__ is not None assert module.__spec__.origin is not None fn = Path(module.__spec__.origin) state = self.config.stash[assertstate_key] self._rewritten_names[module.__name__] = fn # The reque...
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
147
get_cache_dir
ref
function
cache_dir = get_cache_dir(fn)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
149
try_makedirs
ref
function
ok = try_makedirs(cache_dir)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
152
trace
ref
function
state.trace(f"read only directory: {cache_dir}")
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
158
_read_pyc
ref
function
co = _read_pyc(fn, pyc, state.trace)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
160
trace
ref
function
state.trace(f"rewriting {fn!r}")
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
161
_rewrite_test
ref
function
source_stat, co = _rewrite_test(fn, self.config)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
165
_write_pyc
ref
function
_write_pyc(state, co, source_stat, pyc)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
169
trace
ref
function
state.trace(f"found cached rewritten pyc for {fn}")
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
172
_early_rewrite_bailout
def
function
def _early_rewrite_bailout(self, name: str, state: "AssertionState") -> bool: """A fast way to get out of rewriting modules. Profiling has shown that the call to PathFinder.find_spec (inside of the find_spec from this class) is a major slowdown, so, this method tries to filter what ...
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
187
splitext
ref
function
self._basenames_to_check_rewrite.add(os.path.splitext(parts[-1])[0])
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
200
dirname
ref
function
if os.path.dirname(pat):
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
202
fnmatch_ex
ref
function
if fnmatch_ex(pat, path):
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
205
_is_marked_for_rewrite
ref
function
if self._is_marked_for_rewrite(name, state):
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
208
trace
ref
function
state.trace(f"early skip of rewriting module: {name}")
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
211
_should_rewrite
def
function
def _should_rewrite(self, name: str, fn: str, state: "AssertionState") -> bool: # always rewrite conftest files if os.path.basename(fn) == "conftest.py": state.trace(f"rewriting conftest file: {fn!r}") return _True if self.session is not None: if self.ses...
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
213
basename
ref
function
if os.path.basename(fn) == "conftest.py":
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
214
trace
ref
function
state.trace(f"rewriting conftest file: {fn!r}")
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
218
isinitpath
ref
function
if self.session.isinitpath(absolutepath(fn)):
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
218
absolutepath
ref
function
if self.session.isinitpath(absolutepath(fn)):
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
219
trace
ref
function
state.trace(f"matched test file (was specified on cmdline): {fn!r}")
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
226
fnmatch_ex
ref
function
if fnmatch_ex(pat, fn_path):
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
227
trace
ref
function
state.trace(f"matched test file {fn!r}")
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
230
_is_marked_for_rewrite
ref
function
return self._is_marked_for_rewrite(name, state)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
232
_is_marked_for_rewrite
def
function
def _is_marked_for_rewrite(self, name: str, state: "AssertionState") -> bool: try: return self._marked_for_rewrite_cache[name] except KeyError: for marked in self._must_rewrite: if name == marked or name.startswith(marked + "."): state.trac...
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
238
trace
ref
function
state.trace(f"matched marked file {name!r} (from {marked!r})")
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
245
mark_rewrite
def
function
def mark_rewrite(self, *names: str) -> None: """Mark import names as needing to be rewritten. The named module or package as well as any nested modules will be rewritten on import. """ already_imported = ( set(names).intersection(sys.modules).difference(self._rew...
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
256
is_rewrite_disabled
ref
function
if not AssertionRewriter.is_rewrite_disabled(
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
259
_warn_already_imported
ref
function
self._warn_already_imported(name)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
263
_warn_already_imported
def
function
def _warn_already_imported(self, name: str) -> None: from _pytest.warning_types import PytestAssertRewriteWarning self.config.issue_config_time_warning( PytestAssertRewriteWarning( "Module already imported so cannot be rewritten: %s" % name ), sta...
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
266
issue_config_time_warning
ref
function
self.config.issue_config_time_warning(
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
267
PytestAssertRewriteWarning
ref
function
PytestAssertRewriteWarning(
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
273
get_data
def
function
def get_data(self, pathname: Union[str, bytes]) -> bytes: """Optional PEP302 get_data API.""" with open(pathname, "rb") as f: return f.read() if sys.version_info >= (3, 9): def get_resource_reader(self, name: str) -> importlib.abc.TraversableResources: # type: ignore ...
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
280
get_resource_reader
def
function
def get_resource_reader(self, name: str) -> importlib.abc.TraversableResources: # type: ignore from types import SimpleNamespace from importlib.readers import FileReader return FileReader(SimpleNamespace(path=self._rewritten_names[name]))
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
284
FileReader
ref
function
return FileReader(SimpleNamespace(path=self._rewritten_names[name]))
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
287
_write_pyc_fp
def
function
def _write_pyc_fp( fp: IO[bytes], source_stat: os.stat_result, co: types.CodeType
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
309
_write_pyc
def
function
def _write_pyc( state: "AssertionState", co: types.CodeType, source_stat: os.stat_result, pyc: Path, ) -> bool: try: with atomic_write(os.fspath(pyc), mode="wb", overwrite=_True) as fp: _write_pyc_fp(fp, source_stat, co) except OSError ...
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
316
atomic_write
ref
function
with atomic_write(os.fspath(pyc), mode="wb", overwrite=True) as fp:
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
317
_write_pyc_fp
ref
function
_write_pyc_fp(fp, source_stat, co)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
319
trace
ref
function
state.trace(f"error writing pyc file at {pyc}: {e}")
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
329
_write_pyc
def
function
def _write_pyc( state: "AssertionState", co: types.CodeType, source_stat: os.stat_result, pyc: Path, ) -> bool: try: with atomic_write(os.fspath(pyc), mode="wb", overwrite=_True) as fp: _write_pyc_fp(fp, source_stat, co) except OSError ...
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
339
trace
ref
function
state.trace(f"error writing pyc file at {proc_pyc}: errno={e.errno}")
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
343
_write_pyc_fp
ref
function
_write_pyc_fp(fp, source_stat, co)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
346
trace
ref
function
state.trace(f"error writing pyc file at {pyc}: {e}")
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
356
_rewrite_test
def
function
def _rewrite_test(fn: Path, config: Config) -> Tuple[os.stat_result, types.CodeType]: """Read and rewrite *fn* and return the code object.""" stat = os.stat(fn) source = fn.read_bytes() strfn = str(fn) tree = ast.parse(source, filename=strfn) rewrite_asserts(tree, source, strfn, config) co =...
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
362
rewrite_asserts
ref
function
rewrite_asserts(tree, source, strfn, config)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
367
_read_pyc
def
function
def _read_pyc( source: Path, pyc: Path, trace: Callable[[str], None] = lambda x: None
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
387
trace
ref
function
trace(f"_read_pyc({source}): OSError {e}")
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
391
trace
ref
function
trace("_read_pyc(%s): invalid pyc (too short)" % source)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
394
trace
ref
function
trace("_read_pyc(%s): invalid pyc (bad magic number)" % source)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
397
trace
ref
function
trace("_read_pyc(%s): invalid pyc (unsupported flags)" % source)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
401
trace
ref
function
trace("_read_pyc(%s): out of date" % source)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
405
trace
ref
function
trace("_read_pyc(%s): invalid pyc (incorrect size)" % source)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
410
trace
ref
function
trace(f"_read_pyc({source}): marshal.load error {e}")
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
413
trace
ref
function
trace("_read_pyc(%s): not a code object" % source)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
418
rewrite_asserts
def
function
def rewrite_asserts( mod: ast.Module, source: bytes, module_path: Optional[str] = None, config: Optional[Config] = None,
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
425
AssertionRewriter
ref
function
AssertionRewriter(module_path, config, source).run(mod)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
425
run
ref
function
AssertionRewriter(module_path, config, source).run(mod)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
428
_saferepr
def
function
def _saferepr(obj: object) -> str: r"""Get a safe repr of an object for assertion error messages. The assertion formatting (util.format_explanation()) requires newlines to be escaped since they are a special character for it. Normally assertion.util.format_explanation() does this but for a custom r...
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
438
_get_maxsize_for_saferepr
ref
function
maxsize = _get_maxsize_for_saferepr(util._config)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
439
saferepr
ref
function
return saferepr(obj, maxsize=maxsize).replace("\n", "\\n")
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
442
_get_maxsize_for_saferepr
def
function
def _get_maxsize_for_saferepr(config: Optional[Config]) -> Optional[int]: """Get `maxsize` configuration for saferepr based on the given config object.""" verbosity = config.getoption("verbose") if config is not None else 0 if verbosity >= 2: return None if verbosity >= 1: return DEFAULT...
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
444
getoption
ref
function
verbosity = config.getoption("verbose") if config is not None else 0
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
452
_format_assertmsg
def
function
def _format_assertmsg(obj: object) -> str: r"""Format the custom assertion message given. For strings this simply replaces newlines with '\n~' so that util.format_explanation() will preserve them instead of escaping newlines. For other objects saferepr() is used first. """ # reprlib appears to...
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
465
saferepr
ref
function
obj = saferepr(obj)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
474
_should_repr_global_name
def
function
def _should_repr_global_name(obj: object) -> bool: if callable(obj): return _False try: return not hasattr(obj, "__name__") except Exception: return _True
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
484
_format_boolop
def
function
def _format_boolop(explanations: Iterable[str], is_or: bool) -> str: explanation = "(" + (is_or and " or " or " and ").join(explanations) + ")" return explanation.replace("%", "%%")
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
489
_call_reprcompare
def
function
def _call_reprcompare( ops: Sequence[str], results: Sequence[bool], expls: Sequence[str], each_obj: Sequence[object],
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
503
_reprcompare
ref
function
custom = util._reprcompare(ops[i], each_obj[i], each_obj[i + 1])
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
509
_call_assertion_pass
def
function
def _call_assertion_pass(lineno: int, orig: str, expl: str) -> None: if util._assertion_pass is not None: util._assertion_pass(lineno, orig, expl)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
511
_assertion_pass
ref
function
util._assertion_pass(lineno, orig, expl)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
514
_check_if_assertion_pass_impl
def
function
def _check_if_assertion_pass_impl() -> bool: """Check if any plugins implement the pytest_assertion_pass hook in order not to generate explanation unecessarily (might be expensive).""" return _True if util._assertion_pass else _False
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
549
traverse_node
def
function
def traverse_node(node: ast.AST) -> Iterator[ast.AST]: """Recursively yield node and all its children in depth-first order.""" yield node for child in ast.iter_child_nodes(node): yield from traverse_node(child)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
553
traverse_node
ref
function
yield from traverse_node(child)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
557
_get_assertion_exprs
def
function
def _get_assertion_exprs(src: bytes) -> Dict[int, str]: """Return a mapping from {lineno: "assertion test expression"}.""" ret: Dict[int, str] = {} depth = 0 lines: List[str] = [] assert_lineno: Optional[int] = None seen_lines: Set[int] = set() def _write_and_reset() -> None: nonlo...
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
566
_write_and_reset
def
function
def _write_and_reset() -> None: nonlocal depth, lines, assert_lineno, seen_lines assert assert_lineno is not None ret[assert_lineno] = "".join(lines).rstrip().rstrip("\\") depth = 0 lines = [] assert_lineno = None seen_lines = set() tokens = tokenize.toke...
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
575
BytesIO
ref
function
tokens = tokenize.tokenize(io.BytesIO(src).readline)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
601
_write_and_reset
ref
function
_write_and_reset()
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/src/_pytest/assertion/rewrite.py
src/_pytest/assertion/rewrite.py
603
_write_and_reset
ref
function
_write_and_reset()