Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Unit testing errors (testing the platform module)

Reply
Thread Tools

Unit testing errors (testing the platform module)

 
 
John Maclean
Guest
Posts: n/a
 
      04-13-2010
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'>"

----------------------------------------------------------------------
Ran 1 test in 0.000s

FAILED (failures=1)

--
John Maclean MSc. (DIC) Bsc. (Hons),Core Linux Systems Engineering,07739
171 531
 
Reply With Quote
 
 
 
 
Martin P. Hellwig
Guest
Posts: n/a
 
      04-13-2010
On 04/13/10 15:01, John Maclean wrote:
> 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'>"
>
> ----------------------------------------------------------------------
> Ran 1 test in 0.000s
>
> FAILED (failures=1)
>


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__.__clas s__), "<type 'dict'>")

--
mph

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Webinar - Testing the Untestable - Unit Testing Dependencies andLegacy Code (in C++) Avi C Programming 0 06-11-2012 01:55 PM
[ANN] Webinar - Testing the Untestable - Unit Testing Dependenciesand Legacy Code in C++ Avi C++ 0 06-06-2012 11:25 AM
unit-profiling, similar to unit-testing Ulrich Eckhardt Python 6 11-18-2011 02:00 AM
Test::Unit - Ruby Unit Testing Framework Questions Bill Mosteller Ruby 0 10-22-2009 02:02 PM
Errors, errors, errors Mark Goldin ASP .Net 2 01-17-2004 08:05 PM



Advertisments