Example #1
0
class TestGetUser(unittest.TestCase):
    def setUp(self):
        self._lock_file = LockFile('none')
        self.orig_username = os.environ.get('USERNAME', None)

    def tearDown(self):
        if self.orig_username:
            os.environ['USERNAME'] = self.orig_username

    def test_get_user(self):
        os.environ['USERNAME'] = '******'
        self.assertEqual(self._lock_file._get_user(), 'user')

    def test_get_user_when_it_does_not_exist(self):
        os.environ.pop('USERNAME', 'default which prevents KeyError')
        self.assertEqual(self._lock_file._get_user(), 'Unknown')
Example #2
0
class TestGetUser(unittest.TestCase):

    def setUp(self):
        self._lock_file = LockFile('none')
        self.orig_username = os.environ.get('USERNAME', None)

    def tearDown(self):
        if self.orig_username:
            os.environ['USERNAME'] = self.orig_username

    def test_get_user(self):
        os.environ['USERNAME'] = '******'
        self.assertEqual(self._lock_file._get_user(), 'user')

    def test_get_user_when_it_does_not_exist(self):
        os.environ.pop('USERNAME', 'default which prevents KeyError')
        self.assertEqual(self._lock_file._get_user(), 'Unknown')
Example #3
0
 def __init__(self, path, time, user):
     self.time = time
     self.user = user
     LockFile.__init__(self, path)
Example #4
0
 def setUp(self):
     self._lock_file = LockFile('none')
     self.orig_username = os.environ.get('USERNAME', None)
Example #5
0
 def __init__(self, path, time, user):
     self.time = time
     self.user = user
     LockFile.__init__(self, path)
Example #6
0
 def setUp(self):
     self._lock_file = LockFile('none')
     self.orig_username = os.environ.get('USERNAME', None)