in the code from mox example on their page [http://code.google.com/p/pymox/wiki/MoxDocumentation] where does PersonDao comes from ?

import unittest
import mox

class DaoUnitTest(unittest.TestCase):

  def setUp(self):
    # Create an instance of Mox
    self.person_mocker = mox.Mox()

  def testUsingMox(self):
    # Create a mock PersonDao
    dao = self.person_mocker.CreateMock(PersonDao)

    # Return a value when this method is called
    dao.InsertPerson(test_person).AndReturn(test_primary_key)

    # Void method
    dao.UpdatePerson(test_person)

    # Raise an exception when this is called
    dao.DeletePerson(unknown_person).AndRaise(UnknownPersonError('id not found'))

    # Put all mocks created by mox into replay mode
    self.person_mocker.ReplayAll()

    # Run the test
    ret_pk = dao.InsertPerson(test_person)
    dao.UpdatePerson(test_person)
    self.assertRaises(UnknownPersonError, dao, unknown_person)

    # Verify all mocks were used as expected, and tests ran properly
    self.person_mocker.VerifyAll()
    self.assertEquals(test_primary_key, ret_pk)

I guess to mock an object I would have to call unitest.main() how do I proced with it ?

aww man...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.