MarkBerlin78 / pymox

Automatically exported from code.google.com/p/pymox
Apache License 2.0
0 stars 0 forks source link

StubOutWithMock does work if used more than twice #2

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use StubOutWithMock() to mock a module in 3 separate tests.

What is the expected output?
All tests to pass

What do you see instead?

Traceback (most recent call last):
  File
"/local/packages/eclipse-3.4/plugins/org.python.pydev.debug_1.3.18/pysrc/pydevd.
py",
line 583, in trace_dispatch
    filename, base = pydevd_file_utils.GetFilenameAndBase(frame)
  File
"/local/packages/eclipse-3.4/plugins/org.python.pydev.debug_1.3.18/pysrc/pydevd_
file_utils.py",
line 141, in GetFilenameAndBase
    filename = _NormFile(f)
  File
"/local/packages/eclipse-3.4/plugins/org.python.pydev.debug_1.3.18/pysrc/pydevd_
file_utils.py",
line 73, in _NormFile
    rPath = os.path.abspath
  File "/local/devel/PhotoMap2/test/mox.py", line 414, in __getattr__
Traceback (most recent call last):
  File
"/local/packages/eclipse-3.4/plugins/org.python.pydev.debug_1.3.18/pysrc/pydevd.
py",
line 852, in <module>
    debugger.run(setup['file'], None, None)
  File
"/local/packages/eclipse-3.4/plugins/org.python.pydev.debug_1.3.18/pysrc/pydevd.
py",
line 689, in run
    execfile(file, globals, locals) #execute the script
  File
"/local/packages/eclipse-3.4/plugins/org.python.pydev.debug_1.3.18/pysrc/runfile
s.py",
line 246, in <module>
    PydevTestRunner(dirs, test_filter, verbosity).run_tests()
  File
"/local/packages/eclipse-3.4/plugins/org.python.pydev.debug_1.3.18/pysrc/runfile
s.py",
line 238, in run_tests
    runner.run(unittest.TestSuite(all_tests))
  File "/usr/lib64/python2.5/unittest.py", line 705, in run
    test(result)
  File "/usr/lib64/python2.5/unittest.py", line 437, in __call__
    return self.run(*args, **kwds)
  File "/usr/lib64/python2.5/unittest.py", line 433, in run
    test(result)
  File "/usr/lib64/python2.5/unittest.py", line 437, in __call__
    return self.run(*args, **kwds)
  File "/usr/lib64/python2.5/unittest.py", line 433, in run
    test(result)
  File "/usr/lib64/python2.5/unittest.py", line 437, in __call__
    return self.run(*args, **kwds)
  File "/usr/lib64/python2.5/unittest.py", line 433, in run
    test(result)
  File "/usr/lib64/python2.5/unittest.py", line 281, in __call__
    return self.run(*args, **kwds)
  File "/usr/lib64/python2.5/unittest.py", line 263, in run
    result.addFailure(self, self._exc_info())
  File "/usr/lib64/python2.5/unittest.py", line 667, in addFailure
    TestResult.addFailure(self, test, err)
  File "/usr/lib64/python2.5/unittest.py", line 129, in addFailure
    self.failures.append((test, self._exc_info_to_string(err, test)))
  File "/usr/lib64/python2.5/unittest.py", line 153, in _exc_info_to_string
    return ''.join(traceback.format_exception(exctype, value, tb))
  File "/usr/lib64/python2.5/traceback.py", line 131, in format_exception
    def format_exception(etype, value, tb, limit = None):
  File
"/local/packages/eclipse-3.4/plugins/org.python.pydev.debug_1.3.18/pysrc/pydevd.
py",
line 615, in trace_dispatch
    traceback.print_exc()
  File "/usr/lib64/python2.5/traceback.py", line 227, in print_exc
    print_exception(etype, value, tb, limit, file)
  File "/usr/lib64/python2.5/traceback.py", line 125, in print_exception
    print_tb(tb, limit, file)
  File "/usr/lib64/python2.5/traceback.py", line 69, in print_tb
    line = linecache.getline(filename, lineno, f.f_globals)
  File "/usr/lib64/python2.5/linecache.py", line 14, in getline
    lines = getlines(filename, module_globals)
  File "/usr/lib64/python2.5/linecache.py", line 40, in getlines
    return updatecache(filename, module_globals)
  File "/usr/lib64/python2.5/linecache.py", line 82, in updatecache
    basename = os.path.split(filename)[1]
  File "/local/devel/PhotoMap2/src/mox.py", line 414, in __getattr__
    raise UnknownMethodCallError(name)
mox.UnknownMethodCallError: Method called is not a member of the object: split

What version of the product are you using? On what operating system?
Mox 0.5.0. On Fedora 9 x86_64

Please provide any additional information below.

Original issue reported on code.google.com by tsui.t...@gmail.com on 25 Sep 2008 at 7:26

Attachments:

GoogleCodeExporter commented 9 years ago
This isn't working because you should be unsetting your stubs after each test.  
If
you don't do this, you'll end up in a strange state, as you've discovered.

If you add:

  def tearDown(self):
    self.mocker.UnsetStubs()

to TestMoxStubOutWIthMocksBug TestCase, everything passes.

Original comment by smidd...@gmail.com on 25 Sep 2008 at 8:50

GoogleCodeExporter commented 9 years ago
Ah I see. Thanks for the info.

Original comment by tsui.t...@gmail.com on 25 Sep 2008 at 9:37