FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu Server Development

 
 
LinkBack Thread Tools
 
Old 07-29-2011, 02:59 PM
Chris Lumens
 
Default Delete the Mocked pyanaconda.product to fix product tests.

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@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 06:20 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org