Skip to content

Commit 03c8d15

Browse files
committed
fixed for test cases: sending None paths in test_deltacode.py
Signed-off-by: Pratikrocks <pratikrocks.dey11@gmail.com>
1 parent 1b639c6 commit 03c8d15

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

src/deltacode/__init__.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from __future__ import absolute_import
2727

2828
from collections import OrderedDict
29+
import click
2930

3031
from deltacode.models import File
3132
from deltacode.models import Scan
@@ -49,11 +50,13 @@ class DeltaCode(object):
4950
the form of File objects) contained in those scans.
5051
"""
5152
def __init__(self, new_path, old_path, options):
53+
self.codebase1 = None
54+
self.codebase2 = None
5255
try:
5356
self.codebase1 = VirtualCodebase(new_path)
5457
self.codebase2 = VirtualCodebase(old_path)
5558
except Exception as exception:
56-
pass
59+
click.secho(exception.message ,fg = "red")
5760
self.new_files_count = 0 #keeps the count of the new file
5861
self.old_files_count = 0 #keeps the count of old files
5962
self.new_files = [] # a list of [[new file1:Original path],[new file2:Original Path],...]
@@ -63,10 +66,10 @@ def __init__(self, new_path, old_path, options):
6366
self.options = options
6467
self.deltas = []
6568
self.errors = []
66-
self.enumerate_files_from_codebases()
67-
self.stats = Stat(self.new_files_count, self.old_files_count)
68-
if new_path != None and old_path != None:
69-
69+
70+
if self.codebase1 != None and self.codebase2 != None:
71+
self.enumerate_files_from_codebases()
72+
self.stats = Stat(self.new_files_count, self.old_files_count)
7073
self.new_files_errors = []
7174
self.old_files_errors = []
7275
self.determine_delta()

src/deltacode/utils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,11 @@ def calculate_percent(value, total):
206206
"""
207207
Return the rounded value percentage of total.
208208
"""
209-
ratio = (value / total) * 100
210-
return round(ratio, 2)
209+
try :
210+
ratio = (value / total) * 100
211+
return round(ratio, 2)
212+
except ZeroDivisionError:
213+
return 0
211214

212215
class AlignmentException(Exception):
213216
"""

0 commit comments

Comments
 (0)