Address test failures
More details about the fix to the testDuration failure (regression):
```
FAIL: testDuration (whipper.test.test_image_toc.CapitalMergeTestCase)
testDuration
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/twisted/internet/defer.py", line 151, in maybeDeferred
result = f(*args, **kw)
File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/twisted/internet/utils.py", line 221, in runWithWarningsSuppressed
reraise(exc_info[1], exc_info[2])
File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/twisted/python/compat.py", line 464, in reraise
raise exception.with_traceback(traceback)
File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/twisted/internet/utils.py", line 217, in runWithWarningsSuppressed
result = f(*a, **kw)
File "/home/travis/build/whipper-team/whipper/whipper/test/test_image_toc.py", line 271, in testDuration
self.assertEqual(self.table.getFrameLength(), 173530)
File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/twisted/trial/_synctest.py", line 432, in assertEqual
super(_Assertions, self).assertEqual(first, second, msg)
File "/opt/python/3.5.6/lib/python3.5/unittest/case.py", line 829, in assertEqual
assertion_func(first, second, msg=msg)
File "/opt/python/3.5.6/lib/python3.5/unittest/case.py", line 822, in _baseAssertEqual
raise self.failureException(msg)
twisted.trial.unittest.FailTest: 184930 != 173530
```
The test fails because if either nextTrack.session or thisTrack.session are None the if is false and the instructions inside it aren't executed. The check for None is needed because Python 3 doesn't allow NoneType comparisons (in Python 2 that was possible).
IIRC correctly in that test nextTrack.session has value 2 while thisTrack.session is None. That means the Python 2 version evaluates the if condition to true, while the Python 3 version in the first commit does not.
With this change both of the values of nextTrack.session and thisTrack.session are compared as int (if None, the value 1 is used for the comparison - as in disc session 1).
Regression introduced in 64dd9d843a.
Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
This commit is contained in:
@@ -193,7 +193,8 @@ def _match_responses(tracks, responses):
|
||||
for i, track in enumerate(tracks):
|
||||
for v in ('v1', 'v2'):
|
||||
if track.AR[v]['CRC'] == r.checksums[i]:
|
||||
if r.confidences[i] > track.AR[v]['DBConfidence']:
|
||||
if (track.AR[v]['DBConfidence'] is None or
|
||||
r.confidences[i] > track.AR[v]['DBConfidence']):
|
||||
track.AR[v]['DBCRC'] = r.checksums[i]
|
||||
track.AR[v]['DBConfidence'] = r.confidences[i]
|
||||
logger.debug(
|
||||
@@ -242,7 +243,8 @@ def print_report(result):
|
||||
track.AR['v2']['DBCRC']
|
||||
) if _f])
|
||||
max_conf = max(
|
||||
[track.AR[v]['DBConfidence'] for v in ('v1', 'v2')]
|
||||
[track.AR[v]['DBConfidence'] for v in ('v1', 'v2')
|
||||
if track.AR[v]['DBConfidence'] is not None], default=None
|
||||
)
|
||||
if max_conf:
|
||||
if max_conf < track.AR['DBMaxConfidence']:
|
||||
|
||||
@@ -98,7 +98,7 @@ class Persister:
|
||||
if not os.path.exists(self._path):
|
||||
return
|
||||
|
||||
handle = open(self._path)
|
||||
handle = open(self._path, 'rb')
|
||||
import pickle
|
||||
|
||||
try:
|
||||
|
||||
@@ -44,7 +44,7 @@ class Config:
|
||||
# Open the file with the correct encoding
|
||||
if os.path.exists(self._path):
|
||||
with codecs.open(self._path, 'r', encoding='utf-8') as f:
|
||||
self._parser.readfp(f)
|
||||
self._parser.read_file(f)
|
||||
|
||||
logger.debug('loaded %d sections from config file',
|
||||
len(self._parser.sections()))
|
||||
|
||||
@@ -91,7 +91,7 @@ class Operator:
|
||||
Execute the operations
|
||||
"""
|
||||
|
||||
def next(self):
|
||||
def __next__(self):
|
||||
operation = self._todo[len(self._done)]
|
||||
if self._resuming:
|
||||
operation.redo()
|
||||
@@ -199,7 +199,8 @@ class RenameInFile(Operation):
|
||||
(fd, name) = tempfile.mkstemp(suffix='.whipper')
|
||||
|
||||
for s in handle:
|
||||
os.write(fd, s.replace(self._source, self._destination))
|
||||
os.write(fd,
|
||||
s.replace(self._source, self._destination).encode())
|
||||
|
||||
os.close(fd)
|
||||
os.rename(name, self._path)
|
||||
|
||||
Reference in New Issue
Block a user