Flags not at the start of the expression '<[^>]*>(?i)(?m)'

The stack frame is in reversed order for practical reason, the upper one first

test/test_engine.py line 38
34
35
36
37
38
39
40
41
42
    inputs = ("text/html",)
    output = "text/plain"

    def __call__(self, orig):
        orig = re.sub("<[^>]*>(?i)(?m)", "", orig)
        return url_unquote(re.sub("\n+", "\n", orig)).strip()

    def _convert(self, data):
        return self.__call__(data.data)
test/test_engine.py line 42
38
39
40
41
42
43
44
45
46
        orig = re.sub("<[^>]*>(?i)(?m)", "", orig)
        return url_unquote(re.sub("\n+", "\n", orig)).strip()

    def _convert(self, data):
        return self.__call__(data.data)


class HtmlToTextWithEncoding(HtmlToText):
    output_encoding = "utf8"
logilab/mtconverter/transform.py line 53
49
50
51
52
53
54
55
56
57
        """
        # this is not true when transform accept wildcard
        # assert trdata.mimetype in self.inputs
        assert self.output is not None
        trdata.data = self._convert(trdata)
        trdata.mimetype = self.output
        if self.output_encoding:
            trdata.encoding = self.output_encoding
        return trdata
logilab/mtconverter/transform.py line 79
75
76
77
78
79
80
81
82
83
            self._update()

    def convert(self, trdata: TransformData) -> TransformData:
        for transform in self:
            trdata = transform.convert(trdata)
        return trdata

    def __setitem__(self, key, value) -> None:  # type: ignore[no-untyped-def] # use Protocol?
        list.__setitem__(self, key, value)
logilab/mtconverter/engine.py line 78
74
75
76
77
78
79
80
81
82
        if len(path) > 1:
            transform = TransformsChain("aname", path)
        else:
            transform = path[0]
        return transform.convert(trdata)

    def _map_transform(self, transform: Transform) -> None:
        """map transform to internal structures"""
        if not (transform.inputs and transform.output):
test/test_engine.py line 166
162
163
164
165
166
167
168
169
170
        hb = TransformsChain("hbar")
        hb.append(HtmlToText())
        hb.append(FooToBar())
        self.engine.add_transform(hb)
        cache = self.engine.convert(html_data(), "text/bar")
        self.assertEqual(cache.data, "bar")

    def test_same(self):
        data = TransformData("This is a test", "text/plain", "ascii")
_pytest/python.py line 184
180
181
182
183
184
185
186
187
    ):
        async_warn(pyfuncitem.nodeid)
    funcargs = pyfuncitem.funcargs
    testargs = {arg: funcargs[arg] for arg in pyfuncitem._fixtureinfo.argnames}
    result = testfunction(**testargs)
    if hasattr(result, "__await__") or hasattr(result, "__aiter__"):
        async_warn(pyfuncitem.nodeid)
    return True
pluggy/callers.py line 187
183
184
185
186
187
188
189
190
191
                        teardowns.append(gen)
                    except StopIteration:
                        _raise_wrapfail(gen, "did not yield")
                else:
                    res = hook_impl.function(*args)
                    if res is not None:
                        results.append(res)
                        if firstresult:  # halt further impl calls
                            break
pluggy/manager.py line 84
80
81
82
83
84
85
86
87
88
                DeprecationWarning,
                stacklevel=2,
            )
        self._implprefix = implprefix
        self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
            methods,
            kwargs,
            firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
        )
pluggy/manager.py line 93
89
90
91
92
93
94
95
96
97

    def _hookexec(self, hook, methods, kwargs):
        # called from all hookcaller instances.
        # enable_tracing will set its own wrapping function at self._inner_hookexec
        return self._inner_hookexec(hook, methods, kwargs)

    def register(self, plugin, name=None):
        """ Register a plugin and return its canonical name or ``None`` if the name
        is blocked from registering.  Raise a :py:class:`ValueError` if the plugin
pluggy/hooks.py line 286
282
283
284
285
286
287
288
289
290
                    "Argument(s) {} which are declared in the hookspec "
                    "can not be found in this hook call".format(tuple(notincall)),
                    stacklevel=2,
                )
        return self._hookexec(self, self.get_hookimpls(), kwargs)

    def call_historic(self, result_callback=None, kwargs=None, proc=None):
        """Call the hook with given ``kwargs`` for all registered plugins and
        for all plugins which will be registered afterwards.
_pytest/unittest.py line 220
216
217
218
219
220
221
222
223
224
        def wrapped_testMethod(*args, **kwargs):
            """Wrap the original method to call into pytest's machinery, so other pytest
            features can have a chance to kick in (notably --pdb)"""
            try:
                self.ihook.pytest_pyfunc_call(pyfuncitem=self)
            except unittest.SkipTest:
                raise
            except Exception as exc:
                expecting_failure = self._expecting_failure(testMethod)
logilab/common/testlib.py line 465
461
462
463
464
465
466
467
468
469
        successful
        """
        kwargs = kwargs or {}
        try:
            testfunc(*args, **kwargs)
        except self.failureException:
            result.addFailure(self, self.__exc_info())
            return 1
        except KeyboardInterrupt:
logilab/common/testlib.py line 399
395
396
397
398
399
400
401
402
403
            # generative tests
            if generative:
                self._proceed_generative(result, testMethod, runcondition)
            else:
                status = self._proceed(result, testMethod)
                success = status == 0
            if not self.quiet_run(result, self.tearDown):
                return
            if not generative and success:
_pytest/unittest.py line 232
228
229
230
231
232
233
234
235
236
                raise _GetOutOf_testPartExecutor(exc)

        setattr(self._testcase, self._testcase._testMethodName, wrapped_testMethod)
        try:
            self._testcase(result=self)
        except _GetOutOf_testPartExecutor as exc:
            raise exc.args[0] from exc.args[0]
        finally:
            delattr(self._testcase, self._testcase._testMethodName)
_pytest/runner.py line 135
131
132
133
134
135
136
137
138
139
        del sys.last_traceback
    except AttributeError:
        pass
    try:
        item.runtest()
    except Exception as e:
        # Store trace info to allow postmortem debugging
        sys.last_type = type(e)
        sys.last_value = e
pluggy/callers.py line 187
183
184
185
186
187
188
189
190
191
                        teardowns.append(gen)
                    except StopIteration:
                        _raise_wrapfail(gen, "did not yield")
                else:
                    res = hook_impl.function(*args)
                    if res is not None:
                        results.append(res)
                        if firstresult:  # halt further impl calls
                            break
pluggy/manager.py line 84
80
81
82
83
84
85
86
87
88
                DeprecationWarning,
                stacklevel=2,
            )
        self._implprefix = implprefix
        self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
            methods,
            kwargs,
            firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
        )
pluggy/manager.py line 93
89
90
91
92
93
94
95
96
97

    def _hookexec(self, hook, methods, kwargs):
        # called from all hookcaller instances.
        # enable_tracing will set its own wrapping function at self._inner_hookexec
        return self._inner_hookexec(hook, methods, kwargs)

    def register(self, plugin, name=None):
        """ Register a plugin and return its canonical name or ``None`` if the name
        is blocked from registering.  Raise a :py:class:`ValueError` if the plugin
pluggy/hooks.py line 286
282
283
284
285
286
287
288
289
290
                    "Argument(s) {} which are declared in the hookspec "
                    "can not be found in this hook call".format(tuple(notincall)),
                    stacklevel=2,
                )
        return self._hookexec(self, self.get_hookimpls(), kwargs)

    def call_historic(self, result_callback=None, kwargs=None, proc=None):
        """Call the hook with given ``kwargs`` for all registered plugins and
        for all plugins which will be registered afterwards.
_pytest/runner.py line 217
213
214
215
216
217
218
219
220
221
    reraise = (Exit,)  # type: Tuple[Type[BaseException], ...]
    if not item.config.getoption("usepdb", False):
        reraise += (KeyboardInterrupt,)
    return CallInfo.from_call(
        lambda: ihook(item=item, **kwds), when=when, reraise=reraise
    )


@attr.s(repr=False)
_pytest/runner.py line 244
240
241
242
243
244
245
246
247
248
        #: "teardown", "memocollect"
        start = time()
        excinfo = None
        try:
            result = func()
        except:  # noqa
            excinfo = ExceptionInfo.from_current()
            if reraise is not None and excinfo.errisinstance(reraise):
                raise
_pytest/runner.py line 216
212
213
214
215
216
217
218
219
        assert False, "Unhandled runtest hook case: {}".format(when)
    reraise = (Exit,)  # type: Tuple[Type[BaseException], ...]
    if not item.config.getoption("usepdb", False):
        reraise += (KeyboardInterrupt,)
    return CallInfo.from_call(
        lambda: ihook(item=item, **kwds), when=when, reraise=reraise
    )

_pytest/runner.py line 186
182
183
184
185
186
187
188
189
190

def call_and_report(
    item, when: "Literal['setup', 'call', 'teardown']", log=True, **kwds
):
    call = call_runtest_hook(item, when, **kwds)
    hook = item.ihook
    report = hook.pytest_runtest_makereport(item=item, call=call)
    if log:
        hook.pytest_runtest_logreport(report=report)
_pytest/runner.py line 100
 96
 97
 98
 99
100
101
102
103
104
    if rep.passed:
        if item.config.getoption("setupshow", False):
            show_test_item(item)
        if not item.config.getoption("setuponly", False):
            reports.append(call_and_report(item, "call", log))
    reports.append(call_and_report(item, "teardown", log, nextitem=nextitem))
    # after all teardown hooks have been called
    # want funcargs and request info to go away
    if hasrequest:
_pytest/runner.py line 85
81
82
83
84
85
86
87
88


def pytest_runtest_protocol(item, nextitem):
    item.ihook.pytest_runtest_logstart(nodeid=item.nodeid, location=item.location)
    runtestprotocol(item, nextitem=nextitem)
    item.ihook.pytest_runtest_logfinish(nodeid=item.nodeid, location=item.location)
    return True

pluggy/callers.py line 187
183
184
185
186
187
188
189
190
191
                        teardowns.append(gen)
                    except StopIteration:
                        _raise_wrapfail(gen, "did not yield")
                else:
                    res = hook_impl.function(*args)
                    if res is not None:
                        results.append(res)
                        if firstresult:  # halt further impl calls
                            break
pluggy/manager.py line 84
80
81
82
83
84
85
86
87
88
                DeprecationWarning,
                stacklevel=2,
            )
        self._implprefix = implprefix
        self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
            methods,
            kwargs,
            firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
        )
pluggy/manager.py line 93
89
90
91
92
93
94
95
96
97

    def _hookexec(self, hook, methods, kwargs):
        # called from all hookcaller instances.
        # enable_tracing will set its own wrapping function at self._inner_hookexec
        return self._inner_hookexec(hook, methods, kwargs)

    def register(self, plugin, name=None):
        """ Register a plugin and return its canonical name or ``None`` if the name
        is blocked from registering.  Raise a :py:class:`ValueError` if the plugin
pluggy/hooks.py line 286
282
283
284
285
286
287
288
289
290
                    "Argument(s) {} which are declared in the hookspec "
                    "can not be found in this hook call".format(tuple(notincall)),
                    stacklevel=2,
                )
        return self._hookexec(self, self.get_hookimpls(), kwargs)

    def call_historic(self, result_callback=None, kwargs=None, proc=None):
        """Call the hook with given ``kwargs`` for all registered plugins and
        for all plugins which will be registered afterwards.
_pytest/main.py line 272
268
269
270
271
272
273
274
275
276
        return True

    for i, item in enumerate(session.items):
        nextitem = session.items[i + 1] if i + 1 < len(session.items) else None
        item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
        if session.shouldfail:
            raise session.Failed(session.shouldfail)
        if session.shouldstop:
            raise session.Interrupted(session.shouldstop)
pluggy/callers.py line 187
183
184
185
186
187
188
189
190
191
                        teardowns.append(gen)
                    except StopIteration:
                        _raise_wrapfail(gen, "did not yield")
                else:
                    res = hook_impl.function(*args)
                    if res is not None:
                        results.append(res)
                        if firstresult:  # halt further impl calls
                            break
pluggy/manager.py line 84
80
81
82
83
84
85
86
87
88
                DeprecationWarning,
                stacklevel=2,
            )
        self._implprefix = implprefix
        self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
            methods,
            kwargs,
            firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
        )
pluggy/manager.py line 93
89
90
91
92
93
94
95
96
97

    def _hookexec(self, hook, methods, kwargs):
        # called from all hookcaller instances.
        # enable_tracing will set its own wrapping function at self._inner_hookexec
        return self._inner_hookexec(hook, methods, kwargs)

    def register(self, plugin, name=None):
        """ Register a plugin and return its canonical name or ``None`` if the name
        is blocked from registering.  Raise a :py:class:`ValueError` if the plugin
pluggy/hooks.py line 286
282
283
284
285
286
287
288
289
290
                    "Argument(s) {} which are declared in the hookspec "
                    "can not be found in this hook call".format(tuple(notincall)),
                    stacklevel=2,
                )
        return self._hookexec(self, self.get_hookimpls(), kwargs)

    def call_historic(self, result_callback=None, kwargs=None, proc=None):
        """Call the hook with given ``kwargs`` for all registered plugins and
        for all plugins which will be registered afterwards.
_pytest/main.py line 247
243
244
245
246
247
248
249
250
251
def _main(config: Config, session: "Session") -> Optional[Union[int, ExitCode]]:
    """ default command line protocol for initialization, session,
    running tests and reporting. """
    config.hook.pytest_collection(session=session)
    config.hook.pytest_runtestloop(session=session)

    if session.testsfailed:
        return ExitCode.TESTS_FAILED
    elif session.testscollected == 0:
_pytest/main.py line 191
187
188
189
190
191
192
193
194
195
            config._do_configure()
            initstate = 1
            config.hook.pytest_sessionstart(session=session)
            initstate = 2
            session.exitstatus = doit(config, session) or 0
        except UsageError:
            session.exitstatus = ExitCode.USAGE_ERROR
            raise
        except Failed:
_pytest/main.py line 240
236
237
238
239
240
241
242
243
244
    return session.exitstatus


def pytest_cmdline_main(config):
    return wrap_session(config, _main)


def _main(config: Config, session: "Session") -> Optional[Union[int, ExitCode]]:
    """ default command line protocol for initialization, session,
pluggy/callers.py line 187
183
184
185
186
187
188
189
190
191
                        teardowns.append(gen)
                    except StopIteration:
                        _raise_wrapfail(gen, "did not yield")
                else:
                    res = hook_impl.function(*args)
                    if res is not None:
                        results.append(res)
                        if firstresult:  # halt further impl calls
                            break
pluggy/manager.py line 84
80
81
82
83
84
85
86
87
88
                DeprecationWarning,
                stacklevel=2,
            )
        self._implprefix = implprefix
        self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
            methods,
            kwargs,
            firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
        )
pluggy/manager.py line 93
89
90
91
92
93
94
95
96
97

    def _hookexec(self, hook, methods, kwargs):
        # called from all hookcaller instances.
        # enable_tracing will set its own wrapping function at self._inner_hookexec
        return self._inner_hookexec(hook, methods, kwargs)

    def register(self, plugin, name=None):
        """ Register a plugin and return its canonical name or ``None`` if the name
        is blocked from registering.  Raise a :py:class:`ValueError` if the plugin
pluggy/hooks.py line 286
282
283
284
285
286
287
288
289
290
                    "Argument(s) {} which are declared in the hookspec "
                    "can not be found in this hook call".format(tuple(notincall)),
                    stacklevel=2,
                )
        return self._hookexec(self, self.get_hookimpls(), kwargs)

    def call_historic(self, result_callback=None, kwargs=None, proc=None):
        """Call the hook with given ``kwargs`` for all registered plugins and
        for all plugins which will be registered afterwards.
_pytest/config/__init__.py line 124
120
121
122
123
124
125
126
127
128
                tw.line(line.rstrip(), red=True)
            return ExitCode.USAGE_ERROR
        else:
            try:
                ret = config.hook.pytest_cmdline_main(
                    config=config
                )  # type: Union[ExitCode, int]
                try:
                    return ExitCode(ret)
pytest/__main__.py line 7
3
4
5
6
7
"""
import pytest

if __name__ == "__main__":
    raise SystemExit(pytest.main())
/usr/lib/python3.9/runpy.py line 87
83
84
85
86
87
88
89
90
91
                       __doc__ = None,
                       __loader__ = loader,
                       __package__ = pkg_name,
                       __spec__ = mod_spec)
    exec(code, run_globals)
    return run_globals

def _run_module_code(code, init_globals=None,
                    mod_name=None, mod_spec=None,
/usr/lib/python3.9/runpy.py line 197
193
194
195
196
197
198
199
200
201
        sys.exit(msg)
    main_globals = sys.modules["__main__"].__dict__
    if alter_argv:
        sys.argv[0] = mod_spec.origin
    return _run_code(code, main_globals, None,
                     "__main__", mod_spec)

def run_module(mod_name, init_globals=None,
               run_name=None, alter_sys=False):