mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Fixes some files in #123062 Run lintrunner on files: test/license.py test/logging.py ```bash $ lintrunner -a --take UFMT --all-files ok No lint issues. Successfully applied all patches. ``` Co-authored-by: Nikita Shulga <2453524+malfet@users.noreply.github.com> Pull Request resolved: https://github.com/pytorch/pytorch/pull/125737 Approved by: https://github.com/ezyang, https://github.com/malfet
25 lines
821 B
Python
25 lines
821 B
Python
# Owner(s): ["module: unknown"]
|
|
|
|
import torch
|
|
from torch.testing._internal.common_utils import run_tests, TestCase
|
|
|
|
|
|
class LoggingTest(TestCase):
|
|
def testApiUsage(self):
|
|
"""
|
|
This test verifies that api usage logging is not triggered via static
|
|
initialization. Since it's triggered at first invocation only - we just
|
|
subprocess
|
|
"""
|
|
s = TestCase.runWithPytorchAPIUsageStderr("import torch")
|
|
self.assertRegex(s, "PYTORCH_API_USAGE.*import")
|
|
# import the shared library directly - it triggers static init but doesn't call anything
|
|
s = TestCase.runWithPytorchAPIUsageStderr(
|
|
f"from ctypes import CDLL; CDLL('{torch._C.__file__}')"
|
|
)
|
|
self.assertNotRegex(s, "PYTORCH_API_USAGE")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
run_tests()
|