Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion pycycle/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def get_path_from_package_name(root, pkg):
if not pkg or not root:
return ''
modules = pkg.split(".")
return os.path.join(root, os.sep.join(modules) + '.py')
return os.path.join(os.path.normpath(root), os.sep.join(modules) + '.py')


def get_import_context(node):
Expand Down
8 changes: 4 additions & 4 deletions test_pycycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ def test_get_path_from_package_name():

func = pycycle.utils.get_path_from_package_name

assert func('/test/one/two', 'some.package') == '/test/one/two/some/package.py'
assert func('/test/one/two', 'some.package') == os.path.normpath('/test/one/two/some/package.py')
assert func('', 'some.package') == ''
assert func('/', None) == ''
assert func(None, 'some.package') == ''
assert func('/test/', 'some_package') == '/test/some_package.py'
assert func('/test/', 'some_package') == os.path.normpath('/test/some_package.py')


def test_format_path():
Expand All @@ -26,7 +26,7 @@ def test_simple_project():
'result': 'b_module -> a_module: Line 1 =>> b_module'}

root_node = pycycle.utils.read_project(project['path'])
assert root_node != None
assert root_node is not None
assert pycycle.utils.check_if_cycles_exist(
root_node) == project['has_cycle']
assert pycycle.utils.get_cycle_path(root_node, acc=[], seen=set()) == project['result']
Expand Down Expand Up @@ -85,4 +85,4 @@ def test_import_context():
root_node = pycycle.utils.read_project(project['path'])
assert root_node is not None
assert pycycle.utils.check_if_cycles_exist(
root_node) == project['has_cycle']
root_node) == project['has_cycle']