Skip to content

Unit tets faileurs: test_build_one, test_stack_trace_formatting #440

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

Closed
Hellseher opened this issue Sep 5, 2023 · 2 comments
Closed

Unit tets faileurs: test_build_one, test_stack_trace_formatting #440

Hellseher opened this issue Sep 5, 2023 · 2 comments

Comments

@Hellseher
Copy link

Hellseher commented Sep 5, 2023

Hi,

I tried to fix build issue of the package available via Guix for this project.
There were 2 failed unit tests which are blocking the build of the package:

============================= test session starts ==============================
platform linux -- Python 3.10.7, pytest-7.1.3, pluggy-1.0.0
rootdir: /tmp/guix-build-python-libsass-0.22.0.drv-0/source
plugins: hypothesis-6.54.5
collected 107 items

sasstests.py ..................................F........................ [ 55%]
.........................................F......                         [100%]

=================================== FAILURES ===================================
_______________________ ManifestTestCase.test_build_one ________________________

self = <sasstests.ManifestTestCase testMethod=test_build_one>

    def test_build_one(self):
        with tempdir() as d:
            src_path = os.path.join(d, 'test')

            shutil.copytree('test', src_path)
            with pytest.warns(FutureWarning):
                m = Manifest(sass_path='test', css_path='css')

            m.build_one(d, 'a.scss')
            with open(os.path.join(d, 'css', 'a.scss.css')) as f:
                assert A_EXPECTED_CSS == f.read()
            m.build_one(d, 'b.scss', source_map=True)
            with open(
                os.path.join(d, 'css', 'b.scss.css'), encoding='UTF-8',
            ) as f:
                assert f.read() == _map_in_output_dir(B_EXPECTED_CSS_WITH_MAP)
            self.assert_source_map_file(
                {
                    'version': 3,
                    'file': 'b.scss.css',
                    'sources': ['../test/b.scss'],
                    'names': [],
                    'mappings': (
                        'AAAA,AACE,CADD,CACC,CAAC,CAAC;EACA,SAAS,EAAE,IAAI,'
                        'GAChB'
                    ),
                },
                os.path.join(d, 'css', 'b.scss.css.map'),
            )
            m.build_one(d, 'd.scss', source_map=True)
            with open(
                os.path.join(d, 'css', 'd.scss.css'), encoding='UTF-8',
            ) as f:
                assert f.read() == _map_in_output_dir(D_EXPECTED_CSS_WITH_MAP)
>           self.assert_source_map_file(
                {
                    'version': 3,
                    'file': 'd.scss.css',
                    'sources': ['../test/d.scss'],
                    'names': [],
                    'mappings': (
                        ';AAKA,AAAA,IAAI,CAAC;EAHH,gBAAgB,EAAE,KAAK,GAQxB;'
                        'EALD,AAEE,IAFE,CAEF,CAAC,CAAC;IACA,IAAI,EAAE,kBAAkB,'
                        'GACzB'
                    ),
                },
                os.path.join(d, 'css', 'd.scss.css.map'),
            )

sasstests.py:776:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
sasstests.py:176: in assert_source_map_file
    self.assert_source_map_equal(expected, tree)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <sasstests.ManifestTestCase testMethod=test_build_one>
expected = {'file': 'd.scss.css', 'mappings': ';AAKA,AAAA,IAAI,CAAC;EAHH,gBAAgB,EAAE,KAAK,GAQxB;EALD,AAEE,IAFE,CAEF,CAAC,CAAC;IACA,IAAI,EAAE,kBAAkB,GACzB', 'names': [], 'sources': ['../test/d.scss'], ...}
actual = {'file': 'd.scss.css', 'mappings': ';AAKA,AAAA,IAAI,CAAC;EAHH,gBAAgB,EAAE,KAAK,GAQxB;EALD,AAEE,IAFE,CAEF,CAAC,CAAC;IACA,IAAI,EAAE,sBAAsB,GAC7B', 'names': [], 'sources': ['../test/d.scss'], ...}

    def assert_source_map_equal(self, expected, actual):
        if isinstance(expected, str):
            expected = json.loads(expected)
        if isinstance(actual, str):
            actual = json.loads(actual)
>       assert expected == actual
E       AssertionError: assert {'file': 'd.s...d.scss'], ...} == {'file': 'd.s...d.scss'], ...}
E         Omitting 4 identical items, use -vv to show
E         Differing items:
E         {'mappings': ';AAKA,AAAA,IAAI,CAAC;EAHH,gBAAgB,EAAE,KAAK,GAQxB;EALD,AAEE,IAFE,CAEF,CAAC,CAAC;IACA,IAAI,EAAE,kBAAkB,GACzB'} != {'mappings': ';AAKA,AAAA,IAAI,CAAC;EAHH,gBAAgB,EAAE,KAAK,GAQxB;EALD,AAEE,IAFE,CAEF,CAAC,CAAC;IACA,IAAI,EAAE,sBAAsB,GAC7B'}
E         Use -v to get more diff

sasstests.py:166: AssertionError
_________________________ test_stack_trace_formatting __________________________

    def test_stack_trace_formatting():
        try:
            sass.compile(string='a{☃')
            raise AssertionError('expected to raise CompileError')
        except sass.CompileError:
            tb = traceback.format_exc()
        # TODO: https://github.com/sass/libsass/issues/3092
>       assert tb.endswith(
            'CompileError: Error: Invalid CSS after "a{☃": expected "{", was ""\n'
            '        on line 1:4 of stdin\n'
            '>> a{☃\n'
            '   ---^\n\n',
        )
E       assert False
E        +  where False = <built-in method endswith of str object at 0xaedf10>('CompileError: Error: Invalid CSS after "a{☃": expected "{", was ""\n        on line 1:4 of stdin\n>> a{☃\n   ---^\n\n')
E        +    where <built-in method endswith of str object at 0xaedf10> = 'Traceback (most recent call last):\n  File "/tmp/guix-build-python-libsass-0.22.0.drv-0/source/sasstests.py", line 16...CompileError: Error: Invalid CSS after "a{☃": expected "{", was ""\n        on
 line 1:5 of stdin\n>> a{☃\n   ----^\n\n'.endswith

sasstests.py:1619: AssertionError
=========================== short test summary info ============================
FAILED sasstests.py::ManifestTestCase::test_build_one - AssertionError: asser...
FAILED sasstests.py::test_stack_trace_formatting - assert False
======================== 2 failed, 105 passed in 0.85s =========================

The system [email protected] is in use.

To reproduce the issue you may use Guix time machine functionality:

guix time-machine --commit=eeb71d778f149834015858467fbeeb1276d96d1d -- build --system=x86_64-linux --with-commit=python-libsass=0.22.0 python-libsass
@asottile
Copy link
Member

asottile commented Sep 5, 2023

we test against a very specific version of libsass. if you deviate from that that's on you.

@asottile asottile closed this as completed Sep 5, 2023
@Hellseher
Copy link
Author

Hi,

You are turbo quick!

I may confirm that [email protected] is built with [email protected] sucessfully.

guix time-machine --commit=eeb71d778f149834015858467fbeeb1276d96d1d -- build --system=x86_64-linux --with-commit=python-libsass=0.22.0 --with-commit=libsass=3.6.5 python-libsass
...
successfully built /gnu/store/5648x14pkyl673szwfbj05c26qs46g64-python-libsass-0.22.0.drv
/gnu/store/ii7d0x13brlg8lhcchcdbi94qlrgn0d6-python-libsass-0.22.0

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