This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Claudiu.Popa
Recipients Claudiu.Popa
Date 2014-06-23.12:52:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1403527925.65.0.212984709862.issue21829@psf.upfronthosting.co.za>
In-reply-to
Content
There's a problem with ctypes.test.test_values on Windows.
First, the test is wrong because it uses the following:

if __debug__:
    self.assertEqual(opt, 0)
elif ValuesTestCase.__doc__ is not None:
    self.assertEqual(opt, 1)

ValuesTestCase doesn't have a docstring and the check always fails when running the test suite with -O or -OO.
Second, running the test suite with -O and afterwards with -OO, will lead to the following failure:

======================================================================
FAIL: test_optimizeflag (ctypes.test.test_values.Win_ValuesTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\Projects\cpython\lib\ctypes\test\test_values.py", line 50, in test_optimizeflag
    self.assertEqual(opt, 1)
AssertionError: 2 != 1

----------------------------------------------------------------------

That's because the .pyo file for test_values already exist when rerunning with -OO and the docstring will be there. Now, I don't know why the file is not rebuilt and the documentation regarding -OO and -O is pretty scarce. The attached file tries a different approach, regenerate a test class each time the test is run in order to obtain its docstring. If run with -OO, it will be dropped properly.
History
Date User Action Args
2014-06-23 12:52:05Claudiu.Popasetrecipients: + Claudiu.Popa
2014-06-23 12:52:05Claudiu.Popasetmessageid: <1403527925.65.0.212984709862.issue21829@psf.upfronthosting.co.za>
2014-06-23 12:52:05Claudiu.Popalinkissue21829 messages
2014-06-23 12:52:05Claudiu.Popacreate