Skip to content

Commit

Permalink
Add tests for TempfileManager
Browse files Browse the repository at this point in the history
  • Loading branch information
allenh1 committed Feb 28, 2018
1 parent 0ad268d commit b5763c7
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/test_TempfileManager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2018 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os

from superflore.TempfileManager import TempfileManager
import unittest

class TestTempfileManager(unittest.TestCase):
def test_create_specified(self):
"""Test making a directory in a legal location"""
with TempfileManager('/tmp/test') as ret:
self.assertEqual(ret, '/tmp/test')
# clean up
self.assertTrue(os.path.exists('/tmp/test'))
os.rmdir('/tmp/test')

def test_failed_to_create(self):
"""Test making a directory in a bad location"""
with self.assertRaises(OSError):
with TempfileManager('/root/bad_permissions') as tmp:
# code should not enter here
pass

0 comments on commit b5763c7

Please sign in to comment.