summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-12-14 01:17:16 -0800
committerZac Medico <zmedico@gentoo.org>2011-12-14 01:17:16 -0800
commitb898440e35aa96cd50c74b13d26d5924d2d708ed (patch)
tree47585270b842f13f53bdeea988845bca0896e3eb
parent2dbb9bb3bdb826a7da41ba1ccd89f4f8c8ee529c (diff)
downloadportage-b898440e35aa96cd50c74b13d26d5924d2d708ed.tar.gz
portage-b898440e35aa96cd50c74b13d26d5924d2d708ed.tar.bz2
portage-b898440e35aa96cd50c74b13d26d5924d2d708ed.zip
tests/locks: save/restore global env state
This ensures that global __PORTAGE_TEST_HARDLINK_LOCKS overrides work correctly for all tests.
-rw-r--r--pym/portage/tests/locks/test_asynchronous_lock.py12
-rw-r--r--pym/portage/tests/locks/test_lock_nonblock.py3
2 files changed, 15 insertions, 0 deletions
diff --git a/pym/portage/tests/locks/test_asynchronous_lock.py b/pym/portage/tests/locks/test_asynchronous_lock.py
index c896cb45c..49dd10ec4 100644
--- a/pym/portage/tests/locks/test_asynchronous_lock.py
+++ b/pym/portage/tests/locks/test_asynchronous_lock.py
@@ -43,11 +43,14 @@ class AsynchronousLockTestCase(TestCase):
self._testAsynchronousLock()
def testAsynchronousLockHardlink(self):
+ prev_state = os.environ.pop("__PORTAGE_TEST_HARDLINK_LOCKS", None)
os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"] = "1"
try:
self._testAsynchronousLock()
finally:
os.environ.pop("__PORTAGE_TEST_HARDLINK_LOCKS", None)
+ if prev_state is not None:
+ os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"] = prev_state
def _testAsynchronousLockWait(self):
scheduler = PollScheduler().sched_iface
@@ -81,11 +84,14 @@ class AsynchronousLockTestCase(TestCase):
self._testAsynchronousLockWait()
def testAsynchronousLockWaitHardlink(self):
+ prev_state = os.environ.pop("__PORTAGE_TEST_HARDLINK_LOCKS", None)
os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"] = "1"
try:
self._testAsynchronousLockWait()
finally:
os.environ.pop("__PORTAGE_TEST_HARDLINK_LOCKS", None)
+ if prev_state is not None:
+ os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"] = prev_state
def _testAsynchronousLockWaitCancel(self):
scheduler = PollScheduler().sched_iface
@@ -116,11 +122,14 @@ class AsynchronousLockTestCase(TestCase):
self._testAsynchronousLockWaitCancel()
def testAsynchronousLockWaitCancelHardlink(self):
+ prev_state = os.environ.pop("__PORTAGE_TEST_HARDLINK_LOCKS", None)
os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"] = "1"
try:
self._testAsynchronousLockWaitCancel()
finally:
os.environ.pop("__PORTAGE_TEST_HARDLINK_LOCKS", None)
+ if prev_state is not None:
+ os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"] = prev_state
def _testAsynchronousLockWaitKill(self):
scheduler = PollScheduler().sched_iface
@@ -157,8 +166,11 @@ class AsynchronousLockTestCase(TestCase):
self._testAsynchronousLockWaitKill()
def testAsynchronousLockWaitKillHardlink(self):
+ prev_state = os.environ.pop("__PORTAGE_TEST_HARDLINK_LOCKS", None)
os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"] = "1"
try:
self._testAsynchronousLockWaitKill()
finally:
os.environ.pop("__PORTAGE_TEST_HARDLINK_LOCKS", None)
+ if prev_state is not None:
+ os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"] = prev_state
diff --git a/pym/portage/tests/locks/test_lock_nonblock.py b/pym/portage/tests/locks/test_lock_nonblock.py
index 914084ca7..17f854dbe 100644
--- a/pym/portage/tests/locks/test_lock_nonblock.py
+++ b/pym/portage/tests/locks/test_lock_nonblock.py
@@ -48,9 +48,12 @@ class LockNonblockTestCase(TestCase):
self._testLockNonblock()
def testLockNonblockHardlink(self):
+ prev_state = os.environ.pop("__PORTAGE_TEST_HARDLINK_LOCKS", None)
os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"] = "1"
try:
self._testLockNonblock()
finally:
os.environ.pop("__PORTAGE_TEST_HARDLINK_LOCKS", None)
+ if prev_state is not None:
+ os.environ["__PORTAGE_TEST_HARDLINK_LOCKS"] = prev_state