[master] ut: product_test.py should not fail if executed by itself.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Do the sys.modules magic in setup and be mindful.

Also see ca27378ad0229c66c3bbcbd6636f2e555c2d6db8.
---
 tests/pyanaconda_test/product_test.py |   10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/tests/pyanaconda_test/product_test.py b/tests/pyanaconda_test/product_test.py
index 9fd37a5..9b0d864 100644
--- a/tests/pyanaconda_test/product_test.py
+++ b/tests/pyanaconda_test/product_test.py
@@ -43,44 +43,40 @@ class ProductTest(mock.TestCase):
         self.open = __builtin__.open
         __builtin__.open = self.fs.open
 
+        if 'pyanaconda.product' in sys.modules:
+            del(sys.modules["pyanaconda.product"])
+
     def tearDown(self):
         __builtin__.open = self.open
         self.tearDownModules()
 
-
     def bug_url_test(self):
         sys.modules['os'].access = mock.Mock(return_value=True)
-        del(sys.modules["pyanaconda.product"])
         import pyanaconda.product
         self.assertEqual(pyanaconda.product.bugUrl, self.BUGURL)
 
     def is_final_test(self):
         sys.modules['os'].access = mock.Mock(return_value=True)
-        del(sys.modules["pyanaconda.product"])
         import pyanaconda.product
         self.assertFalse(pyanaconda.product.isFinal)
 
     def product_arch_test(self):
         sys.modules['os'].access = mock.Mock(return_value=True)
-        del(sys.modules["pyanaconda.product"])
         import pyanaconda.product
         self.assertEqual(pyanaconda.product.productArch, self.ARCH)
 
     def product_name_test(self):
         sys.modules['os'].access = mock.Mock(return_value=True)
-        del(sys.modules["pyanaconda.product"])
         import pyanaconda.product
         self.assertEqual(pyanaconda.product.productName, self.NAME)
 
     def product_stamp_test(self):
         sys.modules['os'].access = mock.Mock(return_value=True)
-        del(sys.modules["pyanaconda.product"])
         import pyanaconda.product
         self.assertEqual(pyanaconda.product.productStamp, self.UUID)
 
     def product_version_test(self):
         sys.modules['os'].access = mock.Mock(return_value=True)
-        del(sys.modules["pyanaconda.product"])
         import pyanaconda.product
         self.assertEqual(pyanaconda.product.productVersion, self.VERSION)
 
-- 
1.7.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux