Skip to content

Commit

Permalink
custom tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adamchainz committed Nov 16, 2019
1 parent 675783f commit 8b92003
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions pyflakes/test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -1767,6 +1767,60 @@ def test_assign_expr(self):
''')


class TestUnusedFunction(TestCase):
"""
Tests for warning about unused functions.
"""

def test_unusedFunction(self):
"""
Warn when a function inside a function is defined but never used.
"""
self.flakes('''
def a():
def b():
pass
''', m.UnusedFunction)

def test_unusedUnderscoreFunction(self):
"""
Don't warn when the magic "_" (underscore) name is unused.
See issue #202.
"""
self.flakes('''
def a():
def _():
pass
''')


class TestUnusedClass(TestCase):
"""
Tests for warning about unused classes.
"""

def test_unusedClass(self):
"""
Warn when a class inside a function is defined but never used.
"""
self.flakes('''
def a():
class B:
pass
''', m.UnusedClass)

def test_unusedUnderscoreClass(self):
"""
Don't warn when the magic "_" (underscore) name is unused.
See issue #202.
"""
self.flakes('''
def a():
class _:
pass
''')


class TestStringFormatting(TestCase):

@skipIf(version_info < (3, 6), 'new in Python 3.6')
Expand Down

0 comments on commit 8b92003

Please sign in to comment.