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

test_image_preserveaspectratio[_default] fail #242

Open
GaetanLepage opened this issue Aug 18, 2023 · 6 comments
Open

test_image_preserveaspectratio[_default] fail #242

GaetanLepage opened this issue Aug 18, 2023 · 6 comments

Comments

@GaetanLepage
Copy link

Those two tests fail both on master and 1.9.6 (which is the same at the time of writing.

============================================================================== short test summary info ===============================================================================
FAILED test/test_image.py::TestElementImage::test_image_preserveaspectratio - AssertionError: Tuples differ: (0.0, 0.0, 0.0, 0.0) != (0.0, 0.0, 123, 321)
FAILED test/test_image.py::TestElementImage::test_image_preserveaspectratio_default - AssertionError: Tuples differ: (2.5, 0.0, 7.5, 5.0) != (0.0, 0.0, 0.0, 0.0)
===================================================================== 2 failed, 423 passed, 2 warnings in 45.94s =====================================================================
@tatarize
Copy link
Member

What OS and Python version. The automated testing says it's passing and I can't currently get the test to fail.

@GaetanLepage
Copy link
Author

This occurs while packaging svgelements to nixpkgs.
Hence, the environment is a bit special.
Here is the relevant PR: https://github.com/NixOS/nixpkgs/pull/256101/files

I am not able to reproduce the failure in a classic venv-based environment.

@GaetanLepage
Copy link
Author

Actually, I am able to reproduce the test failure in a normal environment:

  • OS: Ubuntu
  • Python: 3.10.12
  • scipy and numpy are installed (otherwise I get much more failed tests)

Logs:

=============================================================== FAILURES ================================================================
____________________________________________ TestElementImage.test_image_preserveaspectratio ____________________________________________

self = <test.test_image.TestElementImage testMethod=test_image_preserveaspectratio>

    def test_image_preserveaspectratio(self):
        """
        "none" stretches to whatever width and height were given.
        """
        q = io.StringIO(
            u'''
            <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 360 360" version="1.1">'
            <image width="123" height="321" preserveAspectRatio="none" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAEFklEQVR4nO3dsW7bQBRFwSjw//8yU6UJYDgil9xdnZnalp6LewhBhV/HcRy/gKTfsw8A5hEACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACPuafUDd6/X68WeO43jgEooE4GH/M/iffkcQGEUAHnJm+D+9lhBwlQDcbOTwv3ttIeAsAbjJncP/7r2EgHf5FuAGT45/hfdlXwIw2OwRzn5/9iIAA60yvlXuYH0CMMhqo1vtHtYkAAOsOrZV72IdAnDR6iNb/T7mEoALdhnXLnfyPAGAMAE4aben6m738gwBgDABOGHXp+mud3MfAYAwAXjT7k/R3e9nLAGAMAGAMAGAMAF4w6d8fv6Uv4PrBADCBADCBADCBADCBADCBADCBADCBADCBOANn/Kfdz7l7+A6AYAwAYAwAYAwAXjT7p+fd7+fsQQAwgTghF2forvezX0EAMIE4KTdnqa73cszBADCBOCCXZ6qu9zJ8wTgotXHtfp9zCUAA6w6slXvYh0CMMhqY1vtHtYkAAOtMrpV7mB9AjDY7PHNfn/2IgA3mDVC4+ddX7MP+FR/x/jEf+ExfM4SgJvdGQLD5yoBeMjIEBg+owjAw/4d7/8EweC5iwBMZtzM5FsACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACPsDhkRyDUVGTB8AAAAASUVORK5CYII="/>
            </svg>
            ''')
        svg = SVG.parse(q)
        m = list(svg.elements())
        a = m[1]
        a.load()
        self.assertEqual(type(a), Image)
>       self.assertEqual(a.bbox(), (0.0, 0.0, 123, 321))
E       AssertionError: Tuples differ: (0.0, 0.0, 0.0, 0.0) != (0.0, 0.0, 123, 321)
E       
E       First differing element 2:
E       0.0
E       123
E       
E       - (0.0, 0.0, 0.0, 0.0)
E       + (0.0, 0.0, 123, 321)

test/test_image.py:50: AssertionError
________________________________________ TestElementImage.test_image_preserveaspectratio_default ________________________________________

self = <test.test_image.TestElementImage testMethod=test_image_preserveaspectratio_default>

    def test_image_preserveaspectratio_default(self):
        """
        Square image, at 5/10 it's centered along the width putting it 5x5 image translateX(2.5)
        """
        q = io.StringIO(
            u'''
            <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 360 360" version="1.1">'
            <image width="10" height="5" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAEFklEQVR4nO3dsW7bQBRFwSjw//8yU6UJYDgil9xdnZnalp6LewhBhV/HcRy/gKTfsw8A5hEACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACPuafUDd6/X68WeO43jgEooE4GH/M/iffkcQGEUAHnJm+D+9lhBwlQDcbOTwv3ttIeAsAbjJncP/7r2EgHf5FuAGT45/hfdlXwIw2OwRzn5/9iIAA60yvlXuYH0CMMhqo1vtHtYkAAOsOrZV72IdAnDR6iNb/T7mEoALdhnXLnfyPAGAMAE4aben6m738gwBgDABOGHXp+mud3MfAYAwAXjT7k/R3e9nLAGAMAGAMAGAMAF4w6d8fv6Uv4PrBADCBADCBADCBADCBADCBADCBADCBADCBOANn/Kfdz7l7+A6AYAwAYAwAYAwAXjT7p+fd7+fsQQAwgTghF2forvezX0EAMIE4KTdnqa73cszBADCBOCCXZ6qu9zJ8wTgotXHtfp9zCUAA6w6slXvYh0CMMhqY1vtHtYkAAOtMrpV7mB9AjDY7PHNfn/2IgA3mDVC4+ddX7MP+FR/x/jEf+ExfM4SgJvdGQLD5yoBeMjIEBg+owjAw/4d7/8EweC5iwBMZtzM5FsACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACBMACPsDhkRyDUVGTB8AAAAASUVORK5CYII="/>
            </svg>
            ''')
        svg = SVG.parse(q)
        m = list(svg.elements())
        a = m[1]
        a.load()
        self.assertEqual(type(a), Image)
>       self.assertEqual((2.5, 0.0, 7.5, 5.0), a.bbox())
E       AssertionError: Tuples differ: (2.5, 0.0, 7.5, 5.0) != (0.0, 0.0, 0.0, 0.0)
E       
E       First differing element 0:
E       2.5
E       0.0
E       
E       - (2.5, 0.0, 7.5, 5.0)
E       + (0.0, 0.0, 0.0, 0.0)

test/test_image.py:67: AssertionError

@GaetanLepage
Copy link
Author

Interesting fact: If I run the test with my globally installed pytest, it works fine:

galepage in 🌐 alya in svgelements (4fe33a4) [?]  3.10.12 (venv) 
✦ ❮ ~/.local/bin/pytest test/test_image.py
Test session starts (platform: linux, Python 3.10.12, pytest 7.4.0, pytest-sugar 0.9.4)
rootdir: /scratch/alya/galepage/temp/svgelements
plugins: sugar-0.9.4, anyio-3.5.0, forked-1.4.0, xdist-2.5.0, cov-3.0.0
collecting ... 
 test/test_image.py ✓✓✓✓                                                                                                  100% ██████████

Results (0.09s):
       4 passed

galepage in 🌐 alya in svgelements (4fe33a4) [?]  3.10.12 (venv) 
✦ ❮ ./venv/bin/pytest test/test_image.py 
========================================================== test session starts ==========================================================
platform linux -- Python 3.10.12, pytest-7.4.2, pluggy-1.3.0
rootdir: /scratch/alya/galepage/temp/svgelements
collected 4 items                                                                                                                       

test/test_image.py ..FF                                                                                                           [100%]

=============================================================== FAILURES ================================================================
...
======================================================== short test summary info ========================================================
FAILED test/test_image.py::TestElementImage::test_image_preserveaspectratio - AssertionError: Tuples differ: (0.0, 0.0, 0.0, 0.0) != (0.0, 0.0, 123, 321)
FAILED test/test_image.py::TestElementImage::test_image_preserveaspectratio_default - AssertionError: Tuples differ: (2.5, 0.0, 7.5, 5.0) != (0.0, 0.0, 0.0, 0.0)
====================================================== 2 failed, 2 passed in 0.05s ======================================================

@GaetanLepage
Copy link
Author

Ok, so the issue was that I did not have pillow installed in my environment.
I would suggest you to add scipy, numpy and pillow to the test dependencies of the python project.
Indeed, they are all required to run the tests succesfully.

@tatarize
Copy link
Member

Okay. Well do. -- Repopened until I have done that.

@tatarize tatarize reopened this Sep 20, 2023
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

No branches or pull requests

2 participants