mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/71708 In Python 3.2, a number of asserts were deprecated. In Python 3.11, these asserts are deleted completely. The files in this change still use the deprecated asserts. Switch over to the supported syntax for 3.2 onwards. Test Plan: Tested on the internal test suite runner. Reviewed By: ajtulloch Differential Revision: D33503694 fbshipit-source-id: a150f296033260acf8365d77b837ce0679f57361 (cherry picked from commit abf60ed97409265222915d8265aaabedd625fd93)
23 lines
807 B
Python
23 lines
807 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.assertRegex(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.assertNotRegex(s, "PYTORCH_API_USAGE")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
run_tests()
|