mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
lint Pull Request resolved: https://github.com/pytorch/pytorch/pull/103450 Approved by: https://github.com/ezyang
28 lines
719 B
Python
28 lines
719 B
Python
# Owner(s): ["module: dynamo"]
|
|
"""
|
|
PYTEST_DONT_REWRITE (prevents pytest from rewriting assertions, which interferes
|
|
with test_export_persist_assert)
|
|
"""
|
|
|
|
import torch
|
|
import torch._dynamo
|
|
import torch._dynamo.test_case
|
|
import torch._dynamo.testing
|
|
from torch._dynamo.source import (
|
|
AttrSource,
|
|
GlobalSource,
|
|
is_from_local_source,
|
|
LocalSource,
|
|
)
|
|
|
|
|
|
class SourceTests(torch._dynamo.test_case.TestCase):
|
|
def test_is_local(self):
|
|
x_src = LocalSource("x")
|
|
y_src = GlobalSource("y")
|
|
|
|
attr_x_a = AttrSource(x_src, "a")
|
|
attr_y_b = AttrSource(y_src, "b")
|
|
|
|
self.assertTrue(is_from_local_source(attr_x_a))
|
|
self.assertEqual(is_from_local_source(attr_y_b), False)
|