MCPcopy Create free account
hub / github.com/catboost/catboost / _rewrite_test

Function _rewrite_test

library/python/pytest/rewrite.py:110–134  ·  view source on GitHub ↗

Try to read and rewrite *fn* and return the code object.

(config, name)

Source from the content-addressed store, hash-verified

108
109
110def _rewrite_test(config, name):
111 """Try to read and rewrite *fn* and return the code object."""
112 state = _get_state(config)
113
114 source = importer.get_source(name)
115 if source is None:
116 return None
117
118 path = importer.get_filename(name)
119
120 try:
121 tree = ast.parse(source, filename=path)
122 except SyntaxError:
123 # Let this pop up again in the real import.
124 state.trace("failed to parse: %r" % (path,))
125 return None
126 rewrite.rewrite_asserts(tree, py.path.local(path), config)
127 try:
128 co = compile(tree, path, "exec", dont_inherit=True)
129 except SyntaxError:
130 # It's possible that this error is from some bug in the
131 # assertion rewriting, but I don't know of a fast way to tell.
132 state.trace("failed to compile: %r" % (path,))
133 return None
134 return co

Callers 1

_find_moduleMethod · 0.85

Calls 6

_get_stateFunction · 0.85
get_filenameMethod · 0.80
compileFunction · 0.50
get_sourceMethod · 0.45
parseMethod · 0.45
traceMethod · 0.45

Tested by

no test coverage detected