Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #93087 > unrolled thread

Why does the unit test fail of the pyPDF2 package?

Started byfl <rxjwg98@gmail.com>
First post2015-06-24 09:53 -0700
Last post2015-06-24 12:50 -0700
Articles 11 — 7 participants

Back to article view | Back to comp.lang.python


Contents

  Why does the unit test fail of the pyPDF2 package? fl <rxjwg98@gmail.com> - 2015-06-24 09:53 -0700
    Re: Why does the unit test fail of the pyPDF2 package? Steven D'Aprano <steve@pearwood.info> - 2015-06-25 03:35 +1000
    Re: Why does the unit test fail of the pyPDF2 package? fl <rxjwg98@gmail.com> - 2015-06-24 10:52 -0700
      Re: Why does the unit test fail of the pyPDF2 package? MRAB <python@mrabarnett.plus.com> - 2015-06-24 19:48 +0100
      Re: Why does the unit test fail of the pyPDF2 package? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-06-24 21:02 +0100
      Re: Why does the unit test fail of the pyPDF2 package? Steven D'Aprano <steve@pearwood.info> - 2015-06-25 11:20 +1000
      Re: Why does the unit test fail of the pyPDF2 package? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-06-24 21:39 -0400
    Re: Why does the unit test fail of the pyPDF2 package? fl <rxjwg98@gmail.com> - 2015-06-24 12:02 -0700
      Re: Why does the unit test fail of the pyPDF2 package? John Gordon <gordon@panix.com> - 2015-06-24 19:13 +0000
      Re: Why does the unit test fail of the pyPDF2 package? Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2015-06-24 19:13 +0000
    Re: Why does the unit test fail of the pyPDF2 package? fl <rxjwg98@gmail.com> - 2015-06-24 12:50 -0700

#93087 — Why does the unit test fail of the pyPDF2 package?

Fromfl <rxjwg98@gmail.com>
Date2015-06-24 09:53 -0700
SubjectWhy does the unit test fail of the pyPDF2 package?
Message-ID<3d9cd33f-f12d-48bc-a645-26e55c31f168@googlegroups.com>
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, 

[toc] | [next] | [standalone]


#93088

FromSteven D'Aprano <steve@pearwood.info>
Date2015-06-25 03:35 +1000
Message-ID<558aea4f$0$1654$c3e8da3$5496439d@news.astraweb.com>
In reply to#93087
On Thu, 25 Jun 2015 02:53 am, 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:

Please don't use screen shots:

(1) We cannot copy and paste text from a screen shot.

(2) Blind people and those with poor vision may not be able to see the
screen shot, and their screen readers do not work on images.

(3) People may be reading your post via email or news, and not be able to
access the website containing the screen shot.

Instead, copy and paste the text from the console and include it in the body
of your message. Do you know how to copy text from the Windows console?


> http://tinypic.com/view.php?pic=fbdpg0&s=8#.VYre8_lVhBc
> 
> [IMG]http://i57.tinypic.com/fbdpg0.png[/IMG]


Have you read the test failure? It is obvious why it failed. Your test
expects to get:

"TheCrazyOnesOctober14,1998Herestothecrazyones..."

but instead gets:

"TheCrazyOnes\nOctober14,1998\nHerestothecrazyones..."

The difference is obvious. Your expected output doesn't include newlines.




-- 
Steven

[toc] | [prev] | [next] | [standalone]


#93089

Fromfl <rxjwg98@gmail.com>
Date2015-06-24 10:52 -0700
Message-ID<252d5aad-e71e-4916-803a-f3b1762f2123@googlegroups.com>
In reply to#93087
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, Steven. I don't know how to copy command console window contents 
to the forum post. I even try redirection hoping to screen contents to a 
text file, but it fails.


Yes, there are extra '\n' in the extracted, but I don't know how to suppress
it. Does anyone know how to make it the same of the expected?

Thanks,

[toc] | [prev] | [next] | [standalone]


#93097

FromMRAB <python@mrabarnett.plus.com>
Date2015-06-24 19:48 +0100
Message-ID<mailman.30.1435171723.3674.python-list@python.org>
In reply to#93089
On 2015-06-24 18:52, fl wrote:
> 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, Steven. I don't know how to copy command console window contents
> to the forum post. I even try redirection hoping to screen contents to a
> text file, but it fails.
>
You can make a rectangular selection by dragging over the console
window the mouse pointer.

>
> Yes, there are extra '\n' in the extracted, but I don't know how to suppress
> it. Does anyone know how to make it the same of the expected?
>
> Thanks,
>

[toc] | [prev] | [next] | [standalone]


#93103

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2015-06-24 21:02 +0100
Message-ID<mailman.33.1435176176.3674.python-list@python.org>
In reply to#93089
On 24/06/2015 19:48, MRAB wrote:
> On 2015-06-24 18:52, fl wrote:
>> 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, Steven. I don't know how to copy command console window contents
>> to the forum post. I even try redirection hoping to screen contents to a
>> text file, but it fails.
>>
> You can make a rectangular selection by dragging over the console
> window the mouse pointer.
>

An alternative is to install ConEmu and set up a startup.txt file.  My 
heavily encrypted :) version follows

cmd /F:ON /T:02 /K cd C:\Users\Mark\Documents\MyPython 
"-new_console:t:MyPython"
cmd /F:ON /T:02 /K cd c:\Users\Mark\pythonissues "-new_console:t:Python 
Issues"
cmd /F:ON /T:02 /K cd c:\cPython\PCBuild "-new_console:t:cPython"
cmd /F:ON /T:02 /K cd C:\Users\Mark\Documents\Cash\Python 
"-new_console:t:Cash Python"
C:\Python34\Scripts\ipython.exe --matplotlib "-new_console:t:iPython"

Once you've overcome the encryption life is far, far easier on Windows. 
  You can do really advanced concepts like cut and paste relatively 
easily, but please don't take my word for it, try it yourself.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

[toc] | [prev] | [next] | [standalone]


#93110

FromSteven D'Aprano <steve@pearwood.info>
Date2015-06-25 11:20 +1000
Message-ID<558b575c$0$1666$c3e8da3$5496439d@news.astraweb.com>
In reply to#93089
On Thu, 25 Jun 2015 03:52 am, fl wrote:

> Thanks, Steven. I don't know how to copy command console window contents
> to the forum post.

I don't know either, because I don't use Windows, but you can google for
instructions:

https://duckduckgo.com/html/?q=copy+text+windows+console

https://startpage.com/do/search?q=copy+text+windows+console

http://www.bing.com/search?q=copy+text+windows+console

http://au.search.yahoo.com/search?p=copy+text+windows+console

Even Google works:

https://www.google.com.au/search?q=copy+text+windows+console


> Yes, there are extra '\n' in the extracted, but I don't know how to
> suppress it. Does anyone know how to make it the same of the expected?

Where you enter the expected output, instead of entering:

"TheCrazyOnesOctober14,1998Herestothecrazyones..."

instead enter:

"TheCrazyOnes\nOctober14,1998\nHerestothecrazyones..."


The point is that your expected output should contain the text actually in
the PDF file. If your expected output is different from the actual
contents, then the expectations are wrong, not your code. The test itself
is buggy.



-- 
Steven

[toc] | [prev] | [next] | [standalone]


#93113

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2015-06-24 21:39 -0400
Message-ID<mailman.40.1435196374.3674.python-list@python.org>
In reply to#93089
On Wed, 24 Jun 2015 19:48:37 +0100, MRAB <python@mrabarnett.plus.com>
declaimed the following:

>You can make a rectangular selection by dragging over the console
>window the mouse pointer.
>
	If this is M$ Windows, the default configuration requires
<right-click>MARK, then position and <left-click>drag to highlight the
text, then <right-click> to copy to clipboard...
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [prev] | [next] | [standalone]


#93099

Fromfl <rxjwg98@gmail.com>
Date2015-06-24 12:02 -0700
Message-ID<16dfcef6-4740-45b9-b04f-0f5bc0899c01@googlegroups.com>
In reply to#93087
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,

You can make a rectangular selection by dragging over the console 
 window the mouse pointer. 

Excuse me. I don't understand your idea. On the command window, there is
no content copied through a mouse click/drag (even no screen difference).
Do you mean using Snipping Tool? That will be an image, which is not
advised as a previous poster.
Thanks,

[toc] | [prev] | [next] | [standalone]


#93100

FromJohn Gordon <gordon@panix.com>
Date2015-06-24 19:13 +0000
Message-ID<mmevg7$k62$1@reader1.panix.com>
In reply to#93099
In <16dfcef6-4740-45b9-b04f-0f5bc0899c01@googlegroups.com> fl <rxjwg98@gmail.com> writes:

> Excuse me. I don't understand your idea. On the command window, there is
> no content copied through a mouse click/drag (even no screen difference).

Right-click the command window title bar and select Edit -> Mark.
Then use the mouse to select a rectangular area of text.
Then right-click the title bar again and select Edit -> Copy.

-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

[toc] | [prev] | [next] | [standalone]


#93101

FromJon Ribbens <jon+usenet@unequivocal.co.uk>
Date2015-06-24 19:13 +0000
Message-ID<slrnmom0do.1nu.jon+usenet@frosty.unequivocal.co.uk>
In reply to#93099
On 2015-06-24, fl <rxjwg98@gmail.com> wrote:
> You can make a rectangular selection by dragging over the console 
>  window the mouse pointer. 
>
> Excuse me. I don't understand your idea. On the command window, there is
> no content copied through a mouse click/drag (even no screen difference).
> Do you mean using Snipping Tool? That will be an image, which is not
> advised as a previous poster.

Click on the icon at the top-left of the command window.
Choose "Edit->Mark". Drag to select the text you want.
Click the menu again, and choose "Edit->Copy".

[toc] | [prev] | [next] | [standalone]


#93102

Fromfl <rxjwg98@gmail.com>
Date2015-06-24 12:50 -0700
Message-ID<af71ac41-0030-45c8-834f-6730185be2c1@googlegroups.com>
In reply to#93087
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>

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web