mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
extract out the clean workspace test to its own file (#88682)
Summary: This test relies on what the root workspace is before any other code is run. However, some of the test cases change it. If the order the tests are run is randomized, then the test can fail if run after one of them. Having it on its own ensures that it always sees a pristine state. Test Plan: Verified locally and confirmed in internal and external CI. Reviewers: Subscribers: Tasks: Tags: Pull Request resolved: https://github.com/pytorch/pytorch/pull/88682 Approved by: https://github.com/r-barnes, https://github.com/malfet
This commit is contained in:
parent
c19bae9f84
commit
3150c9dc6f
15
caffe2/python/clean_workspace_test.py
Normal file
15
caffe2/python/clean_workspace_test.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import unittest
|
||||
|
||||
from caffe2.python import workspace
|
||||
|
||||
|
||||
# This test is extracted out from workspace_test.py because it relies on the pristine
|
||||
# state of the initial workspace. When tests are run in different orders, this test may
|
||||
# become flaky because of global state modifications impacting what the root folder is
|
||||
# after a reset.
|
||||
class TestWorkspace(unittest.TestCase):
|
||||
def testRootFolder(self):
|
||||
self.assertEqual(workspace.ResetWorkspace(), True)
|
||||
self.assertEqual(workspace.RootFolder(), ".")
|
||||
self.assertEqual(workspace.ResetWorkspace("/tmp/caffe-workspace-test"), True)
|
||||
self.assertEqual(workspace.RootFolder(), "/tmp/caffe-workspace-test")
|
||||
|
|
@ -24,12 +24,6 @@ class TestWorkspace(unittest.TestCase):
|
|||
)
|
||||
workspace.ResetWorkspace()
|
||||
|
||||
def testRootFolder(self):
|
||||
self.assertEqual(workspace.ResetWorkspace(), True)
|
||||
self.assertEqual(workspace.RootFolder(), ".")
|
||||
self.assertEqual(workspace.ResetWorkspace("/tmp/caffe-workspace-test"), True)
|
||||
self.assertEqual(workspace.RootFolder(), "/tmp/caffe-workspace-test")
|
||||
|
||||
def testWorkspaceHasBlobWithNonexistingName(self):
|
||||
self.assertEqual(workspace.HasBlob("non-existing"), False)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user