mojo/public/tools/mojom/mojom/fileutil_unittest.py
def testEnsureDirectoryExists(self):
    """Test that EnsureDirectoryExists fuctions correctly."""

    temp_dir = tempfile.mkdtemp()
    try:
      self.assertTrue(os.path.exists(temp_dir))

      # Directory does not exist, yet.
      full = os.path.join(temp_dir, "foo", "bar")
      self.assertFalse(os.path.exists(full))

      # Create the directory.
      fileutil.EnsureDirectoryExists(full)
      self.assertTrue(os.path.exists(full))

      # Trying to create it again does not cause an error.
      fileutil.EnsureDirectoryExists(full)
      self.assertTrue(os.path.exists(full))

      # Bypass check for directory existence to tickle error handling that
      # occurs in response to a race.
      fileutil.EnsureDirectoryExists(full, always_try_to_create=True)
      self.assertTrue(os.path.exists(full))
    finally:
      shutil.rmtree(temp_dir)
Test that EnsureDirectoryExists fuctions correctly.
Test that EnsureDirectoryExists fuctions correctly.
Test that EnsureDirectoryExists fuctions correctly .
def testEnsureDirectoryExists(self):
    temp_dir = tempfile.mkdtemp()
    try:
      self.assertTrue(os.path.exists(temp_dir))
      full = os.path.join(temp_dir, "foo", "bar")
      self.assertFalse(os.path.exists(full))
      fileutil.EnsureDirectoryExists(full)
      self.assertTrue(os.path.exists(full))
      fileutil.EnsureDirectoryExists(full)
      self.assertTrue(os.path.exists(full))
      fileutil.EnsureDirectoryExists(full, always_try_to_create=True)
      self.assertTrue(os.path.exists(full))
    finally:
      shutil.rmtree(temp_dir)
def testEnsureDirectoryExists ( self ) : temp_dir = tempfile . mkdtemp ( ) try : self . assertTrue ( os . path . exists ( temp_dir ) ) full = os . path . join ( temp_dir , "foo" , "bar" ) self . assertFalse ( os . path . exists ( full ) ) fileutil . EnsureDirectoryExists ( full ) self . assertTrue ( os . path . exists ( full ) ) fileutil . EnsureDirectoryExists ( full ) self . assertTrue ( os . path . exists ( full ) ) fileutil . EnsureDirectoryExists ( full , always_try_to_create = True ) self . assertTrue ( os . path . exists ( full ) ) finally : shutil . rmtree ( temp_dir )
Test that EnsureDirectoryExists fuctions correctly.
Test that EnsureDirectoryExists fuctions correctly .
"""Test that EnsureDirectoryExists fuctions correctly.""" # Directory does not exist, yet. # Create the directory. # Trying to create it again does not cause an error. # Bypass check for directory existence to tickle error handling that # occurs in response to a race.
self