mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/30445 Create distributed and rpc directories under caffe/test for better management of unit tests. Differential Revision: D18702786 fbshipit-source-id: e9daeed0cfb846ef68806f6decfcb57c0e0e3606
21 lines
790 B
Python
21 lines
790 B
Python
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()
|