Commit Graph

84 Commits

Author SHA1 Message Date
Andrew Murray
e39765d755 Added type hints 2024-02-20 15:41:20 +11:00
Hugo van Kemenade
4a4b90c365
Autotype tests (#7756)
* autotyping: --none-return
* autotyping: --scalar-return
* autotyping: --int-param
* autotyping: --float-param
* autotyping: --str-param
* autotyping: --annotate-named-param tmp_path:pathlib.Path
2024-01-31 20:12:58 +11:00
Hugo van Kemenade
53c3cd9f8e isort Tests 2024-01-20 13:23:03 +02:00
Hugo van Kemenade
43b2f61e79 Add 'from __future__ import annotations' using Ruff/isort 2023-12-21 13:13:31 +02:00
Andrew Murray
6a931861fe Load before getting size in __array_interface__ 2023-03-23 10:12:18 +11:00
pre-commit-ci[bot]
24183d652e [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2023-02-06 19:27:19 +00:00
Andrew Murray
a065e0252b Updated deprecated NumPy alias 2022-12-21 09:29:25 +11:00
Andrew Murray
c259ac492f Parametrized tests 2022-10-03 16:57:42 +11:00
Andrew Murray
dae1f691c2 Updated checks that no warnings were raised 2022-02-21 13:49:01 +11:00
DWesl
1b6a8c6122 TST: Parametrize numpy roundtrip to find failing case
Segfaults are annoying to debug.
2022-01-29 13:07:27 +11:00
Andrew Murray
3e670d7737 Migrated from deprecated numpy bool and float 2021-02-26 20:59:11 +11:00
Andrew Murray
4a0569e97f Changed zero length assertions to falsy 2021-02-11 13:48:31 +11:00
Andrew Murray
01be700081 Fixed asserting that no warnings were raised 2021-02-10 23:37:55 +11:00
Hugo van Kemenade
dd87dd50c0 Update to isort 5 with Black profile support 2020-08-08 22:39:29 +03:00
Andrew Murray
59957fb8d8 Added support for 1-D NumPy arrays 2020-05-04 20:07:23 +10:00
Hugo
17c67a2cfb Use pytest.importorskip to skip on a missing import dependency 2020-02-18 14:30:56 +02:00
Hugo
affade7595 Replace unittest with pytest 2020-02-13 12:15:05 +02:00
Hugo
38bf862185 Replace PillowTestCase.assert_warning with pytest.warns 2020-02-03 11:11:32 +02: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
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
5631718a8d Format with Black 2019-06-13 18:54:46 +03:00
Andrew Murray
73cb0ce15f Fixed numpy bool bug 2019-04-13 00:25:59 +10:00
Hugo
1c3da86ae7 Remove workaround for EOL Trusty/Precise 2019-04-01 17:45:32 +03:00
Jon Dufresne
6d46ae2e8f Fix BytesWarning in Tests/test_numpy.py
When running Python with the `-b` command line argument, fixes warnings:

    Tests/test_numpy.py::TestNumpy::test_1bit
      Pillow/Tests/test_numpy.py:118: BytesWarning: Comparison between bytes and string
        arr_bool = numpy.array([[1, 0, 0, 1, 0], [0, 1, 0, 0, 0]], 'bool')

    Tests/test_numpy.py::TestNumpy::test_point_lut
      Pillow/Tests/test_numpy.py:170: BytesWarning: Comparison between bytes and string
        lut = numpy.array(data, dtype='uint8')

    Tests/test_numpy.py::TestNumpy::test_to_array
      Pillow/Tests/test_numpy.py:146: BytesWarning: Comparison between bytes and string
        self.assertEqual(np_img.dtype, numpy.dtype(dtype))
2019-03-17 10:08:33 -07: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
Jon Dufresne
37f10651bd Clean up commented out debug print statements 2018-09-04 20:02:42 -07:00
Andrew Murray
c2189235af Line too long 2018-07-02 19:26:02 +10:00
Hugo
2b09e7fa6a
Merge pull request #3099 from uploadcare/lut-numpy
NumPy support for LUTs
2018-07-01 13:18:03 +03:00
Hugo
d524664215 Re-enable test for PyPy, we're long past 5.3.1 2018-05-17 22:18:33 +03:00
Alexander
76e57bbbe2 Better numpy tests skipping 2018-04-14 18:59:57 +03:00
Andrew Murray
c13ccf13a1 Added missing whitespace 2018-03-06 19:53:07 +11:00
hugovk
9344bd20dd Move test_no_resource_warning_for_numpy_array to test_numpy so it can be skipped easily 2017-09-23 22:39:10 +03:00
Andrew Murray
9e843a2d9b Changed format of lambda calls 2017-09-01 21:05:40 +10:00
wiredfool
300dfcf4a4 Test/fix for issue #2044 2017-08-16 11:46:27 -07:00
Alexander
349e300d7b use getchannel where is possible 2017-08-09 02:36:07 +03:00
hugovk
310105625c Failing test case for #2259 2017-02-22 08:16:17 +02:00
Hugo
53e5702557 Update http to https 2017-02-14 11:27:02 +02:00
Eric Soroos
94cc72a2ba disable tests broken on old system versions of numpy/scipy 2017-01-20 11:35:49 -08:00
Andrew Murray
4ed31e8ef7 Updated comments to use print as a function 2016-11-26 11:02:44 +11:00
Andrew Murray
72d5218080 Flake8 fixes 2016-09-03 12:17:22 +10:00
Hugo
ad9fddbcbc Remove duplicate import 2016-08-29 12:57:12 +03:00
Eric Soroos
5b0a1a1c0d Moved tiff save / load of uint16 to test_file_tiff.
Saving a numpy generated image as a tiff will save in native endian, and comparing it to a
little endian tiff will fail on bigendian machines.
2016-08-25 12:49:40 -07:00
wiredfool
b77adf4692 Merge pull request #2090 from wiredfool/pr_2083
Skip failing numpy tests on Pypy <= 5.3.1
2016-08-25 11:57:57 +01:00
wiredfool
30abb42c27 More specific version of pr #2083 2016-08-25 03:22:20 -07:00
Matthew Brett
824a0c232c BF: fix conversion of bit images to numpy arrays
Numpy cannot form arrays from bits.  To convert bit images to numpy,
convert bits to bytes.

From suggestion by Alexander Karpinsky, with thanks.

Fixes gh-350.
2016-08-17 18:47:14 -07:00
Arjen Nienhuis
67eb7a3dc2 Ignore PyPy numpy errors 2016-08-17 23:25:52 +02:00