Skip to content

Commit

Permalink
cleanup test parametrization (#113855)
Browse files Browse the repository at this point in the history
Cleanup from #113340 (comment).

```
❯ pytest test/dynamo/test_export.py -k test_access_class_method_from_user_class --co -q
test/dynamo/test_export.py::ExportTests::test_access_class_method_from_user_class_attr
test/dynamo/test_export.py::ExportTests::test_access_class_method_from_user_class_builtin
```

Pull Request resolved: #113855
Approved by: https://github.com/lezcano, https://github.com/huydhn
  • Loading branch information
pmeier authored and pytorchmergebot committed Nov 16, 2023
1 parent 277229d commit 03bebd9
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions test/dynamo/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -2851,13 +2851,14 @@ def has_aten_op(gm, op):
with self.assertRaisesRegex(RuntimeError, "Shape must be more than 4"):
gm(torch.randn(3, 4, 5))

@common_utils.parametrize("type_access", ["builtin", "class"])
def test_access_class_method_from_user_class(self, type_access):
if type_access == "builtin":
type_fn = type
elif type_access == "class":
type_fn = lambda obj: obj.__class__ # noqa: E731

@common_utils.parametrize(
"type_fn",
[
common_utils.subtest(type, name="builtin"),
common_utils.subtest(lambda obj: obj.__class__, name="attr"),
],
)
def test_access_class_method_from_user_class(self, type_fn):
class A:
@classmethod
def func(cls):
Expand Down

0 comments on commit 03bebd9

Please sign in to comment.