diff options
| author | deshevoy <[email protected]> | 2022-02-10 16:46:57 +0300 | 
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:46:57 +0300 | 
| commit | 28148f76dbfcc644d96427d41c92f36cbf2fdc6e (patch) | |
| tree | b83306b6e37edeea782e9eed673d89286c4fef35 /library/python/pytest/plugins | |
| parent | e988f30484abe5fdeedcc7a5d3c226c01a21800c (diff) | |
Restoring authorship annotation for <[email protected]>. Commit 2 of 2.
Diffstat (limited to 'library/python/pytest/plugins')
| -rw-r--r-- | library/python/pytest/plugins/collection.py | 20 | ||||
| -rw-r--r-- | library/python/pytest/plugins/conftests.py | 22 | ||||
| -rw-r--r-- | library/python/pytest/plugins/ya.py | 38 | 
3 files changed, 40 insertions, 40 deletions
diff --git a/library/python/pytest/plugins/collection.py b/library/python/pytest/plugins/collection.py index dad830e4736..e36f47a78f3 100644 --- a/library/python/pytest/plugins/collection.py +++ b/library/python/pytest/plugins/collection.py @@ -18,14 +18,14 @@ class LoadedModule(_pytest.python.Module):          self.parent = parent          self.config = parent.config          self.keywords = {} -        self.own_markers = []  +        self.own_markers = []          self.fspath = py.path.local()      @classmethod      def from_parent(cls, **kwargs):          namespace = kwargs.pop('namespace', True)          kwargs.setdefault('fspath', py.path.local()) -  +          loaded_module = getattr(super(LoadedModule, cls), 'from_parent', cls)(**kwargs)          loaded_module.namespace = namespace @@ -44,7 +44,7 @@ class LoadedModule(_pytest.python.Module):      def _getobj(self):          module_name = self.name[:-len('.py')] -        if self.namespace:  +        if self.namespace:              module_name = '__tests__.' + module_name          __import__(module_name)          return sys.modules[module_name] @@ -54,13 +54,13 @@ class DoctestModule(LoadedModule):      def collect(self):          import doctest -  -        module = self._getobj()  -        # uses internal doctest module parsing mechanism  + +        module = self._getobj() +        # uses internal doctest module parsing mechanism          finder = doctest.DocTestFinder()          optionflags = _pytest.doctest.get_optionflags(self)          runner = doctest.DebugRunner(verbose=0, optionflags=optionflags) -  +          try:              for test in finder.find(module, self.name[:-len('.py')]):                  if test.examples:  # skip empty doctests @@ -94,9 +94,9 @@ def pytest_ignore_collect(module, session, filenames_from_full_filters, accept_f  class CollectionPlugin(object): -    def __init__(self, test_modules, doctest_modules):  +    def __init__(self, test_modules, doctest_modules):          self._test_modules = test_modules -        self._doctest_modules = doctest_modules  +        self._doctest_modules = doctest_modules      def pytest_sessionstart(self, session): @@ -124,5 +124,5 @@ class CollectionPlugin(object):              if os.environ.get('YA_PYTEST_DISABLE_DOCTEST', 'no') == 'no':                  for doctest_module in self._doctest_modules:                      yield DoctestModule.from_parent(name=doctest_module, parent=session, namespace=False) -  +          session.collect = collect diff --git a/library/python/pytest/plugins/conftests.py b/library/python/pytest/plugins/conftests.py index 96456da28c8..522041f5a7c 100644 --- a/library/python/pytest/plugins/conftests.py +++ b/library/python/pytest/plugins/conftests.py @@ -23,23 +23,23 @@ conftest_modules = []  @hookimpl(trylast=True)  def pytest_load_initial_conftests(early_config, parser, args): -    conftests = filter(lambda name: name.endswith(".conftest"), sys.extra_modules)  +    conftests = filter(lambda name: name.endswith(".conftest"), sys.extra_modules) -    def conftest_key(name):  -        if not name.startswith("__tests__."):  -            # Make __tests__ come last  -            return "_." + name  -        return name  +    def conftest_key(name): +        if not name.startswith("__tests__."): +            # Make __tests__ come last +            return "_." + name +        return name -    for name in sorted(conftests, key=conftest_key):  -        mod = importlib.import_module(name)  +    for name in sorted(conftests, key=conftest_key): +        mod = importlib.import_module(name)          if os.getenv("CONFTEST_LOAD_POLICY") != "LOCAL":              mod.__orig_file__ = mod.__file__              mod.__file__ = "" -        conftest_modules.append(mod)  +        conftest_modules.append(mod)          early_config.pluginmanager.consider_conftest(mod) -  -  + +  def getconftestmodules(*args, **kwargs):      return conftest_modules diff --git a/library/python/pytest/plugins/ya.py b/library/python/pytest/plugins/ya.py index 0dfbb7c2748..1bde03042d4 100644 --- a/library/python/pytest/plugins/ya.py +++ b/library/python/pytest/plugins/ya.py @@ -185,7 +185,7 @@ def pytest_configure(config):      global pytest_config      pytest_config = config -    config.option.continue_on_collection_errors = True  +    config.option.continue_on_collection_errors = True      config.addinivalue_line("markers", "ya:external") @@ -523,9 +523,9 @@ def pytest_collectreport(report):              sys.stderr.write(yatest_lib.tools.to_utf8(report.longrepr)) -def pytest_pyfunc_call(pyfuncitem):  -    testfunction = pyfuncitem.obj  +def pytest_pyfunc_call(pyfuncitem): +    testfunction = pyfuncitem.obj      iscoroutinefunction = getattr(inspect, "iscoroutinefunction", None)      if iscoroutinefunction is not None and iscoroutinefunction(testfunction):          msg = "Coroutine functions are not natively supported and have been skipped.\n" @@ -538,9 +538,9 @@ def pytest_pyfunc_call(pyfuncitem):      funcargs = pyfuncitem.funcargs      testargs = {arg: funcargs[arg] for arg in pyfuncitem._fixtureinfo.argnames}      pyfuncitem.retval = testfunction(**testargs) -    return True  -  -  +    return True + +  @pytest.hookimpl(hookwrapper=True)  def pytest_runtest_makereport(item, call):      def logreport(report, result, call): @@ -575,8 +575,8 @@ def pytest_runtest_makereport(item, call):      outcome = yield      rep = outcome.get_result()      result = None -    if hasattr(item, 'retval') and item.retval is not None:  -        result = item.retval  +    if hasattr(item, 'retval') and item.retval is not None: +        result = item.retval          if not pytest_config.from_ya_test:              ti = TestItem(rep, result, pytest_config.option.test_suffix)              tr = pytest_config.pluginmanager.getplugin('terminalreporter') @@ -584,13 +584,13 @@ def pytest_runtest_makereport(item, call):      logreport(rep, result, call) -def pytest_make_parametrize_id(config, val, argname):  -    # Avoid <, > symbols in canondata file names  -    if inspect.isfunction(val) and val.__name__ == "<lambda>":  -        return str(argname)  -    return None  -  -  +def pytest_make_parametrize_id(config, val, argname): +    # Avoid <, > symbols in canondata file names +    if inspect.isfunction(val) and val.__name__ == "<lambda>": +        return str(argname) +    return None + +  def get_formatted_error(report):      if isinstance(report.longrepr, tuple):          text = "" @@ -692,7 +692,7 @@ class TestItem(object):          return self._error      def set_error(self, entry, marker='bad'): -        if isinstance(entry, _pytest.reports.BaseReport):  +        if isinstance(entry, _pytest.reports.BaseReport):              self._error = get_formatted_error(entry)          else:              self._error = "[[{}]]{}".format(yatest_lib.tools.to_str(marker), yatest_lib.tools.to_str(entry)) @@ -827,9 +827,9 @@ class TraceReportGenerator(object):          self.trace('subtest-started', message)      def on_finish_test_case(self, test_item, duration_only=False): -        if test_item.result is not None:  +        if test_item.result is not None:              try: -                result = canon.serialize(test_item.result)  +                result = canon.serialize(test_item.result)              except Exception as e:                  yatest_logger.exception("Error while serializing test results")                  test_item.set_error("Invalid test result: {}".format(e))  | 
