~hltbra/pyflakes/py3k-convertable

« back to all changes in this revision

Viewing changes to pyflakes/test/test_other.py

  • Committer: exarkun
  • Date: 2010-04-03 13:46:54 UTC
  • Revision ID: importd@pear-20100403134654-x4qdgcc0la2tjf1t
Merge pyflakes-class-name-binding-2999

Author: exarkun
Reviewer: jesstess, mithrandi
Fixes: #2999

Fix a bug in the checker's handling of class names which caused
a class's own binding to be considered valid within the definition
of the class itself.

Now the binding is only valid after the class definition.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# (c) 2005-2008 Divmod, Inc.
 
1
# (c) 2005-2010 Divmod, Inc.
2
2
# See LICENSE file for details
3
3
 
4
4
"""
85
85
        ''', m.UndefinedName)
86
86
 
87
87
 
 
88
    def test_classNameUndefinedInClassBody(self):
 
89
        """
 
90
        If a class name is used in the body of that class's definition and
 
91
        the name is not already defined, a warning is emitted.
 
92
        """
 
93
        self.flakes('''
 
94
        class foo:
 
95
            foo
 
96
        ''', m.UndefinedName)
 
97
 
 
98
 
 
99
    def test_classNameDefinedPreviously(self):
 
100
        """
 
101
        If a class name is used in the body of that class's definition and
 
102
        the name was previously defined in some other way, no warning is
 
103
        emitted.
 
104
        """
 
105
        self.flakes('''
 
106
        foo = None
 
107
        class foo:
 
108
            foo
 
109
        ''')
 
110
 
 
111
 
88
112
 
89
113
class TestUnusedAssignment(harness.Test):
90
114
    """