Skip to content

Commit

Permalink
Okay just do torch tests in a single test (#499)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaogaotiantian authored Nov 11, 2024
1 parent 8e47035 commit 70980f8
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions tests/test_torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,18 @@

@package_matrix(["~torch", "torch"] if sys.version_info < (3, 13) or "linux" in sys.platform else ["~torch"])
class TestTorch(CmdlineTmpl):
def test_basic(self):
def test_entry(self):
# We only want to install/uninstall torch once, so do all tests in one function
with self.subTest("basic"):
self.case_basic()

with self.subTest("cmdline"):
self.case_cmdline()

with self.subTest("corner"):
self.case_corner()

def case_basic(self):
assert self.pkg_config is not None

if self.pkg_config.has("torch"):
Expand All @@ -37,7 +48,7 @@ def check_func(data):
expected_output_file=None, success=False,
expected_stderr=".*ModuleNotFoundError.*")

def test_cmdline(self):
def case_cmdline(self):
assert self.pkg_config is not None

if self.pkg_config.has("torch"):
Expand All @@ -56,7 +67,7 @@ def check_func(data):
else:
self.template(["viztracer", "--log_torch", "cmdline_test.py"], script="pass", success=False)

def test_corner(self):
def case_corner(self):
assert self.pkg_config is not None

if self.pkg_config.has("torch"):
Expand Down

0 comments on commit 70980f8

Please sign in to comment.