Commit Graph

66 Commits

Author SHA1 Message Date
Eric Soroos
a6fa139f62 useless reptile 2021-01-07 14:57:49 +01:00
Eric Soroos
1d7c8e03d0 known failing tests from valgrind -- uninitialized values 2021-01-07 14:52:02 +01:00
Hugo van Kemenade
dd87dd50c0 Update to isort 5 with Black profile support 2020-08-08 22:39:29 +03:00
Hugo van Kemenade
12f66f44f4
Fix regression
Co-Authored-By: Andrew Murray <3112309+radarhere@users.noreply.github.com>
2020-02-23 10:31:54 +02:00
Hugo
44e661f25a Convert to use pytest 2020-02-22 23:03:01 +02:00
Andrew Murray
8482919a37 Converted most assert statements to pytest 2020-02-23 00:06:21 +11:00
Jon Dufresne
4f185329f4 Streamline test skipping based on supported features
This adds a new test decorator: skip_unless_feature(). The argument is
the same as passed to features.check(). If the feature is not supported,
the test will be skipped.

This removes several kinds of boilerplate copied and pasted around tests
so test feature checking is handled and displayed more consistently.

Refs #4193
2020-02-18 13:07:01 -08:00
Hugo
a4bf9fa036 Convert most PillowTestCase methods to pytest 2020-02-02 12:26:01 +02:00
Andrew Murray
c0048ad7de Use context managers 2019-11-26 07:03:23 +11:00
Jon Dufresne
33dabf986f Import unittest from stdlib rather than helper.py
The unittest in helper.py has not offered an interesting abstraction
since dbe9f85c7d so import from the more
typical stdlib location.
2019-11-20 18:42:52 -08:00
Hugo
cc63f66575 Merge remote-tracking branch 'upstream/master' into rm-2.7 2019-11-01 13:22:56 +02:00
Jon Dufresne
4cd4adddc3 Improve handling of file resources
Follow Python's file object semantics. User code is responsible for
closing resources (usually through a context manager) in a deterministic
way.

To achieve this, remove __del__ functions. These functions used to
closed open file handlers in an attempt to silence Python
ResourceWarnings. However, using __del__ has the following drawbacks:

- __del__ isn't called until the object's reference count reaches 0.
  Therefore, resource handlers remain open or in use longer than
  necessary.

- The __del__ method isn't guaranteed to execute on system exit. See the
  Python documentation:

  https://docs.python.org/3/reference/datamodel.html#object.__del__

  > It is not guaranteed that __del__() methods are called for objects
  > that still exist when the interpreter exits.

- Exceptions that occur inside __del__ are ignored instead of raised.
  This has the potential of hiding bugs. This is also in the Python
  documentation:

  > Warning: Due to the precarious circumstances under which __del__()
  > methods are invoked, exceptions that occur during their execution
  > are ignored, and a warning is printed to sys.stderr instead.

Instead, always close resource handlers when they are no longer in use.
This will close the file handler at a specified point in the user's code
and not wait until the interpreter chooses to. It is always guaranteed
to run. And, if an exception occurs while closing the file handler, the
bug will not be ignored.

Now, when code receives a ResourceWarning, it will highlight an area
that is mishandling resources. It should not simply be silenced, but
fixed by closing resources with a context manager.

All warnings that were emitted during tests have been cleaned up. To
enable warnings, I passed the `-Wa` CLI option to Python. This exposed
some mishandling of resources in ImageFile.__init__() and
SpiderImagePlugin.loadImageSeries(), they too were fixed.
2019-10-12 08:27:17 -07:00
Hugo
538d9e2e5d Upgrade Python syntax with pyupgrade --py3-plus 2019-10-07 14:30:59 +03:00
Jon Dufresne
d50445ff30 Introduce isort to automate import ordering and formatting
Similar to the recent adoption of Black. isort is a Python utility to
sort imports alphabetically and automatically separate into sections. By
using isort, contributors can quickly and automatically conform to the
projects style without thinking. Just let the tool do it.

Uses the configuration recommended by the Black to avoid conflicts of
style.

Rewrite TestImageQt.test_deprecated to no rely on import order.
2019-07-06 16:11:35 -07:00
Hugo
d08475442b Format with Black 2019-06-13 18:53:42 +03:00
Jon Dufresne
4de5477b61 Remove unnecessary unittest.main() boilerplate from test files
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.
2019-02-03 10:10:16 -08:00
Jon Dufresne
7da17ad41e Improve pytest configuration to allow specific tests as CLI args
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.
2019-01-13 09:00:12 -08:00
Andrew Murray
0c0f769351 Allow EPS tests that do not require Ghostscript 2018-12-30 20:50:09 +11:00
Hugo
4352edb1ec Assert all images in loop 2018-10-24 22:29:01 +03:00
Jon Dufresne
1ba14783d2 Avoid deprecated 'U' mode when opening files
Instead, use PSFile() wrapper to handle all newline in the EPS spec.

Update line ending tests to handle all combinations of '\n' and '\r'.

Fixes warning "DeprecationWarning: 'U' mode is deprecated" in tests.
2018-07-01 08:07:59 -07:00
Hugo
04a1f71b4c
Merge pull request #3105 from radarhere/py3
Change Python version checks to use util
2018-04-22 18:37:33 +03:00
Andrew Murray
b4e6cdadac Added py3 variable to _util 2018-04-20 09:19:13 +10:00
Andrew Murray
b560f5b417 Changed Python version checks in tests to use helper 2018-04-19 19:40:56 +10:00
Andrew Murray
37f5f1120a Fixed block comments 2018-04-18 16:00:57 +10:00
Andrew Murray
e107ed6fcf Allow for an empty line in EPS header data 2017-12-24 21:12:48 +11:00
Eric Soroos
e5aa9d5f8b Bumped epsilon -- arch is showing 5.6 rather than <5 2017-12-19 16:20:36 +00:00
Eric Soroos
636e5ff1e9 Relaxing similarity on showpage test, Arch has rendering differences 2017-11-01 14:05:40 +00:00
Eric Soroos
c42867fa2c Added expected result, renamed images 2017-09-09 12:01:38 +00:00
Samuele Kaplun
c07ce878d7 Fix EPS import
Fixes EPS import by adding the missing "showpage" Postscript command
to the end of the gs call.

See: https://bugs.ghostscript.com/show_bug.cgi?id=698272

Signed-off-by: Samuele Kaplun <samuele.kaplun@cern.ch>
2017-09-09 12:01:38 +00:00
Andrew Murray
9e843a2d9b Changed format of lambda calls 2017-09-01 21:05:40 +10:00
Andrew Murray
257bc8bd4f Added tests 2017-03-03 19:45:55 +11:00
Andrew Murray
72d5218080 Flake8 fixes 2016-09-03 12:17:22 +10:00
homm
1ba4e9e5ba remove end of file banner from all files 2016-07-10 14:11:28 +03:00
wiredfool
13b8c1c70b test the output for a CMYK EPS image 2016-05-26 22:06:10 +01:00
Andrew Murray
392d567352 Added CMYK mode for opening EPS files 2016-04-13 18:27:46 +10:00
Andrew Murray
0eabe68882 Added test 2015-10-12 23:13:45 +11:00
Andrew Murray
309ab1fc3d Various Flake8 fixes 2015-07-03 16:22:56 +10:00
Andrew Murray
a06b59bd52 Added various tests 2015-07-03 15:03:25 +10:00
Andrew Murray
26bcc443d1 Specified exception types 2015-05-30 09:18:27 +10:00
Andrew Murray
d1c182cadc Various Flake8 fixes 2015-04-24 09:26:52 +10:00
hugovk
883858151d Simple test for 1104 2015-03-26 14:05:17 +02:00
Hugo
ae7b765b53 Fix some Landscape.io errors and warnings 2014-10-01 16:50:33 +03:00
wiredfool
ce0fcef580 Don't test internal python functions 2014-09-12 21:41:12 -07:00
wiredfool
918c77e98a Py3.2 fix 2014-09-02 23:33:10 -07:00
wiredfool
6dc276599e test for all the different line ending characters 2014-09-02 23:20:50 -07:00
wiredfool
e52152baad Test bytesio object 2014-09-02 23:20:16 -07:00
hugovk
cf04a9a0d2 Remove unused tearDownModule 2014-07-07 20:03:50 +03:00
hugovk
3ec505958e Convert old tests to use unittest 2014-06-10 12:10:47 +03:00
eliempje
a712cec02b Added test and testfile for issue #302 2014-05-14 23:14:55 +02:00
hugovk
11227e5dc1 Fix test because thumbnail() retains aspect ratio 2014-05-08 23:01:44 +03:00