Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow test cases to run without installing first
As @spwhitton found: The test suite needs to call "python3 -m ocrmypdf.main" instead of just "ocrmypdf" because this /usr/bin/ocrmypdf script has not yet been generated when dh runs the test suite. --- Seems reasonable to perform in-place testing independent of installation. Source: https://sources.debian.net/src/ocrmypdf/4.2.1%2Bgit.20160824.1.5d67cc7-1/debian/patches/0001-patch-test-suite-executable.patch/
- Loading branch information
325cc0b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
325cc0b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That should work fine. This is really a fix to the test suite in that test_pageinfo.py and test_hocrtransform.py use
import ocrmypdf.module
and test_main.py did not necessarily locate the same installation ifocrmypdf
is installed. By calling Python viasys.executable -m package
the same import resolution order asimport
should be followed so all parts of the test suite are testing whatever Python finds in response toimport ocrmypdf
- meaning it followssys.path
, the first entry of which is the current working directory.So as written, it will run tests on a new version prior to installation or on the installed version for CI.
That said, there could be reasons you might want to explicitly test
/usr/[local/]bin/ocrmypdf
. I can't think of anything that should be needed other than a basic sanity check:Is there anything beyond that you'd need to check?
325cc0b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
325cc0b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I experimented and it seems that py.test is designed to take care of this automatically (provided a package has tests outside its package source tree, as with ocrmypdf). If running via
python3 setup.py test
(to test the package before installation) py.test inserts the uninstalled package into sys.path (I think by way of a temporary installation). If run aspy.test
it will take the system package because it changes PWD and runs each test in its directory.So, with your patch applied, it did all work properly (no crossover of uninstalled/installed versions) before, but I now I understand why it works, which makes me feel a lot better about it. With your patch applied
python3 setup.py test
should work on Debian and other platforms as expected without patching.325cc0b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
325cc0b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.