Beispiel #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')
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')
 def __init__(self, path, time, user):
     self.time = time
     self.user = user
     LockFile.__init__(self, path)
 def setUp(self):
     self._lock_file = LockFile('none')
     self.orig_username = os.environ.get('USERNAME', None)
Beispiel #5
0
 def __init__(self, path, time, user):
     self.time = time
     self.user = user
     LockFile.__init__(self, path)
Beispiel #6
0
 def setUp(self):
     self._lock_file = LockFile('none')
     self.orig_username = os.environ.get('USERNAME', None)