UFMT formatting on test/autograd test/ao test/cpp test/backends (#123369)

Partially addresses #123062

Ran lintrunner on
- test/_test_bazel.py
- test/ao
- test/autograd test/backends test/benchmark_uitls test/conftest.py test/bottleneck_test test/cpp

Pull Request resolved: https://github.com/pytorch/pytorch/pull/123369
Approved by: https://github.com/huydhn
This commit is contained in:
Arun Pa
2024-04-05 18:51:38 +00:00
committed by PyTorch MergeBot
parent de7edeea25
commit f71e368969
23 changed files with 1914 additions and 1035 deletions

View File

@ -1,25 +1,24 @@
from _pytest.junitxml import LogXML, _NodeReporter, bin_xml_escape
from _pytest.terminal import _get_raw_skip_reason
from _pytest.stash import StashKey
from _pytest.reports import TestReport
from _pytest.config.argparsing import Parser
from _pytest.config import filename_arg
from _pytest.config import Config
from _pytest._code.code import ReprFileLocation
from _pytest.python import Module
from typing import Any, List, Union
from typing import Optional
from types import MethodType
import xml.etree.ElementTree as ET
import functools
import pytest
import sys
import os
import copy
import functools
import json
import os
import re
import sys
import xml.etree.ElementTree as ET
from collections import defaultdict
from pytest_shard_custom import PytestShardPlugin, pytest_addoptions as shard_addoptions
from types import MethodType
from typing import Any, List, Optional, Union
import pytest
from _pytest._code.code import ReprFileLocation
from _pytest.config import Config, filename_arg
from _pytest.config.argparsing import Parser
from _pytest.junitxml import _NodeReporter, bin_xml_escape, LogXML
from _pytest.python import Module
from _pytest.reports import TestReport
from _pytest.stash import StashKey
from _pytest.terminal import _get_raw_skip_reason
from pytest_shard_custom import pytest_addoptions as shard_addoptions, PytestShardPlugin
# a lot of this file is copied from _pytest.junitxml and modified to get rerun info
@ -42,7 +41,7 @@ def pytest_addoption(parser: Parser) -> None:
dest="stepcurrent",
)
parser.addoption("--use-main-module", action='store_true')
parser.addoption("--use-main-module", action="store_true")
group = parser.getgroup("terminal reporting")
group.addoption(
"--junit-xml-reruns",
@ -143,11 +142,14 @@ class _NodeReporterReruns(_NodeReporter):
skipreason = skipreason[9:]
details = f"{filename}:{lineno}: {skipreason}"
skipped = ET.Element("skipped", type="pytest.skip", message=bin_xml_escape(skipreason))
skipped = ET.Element(
"skipped", type="pytest.skip", message=bin_xml_escape(skipreason)
)
skipped.text = bin_xml_escape(details)
self.append(skipped)
self.write_captured_output(report)
class LogXMLReruns(LogXML):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@ -223,7 +225,7 @@ def pytest_terminal_summary(terminalreporter, exitstatus, config):
def pytest_pycollect_makemodule(module_path, path, parent) -> Module:
if parent.config.getoption("--use-main-module"):
mod = Module.from_parent(parent, path=module_path)
mod._getobj = MethodType(lambda x: sys.modules['__main__'], mod)
mod._getobj = MethodType(lambda x: sys.modules["__main__"], mod)
return mod
@ -275,7 +277,10 @@ def pytest_collection_modifyitems(items: List[Any]) -> None:
test_name = item.name
test_class = item.parent.name
if test_class not in disabled_tests or test_name not in disabled_tests[test_class]:
if (
test_class not in disabled_tests
or test_name not in disabled_tests[test_class]
):
continue
cpy = copy.copy(item)