Query on Python Compiled source--Urgent

Tim Golden mail at timgolden.me.uk
Mon Oct 14 03:40:11 EDT 2013


On 14/10/2013 06:41, chandan kumar wrote:
> I'm working on a python project for protocol testing.I need to provide
> only python compiled source to our customer.
> 
> Here are the steps followed to take python compiled from actual source.
> 1.There are 5 different test suites under the project
> 2..Run all 5  test suite with python sources.
> 3.After completion of test suite ,just take .pyc files and copied in to
> seperate folder.
> 4.Re run test suite for any issues with the .pyc code.I started seeing
> one issue when it logs the test results in to excel file.
>  This issue occurs sometimes.50% of chances are there to see this issue
> 
> Below is the error
> Traceback (most recent call last):
>   File "D:\users\ScriptTestCode\scriptsCompiledCode\ExecuteScripts.py",
> line 32, in <module>
>     TestManager.execute_scripts(TEST_BUILD)
>   File "D:\users\ScriptTestCode\scriptsCompiledCode\TestManager.py",
> line 764, in execute_scripts
>   File "D:\users\ScriptTestCode\scriptsCompiledCode\TestManager.py",
> line 772, in _execute_all
>   File "D:\users\ScriptTestCode\scriptsCompiledCode\TestManager.py",
> line 924, in _testsuite_950_band
>   File "D:\users\ScriptTestCode\scriptsCompiledCode\TestManager.py",
> line 377, in exec_test_suite
>   File "D:\users\ScriptTestCode\scripts\ResultReporter.py", line 321, in
> save_test_results
>     _my_doc.save(StackTestData.TEST_REPORT_PATH)
>   File "C:\Python27\lib\site-packages\pyExcelerator\Workbook.py", line
> 610, in save
>     doc.save(filename, self.get_biff_data())
>   File "C:\Python27\lib\site-packages\pyExcelerator\CompoundDoc.py",
> line 554, in save
>     f = file(filename, 'wb')
> IOError: [Errno 22] invalid mode ('wb') or filename:
> '.\\TestResults\\TestReport.xls'
> 
> Now my question is of there any issue with logging to excel it should
> happen for the first test suite itself,but it occurs in either 2,3,4 or
> 5 test suite. Some it runs without any issues.

Well, the fact that it works/fails 50% of the time points to a race
condition. You don't say how the test suites / tests are running, but if
anything's running in parallel, one test's cleanup could be pulling the
file out from under another test's writing results. Without knowing more
about your test runner, this is really guess-work.

Logging to Excel isn't part of the builtin logging module so you've
presumably added that functionality yourself. But PyExcelerator is
ultimately just opening a file and writing to it so for this purpose it
appears to be equivalent to, say, logging a bunch of stuff into a list
and then writing that into a file.

TJG



More information about the Python-list mailing list