Question

The SoCo project has a small test suite in which one test fails under pypy only on the first run (when no pyc file exists). Subsequent runs succeed.

When running the test for the first time, the output of the failing test is

E           assert {'CurrentLEDS...': 'μИⅠℂ☺ΔЄ💋'} == {'CurrentLEDSt...: 'μИⅠℂ☺ΔЄ💋'}
E             Common items:
E             {'CurrentLEDState': 'On'}
E             Differing items:
E             {'Unicode': 'μИⅠℂ☺ΔЄ💋'} != {'Unicode': 'μИⅠℂ☺ΔЄ💋'}

Note that in the "Differing items" both sides are exactly equal. The test run creates a unittest/__pycache__/test_services.pypy-20-PYTEST.pyc file. When running the test while leaving the file intact, it succeeds. When deleting the pyc file and running the test again, it fails.

The failing test can be reproduced with (assuming you have pypy installed)

mkdir soco-tmp
cd soco-tmp/
git clone https://github.com/SoCo/SoCo.git
cd SoCo/
git reset --hard 4d6cea18d30e5b30ed5c6f #that's the current revision when writing this
virtualenv -p `which pypy` venv
source venv/bin/activate
python --version
# Python 2.7.3 (2.2.1+dfsg-1~ppa1, Nov 28 2013, 02:02:56)
# [PyPy 2.2.1 with GCC 4.6.3]
pip install -r requirements.txt -r requirements-dev.txt 
pip install .
py.test unittest/test_services.py # should fail
py.test unittest/test_services.py # should succeed
rm unittest/__pycache__/*
python -B -mpytest unittest/test_services.py # will always fail as no pyc is created

This seems like a bug in PyPy, but otoh I couldn't reproduce it in a simple test case so far...

Any ideas?

Was it helpful?

Solution

This is a bug. Should now be fixed in the source (see changeset 574aa48e4875). You can try tomorrow's nightly build from http://buildbot.pypy.org/nightly/trunk/.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top