[TIP] Should the unit tests for mock still run in python 2.7.x?

Staple, Danny (BSKYB) DStaple at nds.com
Thu Dec 13 07:06:22 PST 2012


Okay - confirmed - a path issue. The IDE was setting things up so the installed mock was being used as the SUT instead of the mock.py in the workspace.

From: Staple, Danny (BSKYB)
Sent: 13 December 2012 10:06
To: testing-in-python at lists.idyll.org
Subject: RE: [TIP] Should the unit tests for mock still run in python 2.7.x?

I have found an interesting difference.
If I run it on the command line with Nose I get this:

$ /usr/local/bin/nosetests-2.7 tests
..........................................S...............................................S......................................S.....................................................................................................................................................
----------------------------------------------------------------------
Ran 279 tests in 0.283s

OK (SKIP=3)

If run within pycharm (my usual IDE) on 2.7 I get a load of errors - I am now wandering if it is doing something wrong with the import order - and picking up an environment mock (which is an older version) before the intended tested mock...

A short example (there are 24 of these):
/usr/bin/python2.7 /home/stapled/pycharm/helpers/pycharm/noserunner.py /home/stapled/workspace/mock/tests/
Testing started at 9:57 AM ...
...........
Error
Traceback (most recent call last):
  File "/usr/lib/python2.7/unittest/case.py", line 327, in run
    testMethod()
  File "/usr/local/lib/python2.7/dist-packages/nose-1.1.2-py2.7.egg/nose/loader.py", line 390, in loadTestsFromName
    addr.filename, addr.module)
  File "/usr/local/lib/python2.7/dist-packages/nose-1.1.2-py2.7.egg/nose/importer.py", line 39, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/usr/local/lib/python2.7/dist-packages/nose-1.1.2-py2.7.egg/nose/importer.py", line 86, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/home/stapled/workspace/mock/tests/testhelpers.py", line 7, in <module>
    from mock import (
ImportError: cannot import name PropertyMock

I am going to investigate further to find out what is different (for a start logging sys.path).

Danny
From: John Wong [mailto:gokoproject at gmail.com]
Sent: 12 December 2012 19:16
To: Staple, Danny (BSKYB)
Cc: testing-in-python at lists.idyll.org<mailto:testing-in-python at lists.idyll.org>
Subject: Re: [TIP] Should the unit tests for mock still run in python 2.7.x?

I have no problem running it.
What errors are you getting? I am on Ubuntu 12.04 using 2.7.3 which comes with the distro.

I also tested a clone called bendarnell-mock<http://code.google.com/r/bendarnell-mock/source/browse> and it works also.
First I show 2.7.3 and then 2.7.2.

hg clone https://code.google.com/p/mock/
yeukhon at fubini:/tmp/mock/tests$ nosetests --verbosity=2 -s
----------------------------------------------------------------------
Ran 279 tests in 1.750s

OK (SKIP=3)

#python 2.7.2
----------------------------------------------------------------------
Ran 279 tests in 1.857s

OK (SKIP=3)
yeukhon at fubini:/tmp/mock$ which python
/home1/yeukhon/.pythonbrew/pythons/Python-2.7.2/bin/python
On Wed, Dec 12, 2012 at 9:19 AM, Staple, Danny (BSKYB) <DStaple at nds.com<mailto:DStaple at nds.com>> wrote:
The master branch in mercurial at http://code.google.com/p/mock/ - cloned today.

From: John Wong [mailto:gokoproject at gmail.com<mailto:gokoproject at gmail.com>]
Sent: 12 December 2012 14:04
To: Staple, Danny (BSKYB)
Cc: testing-in-python at lists.idyll.org<mailto:testing-in-python at lists.idyll.org>
Subject: Re: [TIP] Should the unit tests for mock still run in python 2.7.x?

Which version of mock?

On Wednesday, December 12, 2012, Staple, Danny (BSKYB) wrote:
I've just cloned mock and I've spotted that there are many test failures when using 2.7.2, all of them pass in 3.2.2 (and presumably other 3.x versions).
Is this known?

Thanks,
Danny

________________________________


**************************************************************************************
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster at nds.com<mailto:postmaster at nds.com> and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.

NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00
**************************************************************************************


--
Sent from Gmail Mobile

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20121213/97b4b9dc/attachment.htm>


More information about the testing-in-python mailing list