With the introduction and use of pytest, it is simple and easy to
execute specific tests in isolation through documented command line
arguments. Either by specifying the module path or through the `-k
EXPRESSION` argument. There is no longer any need to provide the
boilerplate:
if __name__ == '__main__':
unittest.main()
To every test file. It is simply noise.
The pattern remains in test files that aren't named with `test_*` as
those files are not discovered and executed by pytest by default.
The previous test configuration made it difficult to run a single test
with the pytest CLI. There were two major issues:
- The Tests directory was not a package. It now includes a __init__.py
file and imports from other tests modules are done with relative
imports.
- setup.cfg always specified the Tests directory. So even if a specific
test were specified as a CLI arg, this configuration would also always
include all tests. This configuration has been removed to allow
specifying a single test on the command line.
Contributors can now run specific tests with a single command such as:
$ tox -e py37 -- Tests/test_file_pdf.py::TestFilePdf.test_rgb
This makes it easy and faster to iterate on a single test failure and is
very familiar to those that have previously used tox and pytest.
When running tox or pytest with no arguments, they still discover and
runs all tests in the Tests directory.
Instead, allow exceptions to bubble up to the unittest exception
handler.
Prevents replacing the exception trace with a less informative
message. As the exceptions are always unexpected, should not need to
catch them explicitly in tests.
To have the old API that always returns tuples, and fractions as pairs,
set the `legacy_api` attribute of the IFD to True.
This should alleviate concerns about backwards compatibility.
Do not represent scalar tags as 1-element tuples. Keep tag
type and count information in TiffTags.TAGS. Normalize data in
ImageFileDirectory.__setitem__: wrap and unwrap tuples as needed,
convert rationals to floats. (To ensure consistency, make the "tags"
attribute private.) Interpret byte data as a series of integers rather
than a bytearray (which should only map to the "undefined" type). On
Python3, if a str is assigned to an "undefined" tag, encode it as ASCII.
Note that a large number of tags have been removed from TiffTags.TAGS
because I do not have time to figure out the type and count of each of
them. They should be restored before this gets merged in.
This obviously breaks backwards compatibility in a lot of ways...
Fix for UnicodeDecodeError: ascii codec cannot decode byte while saving a TIFF image
Problem occured while saving TIFF images that contain non-ascii characters in metadata
Manually merged with master by wiredfool