Skip to content

Commit

Permalink
Merge 283ab80 into 2502cce
Browse files Browse the repository at this point in the history
  • Loading branch information
thebjorn committed Aug 20, 2017
2 parents 2502cce + 283ab80 commit 2088dae
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion radon/cli/harvest.py
Expand Up @@ -241,7 +241,7 @@ class MIHarvester(Harvester):

def gobble(self, fobj):
'''Analyze the content of the file object.'''
mi = mi_visit(fobj.read(), self.config.multi)
mi = mi_visit(open(fobj.name, 'rb').read(), self.config.multi)
rank = mi_rank(mi)
return {'mi': mi, 'rank': rank}

Expand Down
3 changes: 3 additions & 0 deletions radon/tests/data/__init__.py
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-


21 changes: 20 additions & 1 deletion radon/tests/test_cli.py
@@ -1,8 +1,12 @@
import os

import pytest

import radon.cli as cli
import radon.complexity as cc_mod
from radon.cli.harvest import Harvester
from radon.cli.harvest import Harvester, MIHarvester

DIRNAME = os.path.dirname(__file__)


def func(a, b=2, c=[], d=None):
Expand Down Expand Up @@ -81,6 +85,21 @@ def test_raw(mocker, log_mock):
log_mock.assert_called_once_with(mocker.sentinel.harvester, json=True)


def test_mi_encoding(mocker, log_mock):
config = cli.Config(
min='A',
max='C',
exclude=None,
ignore=None,
multi=True,
show=False,
sort=False,
)
fname = os.path.join(DIRNAME, 'data/__init__.py')
harvester = MIHarvester([fname], config)
assert not any(['error' in kw for msg, args, kw in harvester.to_terminal()])


def test_mi(mocker, log_mock):
harv_mock = mocker.patch('radon.cli.MIHarvester')
harv_mock.return_value = mocker.sentinel.harvester
Expand Down

0 comments on commit 2088dae

Please sign in to comment.