def test_analyze_error(self, check_output_mock): """Test whether an exception is thrown in case of errors""" check_output_mock.side_effect = subprocess.CalledProcessError( -1, "command", output=b'output') linguist = Linguist() kwargs = {'repository_path': self.repo_path, 'details': False} _ = linguist.analyze(**kwargs)
def test_analyze_no_details(self): """Test whether linguist returns the expected fields data""" linguist = Linguist() kwargs = {'repository_path': self.repo_path, 'details': False} result = linguist.analyze(**kwargs) self.assertNotIn('breakdown', result) self.assertIn('Python', result) self.assertTrue(type(result['Python']), float)
def __init__(self, details=False, kind=LINGUIST): self.details = details self.kind = kind if kind == LINGUIST: self.analyzer = Linguist() else: self.analyzer = Cloc()