Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Make file normalization test work on windows
  • Loading branch information
jnmclarty committed Jun 2, 2016
commit 64332d88e2d14386df7002b5a9d7207da5fdf7ed
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/*'])