Skip to content

Commit

Permalink
unit test for w503 and w504 fixed methods
Browse files Browse the repository at this point in the history
  • Loading branch information
hhatto committed Sep 2, 2018
1 parent 6a68135 commit 6ae797e
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions test/test_autopep8.py
Expand Up @@ -1561,8 +1561,12 @@ def extractBlocks(self):
"""
fixed = """\
def extractBlocks(self):
addLine = (self.matchMultiple(linesIncludePatterns, line) and
not self.matchMultiple(linesExcludePatterns, line)) or emptyLine
addLine = (
self.matchMultiple(
linesIncludePatterns,
line) and not self.matchMultiple(
linesExcludePatterns,
line)) or emptyLine
"""
with autopep8_context(line, options=['-aaa']) as result:
self.assertEqual(fixed, result)
Expand Down Expand Up @@ -4266,7 +4270,7 @@ def test_w391_more_complex(self):
def test_w503(self):
line = '(width == 0\n + height == 0)\n'
fixed = '(width == 0 +\n height == 0)\n'
with autopep8_context(line, options=['-aaa']) as result:
with autopep8_context(line, options=['--select=W503']) as result:
self.assertEqual(fixed, result)

def test_w503_skip_default(self):
Expand All @@ -4277,13 +4281,13 @@ def test_w503_skip_default(self):
def test_w503_and_or(self):
line = '(width == 0\n and height == 0\n or name == "")\n'
fixed = '(width == 0 and\n height == 0 or\n name == "")\n'
with autopep8_context(line, options=['-aaa']) as result:
with autopep8_context(line, options=['--select=W503']) as result:
self.assertEqual(fixed, result)

def test_w503_with_comment(self):
line = '(width == 0 # this is comment\n + height == 0)\n'
fixed = '(width == 0 + # this is comment\n height == 0)\n'
with autopep8_context(line, options=['-aaa']) as result:
with autopep8_context(line, options=['--select=W503']) as result:
self.assertEqual(fixed, result)

def test_w503_with_comment_double(self):
Expand All @@ -4301,7 +4305,7 @@ def test_w503_with_comment_double(self):
333333333333 # C3
)
"""
with autopep8_context(line, options=['-aaa']) as result:
with autopep8_context(line, options=['--select=W503']) as result:
self.assertEqual(fixed, result)

def test_w503_over_5lines(self):
Expand All @@ -4327,7 +4331,27 @@ def test_w503_over_5lines(self):
7 # 7
)
"""
with autopep8_context(line, options=['-aaa']) as result:
with autopep8_context(line, options=['--select=W503']) as result:
self.assertEqual(fixed, result)

@unittest.skip('TODO')
def test_w503_with_line_comment(self):
line = '(width == 0\n # this is comment\n + height == 0)\n'
fixed = '(width == 0 +\n # this is comment\n height == 0)\n'
with autopep8_context(line, options=['--select=W503', '--ignore=E']) as result:
self.assertEqual(fixed, result)

def test_w504(self):
line = '(width == 0 +\n height == 0)\n'
fixed = '(width == 0\n + height == 0)\n'
with autopep8_context(line, options=['--select=W504', '--ignore=E']) as result:
self.assertEqual(fixed, result)

@unittest.skip('TODO')
def test_w504_with_line_comment(self):
line = '(width == 0 +\n # this is comment\n height == 0)\n'
fixed = '(width == 0\n # this is comment\n + height == 0)\n'
with autopep8_context(line, options=['--select=W504', '--ignore=E']) as result:
self.assertEqual(fixed, result)

def test_w601(self):
Expand Down

0 comments on commit 6ae797e

Please sign in to comment.