Skip to content

Commit

Permalink
Use _read for better compatibility on using U mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
tirkarthi committed Mar 1, 2020
1 parent e92e9e7 commit bf9e256
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 1 addition & 2 deletions mccabe.py
Expand Up @@ -291,8 +291,7 @@ def get_code_complexity(code, threshold=7, filename='stdin'):

def get_module_complexity(module_path, threshold=7):
"""Returns the complexity of a module"""
with open(module_path, "rU") as mod:
code = mod.read()
code = _read(module_path)
return get_code_complexity(code, threshold, filename=module_path)


Expand Down
3 changes: 3 additions & 0 deletions test_mccabe.py
Expand Up @@ -229,6 +229,9 @@ class _options(object):
mccabe.McCabeChecker.parse_options(options)
self.assertEqual(16, mccabe.McCabeChecker.max_complexity)

def test_get_module_complexity(self):
self.assertEqual(0, mccabe.get_module_complexity("mccabe.py"))


if __name__ == "__main__":
unittest.main()

0 comments on commit bf9e256

Please sign in to comment.