Unit testing errors (testing the platform module)

Discussion in 'Python' started by John Maclean, Apr 13, 2010.

  1. John Maclean

    John Maclean Guest

    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
     
    John Maclean, Apr 13, 2010
    #1
    1. Advertising

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

    --
    mph
     
    Martin P. Hellwig, Apr 13, 2010
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ulrich Eckhardt

    unit-profiling, similar to unit-testing

    Ulrich Eckhardt, Nov 16, 2011, in forum: Python
    Replies:
    6
    Views:
    349
    Roy Smith
    Nov 18, 2011
  2. Bill Mosteller
    Replies:
    0
    Views:
    239
    Bill Mosteller
    Oct 22, 2009
  3. Avi
    Replies:
    0
    Views:
    507
  4. Avi
    Replies:
    0
    Views:
    473
  5. James Harris

    C unit testing and regression testing

    James Harris, Aug 8, 2013, in forum: C Programming
    Replies:
    40
    Views:
    645
    Les Cargill
    Aug 17, 2013
Loading...

Share This Page