[PATCH 4/4] Delete the Mocked pyanaconda.product to fix product tests.

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

 



Since anaconda modules are such a tangle, running one of the earlier tests
causes pyanaconda.product to get imported early.  On that import, it gets
created as a Mock object, so the later import doesn't do anything useful and
all the product tests will therefore fail.  If we delete and then re-import,
everything will work.

This is only seen if you run everything in tests/, not if you just run the
product_test.py by itself.
---
 tests/pyanaconda_test/product_test.py |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/tests/pyanaconda_test/product_test.py b/tests/pyanaconda_test/product_test.py
index 5be51d3..9fd37a5 100644
--- a/tests/pyanaconda_test/product_test.py
+++ b/tests/pyanaconda_test/product_test.py
@@ -50,31 +50,37 @@ class ProductTest(mock.TestCase):
 
     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