mogui/pyorient

AttributeError: can't set attribute in groovy.py

Closed this issue · 0 comments

Running the tests on the current develop branch on OS X Yosemite with the default python 2 (version 2.7.10) causes two tests to fail:

======================================= FAILURES =======================================
_____________________________ OGMAnimalsTestCase.testGraph _____________________________

self = <tests.test_ogm.OGMAnimalsTestCase testMethod=testGraph>

    def testGraph(self):
        < ... >
        g.scripts.add(GroovyScripts.from_string(
    """
    def get_eaters_of(food_type) {
        return g.V('@class', 'food').has('name', T.eq, food_type).inE().outV();
    }

    def get_foods_eaten_by(animal) {
        return g.v(animal).outE('eats').inV()
    }

    def get_colored_eaten_foods(animal, color) {
        return g.v(animal).outE('eats').inV().has('color', T.eq, color)
    }
>   """))

tests/test_ogm.py:120: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
pyorient/groovy.py:123: in from_string
    parser.parse(groovy_str)
pyorient/groovy.py:137: in parse
    scanner = Scanner(handlers).scan(io.StringIO(u(groovy_str)))
pyorient/groovy.py:52: in __init__
    self.group_pattern = self._get_group_pattern(flags)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pyorient.groovy.Scanner object at 0x101f15390>, flags = 0

    def _get_group_pattern(self,flags):
        # combine phrases into a compound pattern
        patterns = []
        sub_pattern = sre_parse.Pattern()
        sub_pattern.flags = flags
        for phrase, action in self.lexicon:
            patterns.append(sre_parse.SubPattern(sub_pattern, [
                (SUBPATTERN, (len(patterns) + 1
                    , sre_parse.parse(phrase, flags))),
                ]))
>       sub_pattern.groups = len(patterns) + 1
E       AttributeError: can't set attribute

pyorient/groovy.py:64: AttributeError
______________________________ OGMMoneyTestCase.testMoney ______________________________

self = <tests.test_ogm.OGMMoneyTestCase testMethod=testMoney>

    def testMoney(self):
        < ... >
        g.scripts.add(GroovyScripts.from_file(
            os.path.join(
                os.path.split(
>                   os.path.abspath(__file__))[0], 'money.groovy')), 'money')

tests/test_ogm.py:235: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
pyorient/groovy.py:116: in from_file
    parser.include(groovy_path)
pyorient/groovy.py:132: in include
    Scanner(handlers).scan(groovy_file)
pyorient/groovy.py:52: in __init__
    self.group_pattern = self._get_group_pattern(flags)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pyorient.groovy.Scanner object at 0x101f19470>, flags = 0

    def _get_group_pattern(self,flags):
        # combine phrases into a compound pattern
        patterns = []
        sub_pattern = sre_parse.Pattern()
        sub_pattern.flags = flags
        for phrase, action in self.lexicon:
            patterns.append(sre_parse.SubPattern(sub_pattern, [
                (SUBPATTERN, (len(patterns) + 1
                    , sre_parse.parse(phrase, flags))),
                ]))
>       sub_pattern.groups = len(patterns) + 1
E       AttributeError: can't set attribute

pyorient/groovy.py:64: AttributeError
========================= 2 failed, 93 passed in 5.41 seconds ==========================

This seems to be an error caused by an update to the python standard library, where the groups attribute was turned into a read-only property. Other projects are affected too:
nltk/nltk#1106