Unit testing errors (testing the platform module)

J

John Maclean

I normally use languages unit testing framework to get a better
understanding of how a language works. Right now I want to grok the
platform module;


1 #!/usr/bin/env python
2 '''a pythonic factor'''
3 import unittest
4 import platform
5
6 class TestPyfactorTestCase(unittest.TestCase):
7 def setUp(self):
8 '''setting up stuff'''
13
14 def testplatformbuiltins(self): 15
'''platform.__builtins__.blah '''
16 self.assertEquals(platform.__builtins__.__class__, "<type 'd
ict'>")
17
18
19 def tearDown(self):
20 print 'cleaning stuff up'
21
22 if __name__ == "__main__":
23 unittest.main()


Is there an error in my syntax? Why is my test failing? Line 16.


python stfu/testing/test_pyfactor.py
Fcleaning stuff up

======================================================================
FAIL: platform.__builtins__.blah
 
M

Martin P. Hellwig

I normally use languages unit testing framework to get a better
understanding of how a language works. Right now I want to grok the
platform module;


1 #!/usr/bin/env python
2 '''a pythonic factor'''
3 import unittest
4 import platform
5
6 class TestPyfactorTestCase(unittest.TestCase):
7 def setUp(self):
8 '''setting up stuff'''
13
14 def testplatformbuiltins(self): 15
'''platform.__builtins__.blah '''
16 self.assertEquals(platform.__builtins__.__class__, "<type 'd
ict'>")
17
18
19 def tearDown(self):
20 print 'cleaning stuff up'
21
22 if __name__ == "__main__":
23 unittest.main()


Is there an error in my syntax? Why is my test failing? Line 16.


python stfu/testing/test_pyfactor.py
Fcleaning stuff up

======================================================================
FAIL: platform.__builtins__.blah
----------------------------------------------------------------------
Traceback (most recent call last):
File "stfu/testing/test_pyfactor.py", line 16, in testplatformbuiltins
self.assertEquals(platform.__builtins__.__class__, "<type 'dict'>")
AssertionError:<type 'dict'> != "<type 'dict'>"

What happens if you change this line:
self.assertEquals(platform.__builtins__.__class__, "<type 'dict'>")

To something like:
self.assertEquals(platform.__builtins__.__class__, type(dict()))

or
self.assertEquals(str(platform.__builtins__.__class__), "<type 'dict'>")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,962
Messages
2,570,134
Members
46,692
Latest member
JenniferTi

Latest Threads

Top