Skip to content

Commit

Permalink
Make file normalization test work on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jnmclarty committed Jun 2, 2016
1 parent fd4f1c2 commit 64332d8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pycodestyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -1317,9 +1317,9 @@ def normalize_paths(value, parent=os.curdir):
paths = []
for path in value.split(','):
path = path.strip()
if '/' in path:
if os.path.sep in path:
path = os.path.abspath(os.path.join(parent, path))
paths.append(path.rstrip('/'))
paths.append(path.rstrip(os.path.sep))
return paths


Expand Down
16 changes: 11 additions & 5 deletions testsuite/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
import os
import unittest

import sys
from pycodestyle import normalize_paths


Expand All @@ -17,7 +17,13 @@ def test_normalize_paths(self):
self.assertEqual(normalize_paths('foo'), ['foo'])
self.assertEqual(normalize_paths('foo,bar'), ['foo', 'bar'])
self.assertEqual(normalize_paths('foo, bar '), ['foo', 'bar'])
self.assertEqual(normalize_paths('/foo/bar,baz/../bat'),
['/foo/bar', cwd + '/bat'])
self.assertEqual(normalize_paths(".pyc,\n build/*"),
['.pyc', cwd + '/build/*'])

if 'win' in sys.platform:
self.assertEqual(normalize_paths(r'C:\foo\bar,baz\..\bat'),
[r'C:\foo\bar', cwd + r'\bat'])
self.assertEqual(normalize_paths(".pyc"), ['.pyc'])
else:
self.assertEqual(normalize_paths('/foo/bar,baz/../bat'),
['/foo/bar', cwd + '/bat'])
self.assertEqual(normalize_paths(".pyc,\n build/*"),
['.pyc', cwd + '/build/*'])

0 comments on commit 64332d8

Please sign in to comment.