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

0.13: pytest is failing in 7 units #163

Open
kloczek opened this issue May 18, 2022 · 1 comment
Open

0.13: pytest is failing in 7 units #163

kloczek opened this issue May 18, 2022 · 1 comment

Comments

@kloczek
Copy link

kloczek commented May 18, 2022

I'm trying to package your module as an rpm package. So I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

  • python3 -sBm build -w --no-isolation
  • because I'm calling build with --no-isolation I'm using during all processes only locally installed modules
  • install .whl file in </install/prefix>
  • run pytest with PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>

Here is pytest output:

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-cppclean-0.13-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-cppclean-0.13-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.13, pytest-7.1.2, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/cppclean-0.13
plugins: anyio-3.5.0, tornasync-0.6.0.post2, timeout-2.1.0, cov-3.0.0, black-0.3.12
collected 153 items

test_ast.py .............F.............................F......F..............................FFF....F........................                                        [ 73%]
test_find_warnings.py ..                                                                                                                                             [ 75%]
test_symbols.py ..........                                                                                                                                           [ 81%]
test_tokenize.py ............................                                                                                                                        [100%]

================================================================================= FAILURES =================================================================================
_______________________________________________________ TypeConverterToParametersTest.test_simple_with_initializers ________________________________________________________

self = <test_ast.TypeConverterToParametersTest testMethod=test_simple_with_initializers>

    def test_simple_with_initializers(self):
        tokens = get_tokens('Fool* data = NULL')
        results = self.converter.to_parameters(list(tokens))
        self.assertEqual(1, len(results), repr(results))

        self.assertEqual([], results[0].type.modifiers)
        self.assertEqual('Fool', results[0].type.name)
        self.assertEqual([], results[0].type.templated_types)
        self.assertEqual(True, results[0].type.pointer)
        self.assertEqual(False, results[0].type.reference)
        self.assertEqual(False, results[0].type.array)
        self.assertEqual('data', results[0].name)
>       self.assertEqual([Token('NULL')], results[0].default)
E       AssertionError: Lists differ: [Token('NULL', 0, 0)] != [Token('NULL', 13, 17)]
E
E       First differing element 0:
E       Token('NULL', 0, 0)
E       Token('NULL', 13, 17)
E
E       - [Token('NULL', 0, 0)]
E       ?                ^  ^
E
E       + [Token('NULL', 13, 17)]
E       ?                ^^  ^^

test_ast.py:370: AssertionError
_____________________________________________ ASTBuilderIntegrationTest.test_class_colon_separated_class_name_and_inline_dtor ______________________________________________

self = <test_ast.ASTBuilderIntegrationTest testMethod=test_class_colon_separated_class_name_and_inline_dtor>

    def test_class_colon_separated_class_name_and_inline_dtor(self):
        method_body = 'XXX(1) << "should work";'
        code = 'class Foo::Bar { ~Bar() { %s } };' % method_body
        nodes = list(MakeBuilder(code).generate())
        self.assertEqual(1, len(nodes), repr(nodes))
        function = nodes[0].body[0]
        expected = Function('Bar', [], [], body=list(get_tokens(method_body)),
                            modifiers=ast.FUNCTION_DTOR)
        self.assertEqual(expected.return_type, function.return_type)
>       self.assertEqual(expected, function)
E       AssertionError: Function(0, 0, None Bar([]), 0x10, [Token('XXX', 0[126 chars]24)]) != Function(18, 21, None Bar([]), 0x10, [Token('XXX',[138 chars]50)])

test_ast.py:954: AssertionError
________________________________________________________ ASTBuilderIntegrationTest.test_class_handles_struct_rebind ________________________________________________________

self = <test_ast.ASTBuilderIntegrationTest testMethod=test_class_handles_struct_rebind>

    def test_class_handles_struct_rebind(self):
        code = """
        template <typename T, typename Alloc = std::allocator<T> >
        class AnotherAllocator : public Alloc {
            template <class U> struct rebind {
            };
        };
        """
        types1 = {}
        types1['Alloc'] = (None, list(get_tokens('std::allocator<T>')))
        types1['T'] = (None, None)
        types2 = {}
        types2['U'] = (None, None)

        nodes = list(MakeBuilder(code).generate())
        self.assertEqual(1, len(nodes), repr(nodes))
>       self.assertEqual(Class('AnotherAllocator', bases=[Type('Alloc')],
                               body=[Struct('rebind', body=[],
                                            templated_types=types2)],
                               templated_types=types1,),
                         nodes[0])
E       AssertionError: Class(0, 0, AnotherAllocator<Alloc,T>, [Type(0,[44 chars][])]) != Class(82, 98, AnotherAllocator<T,Alloc>, [Type([54 chars][])])

test_ast.py:973: AssertionError
________________________________________________ ASTBuilderIntegrationTest.test_method_with_template_class_with2args_works _________________________________________________

self = <test_ast.ASTBuilderIntegrationTest testMethod=test_method_with_template_class_with2args_works>

    def test_method_with_template_class_with2args_works(self):
        code = """
        template <class T, typename U>
        inline void EVM::VH<T, U>::Write() {
        }
        """
        nodes = list(MakeBuilder(code).generate())
        self.assertEqual(1, len(nodes), repr(nodes))
        expected = Method('Write', list(get_tokens('EVM::VH<T, U>')),
                          list(get_tokens('inline void')), [],
                          templated_types={'T': (None, None),
                                           'U': (None, None)},
                          body=[])
        self.assertEqual(expected.return_type, nodes[0].return_type)
>       self.assertEqual(expected.in_class, nodes[0].in_class)
E       AssertionError: Lists differ: [Token('EVM', 0, 3), Token('::', 3, 5), Token('VH', 5, [93 chars] 13)] != [Token('EVM', 60, 63), Token('::', 63, 65), Token('VH',[104 chars] 73)]
E
E       First differing element 0:
E       Token('EVM', 0, 3)
E       Token('EVM', 60, 63)
E
E       - [Token('EVM', 0, 3),
E       + [Token('EVM', 60, 63),
E       ?               +   +
E
E       -  Token('::', 3, 5),
E       +  Token('::', 63, 65),
E       ?              +   +
E
E       -  Token('VH', 5, 7),
E       +  Token('VH', 65, 67),
E       ?              +   +
E
E       -  Token('<', 7, 8),
E       +  Token('<', 67, 68),
E       ?             +   +
E
E       -  Token('T', 8, 9),
E       +  Token('T', 68, 69),
E       ?             +   +
E
E       -  Token(',', 9, 10),
E       ?                ^
E
E       +  Token(',', 69, 70),
E       ?             +   ^
E
E       -  Token('U', 11, 12),
E       ?             ^   ^
E
E       +  Token('U', 71, 72),
E       ?             ^   ^
E
E       -  Token('>', 12, 13)]
E       ?             ^   ^
E
E       +  Token('>', 72, 73)]
E       ?             ^   ^

test_ast.py:1100: AssertionError
________________________________________________ ASTBuilderIntegrationTest.test_method_with_template_class_with3args_works _________________________________________________

self = <test_ast.ASTBuilderIntegrationTest testMethod=test_method_with_template_class_with3args_works>

    def test_method_with_template_class_with3args_works(self):
        code = """
        template <class CT, class IT, class DT>
        DT* Worker<CT, IT, DT>::Create() {
        }
        """
        nodes = list(MakeBuilder(code).generate())
        self.assertEqual(1, len(nodes), repr(nodes))
        tt = (None, None)
        expected = Method('Create', list(get_tokens('Worker<CT, IT, DT>')),
                          list(get_tokens('DT*')), [],
                          templated_types={'CT': tt, 'IT': tt, 'DT': tt},
                          body=[])
        self.assertEqual(expected.return_type, nodes[0].return_type)
>       self.assertEqual(expected.in_class, nodes[0].in_class)
E       AssertionError: Lists differ: [Token('Worker', 0, 6), Token('<', 6, 7), Token('CT', 7, 9[98 chars] 18)] != [Token('Worker', 61, 67), Token('<', 67, 68), Token('CT', [105 chars] 79)]
E
E       First differing element 0:
E       Token('Worker', 0, 6)
E       Token('Worker', 61, 67)
E
E       Diff is 733 characters long. Set self.maxDiff to None to see it.

test_ast.py:1118: AssertionError
_____________________________________________________ ASTBuilderIntegrationTest.test_method_with_template_class_works ______________________________________________________

self = <test_ast.ASTBuilderIntegrationTest testMethod=test_method_with_template_class_works>

    def test_method_with_template_class_works(self):
        code = """
        template <class T>
        inline void EVM::VH<T>::Write() {
        }
        """
        nodes = list(MakeBuilder(code).generate())
        self.assertEqual(1, len(nodes), repr(nodes))
        expected = Method('Write', list(get_tokens('EVM::VH<T>')),
                          list(get_tokens('inline void')), [],
                          templated_types={'T': (None, None)},
                          body=[])
        self.assertEqual(expected.return_type, nodes[0].return_type)
>       self.assertEqual(expected.in_class, nodes[0].in_class)
E       AssertionError: Lists differ: [Token('EVM', 0, 3), Token('::', 3, 5), Token('VH', 5, [53 chars] 10)] != [Token('EVM', 48, 51), Token('::', 51, 53), Token('VH',[64 chars] 58)]
E
E       First differing element 0:
E       Token('EVM', 0, 3)
E       Token('EVM', 48, 51)
E
E       - [Token('EVM', 0, 3),
E       ?               ^  ^
E
E       + [Token('EVM', 48, 51),
E       ?               ^^  ^^
E
E       -  Token('::', 3, 5),
E       ?               ---
E
E       +  Token('::', 51, 53),
E       ?              +++++
E
E       -  Token('VH', 5, 7),
E       ?                 ^
E
E       +  Token('VH', 53, 55),
E       ?               +  ^^
E
E       -  Token('<', 7, 8),
E       ?             ^  ^
E
E       +  Token('<', 55, 56),
E       ?             ^^  ^^
E
E       -  Token('T', 8, 9),
E       ?             ^  ^
E
E       +  Token('T', 56, 57),
E       ?             ^^  ^^
E
E       -  Token('>', 9, 10)]
E       ?             ^  ^^
E
E       +  Token('>', 57, 58)]
E       ?             ^^  ^^

test_ast.py:1082: AssertionError
_________________________________________________________________ ASTBuilderIntegrationTest.test_operators _________________________________________________________________

self = <test_ast.ASTBuilderIntegrationTest testMethod=test_operators>

    def test_operators(self):
        for operator in ('=', '+=', '-=', '*=', '==', '!=', '()', '[]', '<',
                         '>', '^=', '<<=', '>>='):
            code = 'void Foo::operator%s();' % operator
            nodes = list(MakeBuilder(code).generate())
            self.assertEqual(1, len(nodes), repr(nodes))
>           self.assertEqual(Method(('operator%s' % operator),
                                    list(get_tokens('Foo')),
                                    list(get_tokens('void')), []), nodes[0])
E           AssertionError: Method(0, 0, Type(0, 4, void) operator=([]), 0x00, None) != Method(0, 4, Type(0, 4, void) operator=([]), 0x00, None)

test_ast.py:883: AssertionError
========================================================================= short test summary info ==========================================================================
FAILED test_ast.py::TypeConverterToParametersTest::test_simple_with_initializers - AssertionError: Lists differ: [Token('NULL', 0, 0)] != [Token('NULL', 13, 17)]
FAILED test_ast.py::ASTBuilderIntegrationTest::test_class_colon_separated_class_name_and_inline_dtor - AssertionError: Function(0, 0, None Bar([]), 0x10, [Token('XXX', 0...
FAILED test_ast.py::ASTBuilderIntegrationTest::test_class_handles_struct_rebind - AssertionError: Class(0, 0, AnotherAllocator<Alloc,T>, [Type(0,[44 chars][])]) != Class...
FAILED test_ast.py::ASTBuilderIntegrationTest::test_method_with_template_class_with2args_works - AssertionError: Lists differ: [Token('EVM', 0, 3), Token('::', 3, 5), To...
FAILED test_ast.py::ASTBuilderIntegrationTest::test_method_with_template_class_with3args_works - AssertionError: Lists differ: [Token('Worker', 0, 6), Token('<', 6, 7), ...
FAILED test_ast.py::ASTBuilderIntegrationTest::test_method_with_template_class_works - AssertionError: Lists differ: [Token('EVM', 0, 3), Token('::', 3, 5), Token('VH', ...
FAILED test_ast.py::ASTBuilderIntegrationTest::test_operators - AssertionError: Method(0, 0, Type(0, 4, void) operator=([]), 0x00, None) != Method(0, 4, Type(0, 4, void)...
====================================================================== 7 failed, 146 passed in 0.60s =======================================================================
@kloczek
Copy link
Author

kloczek commented Oct 15, 2023

Gentle pong .. 🤔

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

1 participant