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