Why does the unit test fail of the pyPDF2 package?

fl rxjwg98 at gmail.com
Wed Jun 24 15:50:12 EDT 2015


On Wednesday, June 24, 2015 at 9:54:12 AM UTC-7, fl wrote:
> Hi,
> I want to learn some coding on PDF. After I download and install pyPDF2,
> it cannot pass unit test, which is coming from the package.
> 
> I put a screen shot link here to show the console message:
> 
> http://tinypic.com/view.php?pic=fbdpg0&s=8#.VYre8_lVhBc
> 
> [IMG]http://i57.tinypic.com/fbdpg0.png[/IMG]
> 
> 
> This Windows 7 PC has both Python 2.7 and Enthought Canopy (3.4?) installed.
> 
> I don't know whether it has conflicts or not.
> 
> 
> Thanks,

Thanks for the trick! I know now how new I am to the Windows.

Below is the installation message, and the unittest message.

Suspecting there are differences between Linux and Windows on '\n', I
 install pyPDF2 on Ubuntu. It has the same error. What the hell of pyPDF2
 is? I don't know what use/purpose of its test script for. This process is
 also for my learning on Python. Does anyone have the same or different 
 experiences on pyPDF2?

Thanks again.



/////////////////////






ImportError: No module named Tests

C:\Python27\Tools\PyPDF2-master\Tests>cd ..

C:\Python27\Tools\PyPDF2-master>C:\python27\python.exe setup.py install
running install
running build
running build_py
creating build
creating build\lib
creating build\lib\PyPDF2
copying PyPDF2\filters.py -> build\lib\PyPDF2
copying PyPDF2\generic.py -> build\lib\PyPDF2
copying PyPDF2\merger.py -> build\lib\PyPDF2
copying PyPDF2\pagerange.py -> build\lib\PyPDF2
copying PyPDF2\pdf.py -> build\lib\PyPDF2
copying PyPDF2\utils.py -> build\lib\PyPDF2
copying PyPDF2\xmp.py -> build\lib\PyPDF2
copying PyPDF2\_version.py -> build\lib\PyPDF2
copying PyPDF2\__init__.py -> build\lib\PyPDF2
running install_lib
creating C:\python27\Lib\site-packages\PyPDF2
copying build\lib\PyPDF2\filters.py -> C:\python27\Lib\site-packages\PyPDF2
copying build\lib\PyPDF2\generic.py -> C:\python27\Lib\site-packages\PyPDF2
copying build\lib\PyPDF2\merger.py -> C:\python27\Lib\site-packages\PyPDF2
copying build\lib\PyPDF2\pagerange.py -> C:\python27\Lib\site-packages\PyPDF2
copying build\lib\PyPDF2\pdf.py -> C:\python27\Lib\site-packages\PyPDF2
copying build\lib\PyPDF2\utils.py -> C:\python27\Lib\site-packages\PyPDF2
copying build\lib\PyPDF2\xmp.py -> C:\python27\Lib\site-packages\PyPDF2
copying build\lib\PyPDF2\_version.py -> C:\python27\Lib\site-packages\PyPDF2
copying build\lib\PyPDF2\__init__.py -> C:\python27\Lib\site-packages\PyPDF2
byte-compiling C:\python27\Lib\site-packages\PyPDF2\filters.py to filters.pyc
byte-compiling C:\python27\Lib\site-packages\PyPDF2\generic.py to generic.pyc
byte-compiling C:\python27\Lib\site-packages\PyPDF2\merger.py to merger.pyc
byte-compiling C:\python27\Lib\site-packages\PyPDF2\pagerange.py to pagerange.py
c
byte-compiling C:\python27\Lib\site-packages\PyPDF2\pdf.py to pdf.pyc
byte-compiling C:\python27\Lib\site-packages\PyPDF2\utils.py to utils.pyc
byte-compiling C:\python27\Lib\site-packages\PyPDF2\xmp.py to xmp.pyc
byte-compiling C:\python27\Lib\site-packages\PyPDF2\_version.py to _version.pyc
byte-compiling C:\python27\Lib\site-packages\PyPDF2\__init__.py to __init__.pyc
running install_egg_info
Writing C:\python27\Lib\site-packages\PyPDF2-1.24-py2.7.egg-info











C:\Python27\Tools\PyPDF2-master>C:\python27\python.exe -m unittest Tests.tests >
> logt
F
======================================================================
FAIL: test_PdfReaderFileLoad (Tests.tests.PdfReaderTestCases)
Test loading and parsing of a file. Extract text of the file and compare to expe
cted
----------------------------------------------------------------------
Traceback (most recent call last):
  File "Tests\tests.py", line 35, in test_PdfReaderFileLoad
    % (pdftext, ipdf_p1_text.encode('utf-8', errors='ignore')))
AssertionError: PDF extracted text differs from expected value.

Expected:

'TheCrazyOnesOctober14,1998Herestothecrazyones.Themis\xcb\x9dts.Therebels.Thetro
ublemakers.Theroundpegsinthesquareholes.Theoneswhoseethingsdi\xcb\x99erently.The
yrenotfondofrules.Andtheyhavenorespectforthestatusquo.Youcanquotethem,disagreewi
ththem,glorifyorvilifythem.Abouttheonlythingyoucantdoisignorethem.Becausetheycha
ngethings.Theyinvent.Theyimagine.Theyheal.Theyexplore.Theycreate.Theyinspire.The
ypushthehumanraceforward.Maybetheyhavetobecrazy.Howelsecanyoustareatanemptycanva
sandseeaworkofart?Orsitinsilenceandhearasongthatsneverbeenwritten?Orgazeataredpl
anetandseealaboratoryonwheels?Wemaketoolsforthesekindsofpeople.Whilesomeseethema
sthecrazyones,weseegenius.Becausethepeoplewhoarecrazyenoughtothinktheycanchanget
heworld,aretheoneswhodo.'

Extracted:

'TheCrazyOnes\nOctober14,1998\nHerestothecrazyones.Themis\xcb\x9dts.Therebels.Th
etroublemakers.\nTheroundpegsinthesquareholes.\nTheoneswhoseethingsdi\xcb\x99ere
ntly.Theyrenotfondofrules.And\ntheyhavenorespectforthestatusquo.Youcanquotethem,
\ndisagreewiththem,glorifyorvilifythem.\nAbouttheonlythingyoucantdoisignorethem.
Becausetheychange\nthings.Theyinvent.Theyimagine.Theyheal.Theyexplore.They\ncrea
te.Theyinspire.Theypushthehumanraceforward.\nMaybetheyhavetobecrazy.\nHowelsecan
youstareatanemptycanvasandseeaworkofart?Or\nsitinsilenceandhearasongthatsneverbe
enwritten?Orgazeat\naredplanetandseealaboratoryonwheels?\nWemaketoolsforthesekin
dsofpeople.\nWhilesomeseethemasthecrazyones,weseegenius.Becausethe\npeoplewhoare
crazyenoughtothinktheycanchangetheworld,\naretheoneswhodo.\n'



----------------------------------------------------------------------
Ran 1 test in 0.016s

FAILED (failures=1)

C:\Python27\Tools\PyPDF2-master>
C:\Python27\Tools\PyPDF2-master>



More information about the Python-list mailing list