Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyPDF4/filters.py unit tests #9

Merged
merged 15 commits into from
Sep 8, 2018
Merged

PyPDF4/filters.py unit tests #9

merged 15 commits into from
Sep 8, 2018

Conversation

acsor
Copy link
Collaborator

@acsor acsor commented Aug 22, 2018

This is an ongoing PR - do not close it right after the first merge, I will continue pushing more until I say I am done with it. In the meantime, review and eventually merge the existng code.

I have continued adding unit tests for filters in PyPDF4/filters.py, and admittedly they turned out quite useful in estirpating a few bugs or refactoring some algorithms. As of now, I'm not fully sure that LZWDecode.Decoder is bug-free as I found it in the codebase prior to working on it; indeed, one of its test cases keeps failing.

There were also a few other commits not fully related to unit testing, but they were good enough to be added.

acsor added 8 commits August 14, 2018 17:13
Too many and too little to document them all.
Very small changes were added elsewhere too.
`str_()` is now `pypdfStr()`, `ord_()` is `pypdfOrd()`, `b_()` is
`pypdfBytes()` and so on.
In case a user wishes to retain the old names, such functions can be imported
as

```
from PyPDF4.utils import pypdfStr as str_, pypdfBytes as b_  # ...
```
The `staticmethod()` feature was first added in version 2.2 of Python, with
the decorator syntax being added in 2.4:
[source](https://docs.python.org/2.7/library/functions.html#staticmethod).
`pypdfOrd()` in `PyPDF4/utils.py` was updated too.
This version of the encoder is primarily meant to aid testing of
`LZWDecode.Decoder`. It does not interpret optional parameters and may contain
a few bugs as of this commit.
@acsor
Copy link
Collaborator Author

acsor commented Aug 22, 2018

Commit 169dce1 should end issue #8. There's only one staticmethod() direct call but it is not proper to modify.

acsor added 3 commits August 23, 2018 13:38
An encode() method had to be added in ASCII85Decode specifically for testing
purposes.  A bug in the Python 2 implementation of ASCII85Decode.decode() was
potentially found.
@acsor
Copy link
Collaborator Author

acsor commented Aug 24, 2018

Hey @claird, isn't it possible to set Pylint flags such as these in the source code:

class CCITTFaxDecode(object):    # pylint: disable=too-few-public-methods
    @staticmethod

in the configuration of the Pylint tool? I will check myself, and if you agree will weed out those invasive comment declarations.

@claird
Copy link
Owner

claird commented Aug 24, 2018 via email

… 2 and 3.

The bug manifested solely in the Python 2 version of the code, which has been
deleted now (sorry, but it's a little cumbersome to maintain **two** distinct
implementations of an algorithm at once - the one stored now is efficient and
works seamlessly for both Python 2 and Python 3!).

TO-DO: the current decode() algorithm doesn't verify the ending `~>` EOD
sequence in an ASCII85-encoded sequence.
These should be considered "scratching scripts" for now, so not a lot of
development time was spent on them. However, it was ensured that they work
properly, like not they were doing before.
@acsor
Copy link
Collaborator Author

acsor commented Aug 24, 2018

I had been prolonging Add fixes to Sample_Code/*.py. for too long, and I decided to include it in this PR even if not intimately related. (It is a very small modification to an unessential part of the project.)

acsor added 2 commits August 30, 2018 16:55
One unit test was added to ensure that these many tweaks didn't introduce
any changes in a specific area (@Property and such).
@acsor
Copy link
Collaborator Author

acsor commented Sep 3, 2018

This is an ongoing PR - do not close it right after the first merge

I am noting that GitHub doesn't allow reopening PRs that were just merged. Will need to find a workaround or just resort to opening a new one each time.

@acsor
Copy link
Collaborator Author

acsor commented Sep 5, 2018

Hey @claird, since PRs cannot be reused on GitHub you can merge the changes in #9 and close it.

@claird claird merged commit 1ce79fe into claird:master Sep 8, 2018
@claird
Copy link
Owner

claird commented Sep 8, 2018

Thank you, newnone, for your contributions and patience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants