mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Summary: Action following https://github.com/pytorch/pytorch/issues/66232 Pull Request resolved: https://github.com/pytorch/pytorch/pull/67552 Reviewed By: jbschlosser Differential Revision: D32028248 Pulled By: janeyx99 fbshipit-source-id: a006f7026288b7126dba58b31cac28e10ce0fed6
23 lines
823 B
Python
23 lines
823 B
Python
# Owner(s): ["module: unknown"]
|
|
|
|
import torch
|
|
from torch.testing._internal.common_utils import TestCase, run_tests
|
|
|
|
|
|
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.assertRegexpMatches(s, "PYTORCH_API_USAGE.*import")
|
|
# import the shared library directly - it triggers static init but doesn't call anything
|
|
s = TestCase.runWithPytorchAPIUsageStderr("from ctypes import CDLL; CDLL('{}')".format(torch._C.__file__))
|
|
self.assertNotRegexpMatches(s, "PYTORCH_API_USAGE")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
run_tests()
|