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:
JoeLametta
2019-08-10 09:30:00 +00:00
parent 35201d5290
commit fff3014e15
11 changed files with 38 additions and 33 deletions

View File

@@ -18,7 +18,7 @@ class MetadataTestCase(unittest.TestCase):
filename = 'whipper.release.c56ff16e-1d81-47de-926f-ba22891bd2bd.json'
path = os.path.join(os.path.dirname(__file__), filename)
handle = open(path, "rb")
response = json.loads(handle.read())
response = json.loads(handle.read().decode('utf-8'))
handle.close()
discid = "b.yqPuCBdsV5hrzDvYrw52iK_jE-"
@@ -31,7 +31,7 @@ class MetadataTestCase(unittest.TestCase):
filename = 'whipper.release.a76714e0-32b1-4ed4-b28e-f86d99642193.json'
path = os.path.join(os.path.dirname(__file__), filename)
handle = open(path, "rb")
response = json.loads(handle.read())
response = json.loads(handle.read().decode('utf-8'))
handle.close()
discid = "f7XO36a7n1LCCskkCiulReWbwZA-"
@@ -59,7 +59,7 @@ class MetadataTestCase(unittest.TestCase):
filename = 'whipper.release.e32ae79a-336e-4d33-945c-8c5e8206dbd3.json'
path = os.path.join(os.path.dirname(__file__), filename)
handle = open(path, "rb")
response = json.loads(handle.read())
response = json.loads(handle.read().decode('utf-8'))
handle.close()
discid = "xAq8L4ELMW14.6wI6tt7QAcxiDI-"
@@ -93,7 +93,7 @@ class MetadataTestCase(unittest.TestCase):
filename = 'whipper.release.61c6fd9b-18f8-4a45-963a-ba3c5d990cae.json'
path = os.path.join(os.path.dirname(__file__), filename)
handle = open(path, "rb")
response = json.loads(handle.read())
response = json.loads(handle.read().decode('utf-8'))
handle.close()
discid = "u0aKVpO.59JBy6eQRX2vYcoqQZ0-"
@@ -130,7 +130,7 @@ class MetadataTestCase(unittest.TestCase):
filename = 'whipper.release.8478d4da-0cda-4e46-ae8c-1eeacfa5cf37.json'
path = os.path.join(os.path.dirname(__file__), filename)
handle = open(path, "rb")
response = json.loads(handle.read())
response = json.loads(handle.read().decode('utf-8'))
handle.close()
discid = "RhrwgVb0hZNkabQCw1dZIhdbMFg-"
@@ -167,7 +167,7 @@ class MetadataTestCase(unittest.TestCase):
filename = 'whipper.release.f484a9fc-db21-4106-9408-bcd105c90047.json'
path = os.path.join(os.path.dirname(__file__), filename)
handle = open(path, "rb")
response = json.loads(handle.read())
response = json.loads(handle.read().decode('utf-8'))
handle.close()
discid = "X2c2IQ5vUy5x6Jh7Xi_DGHtA1X8-"
@@ -214,7 +214,7 @@ class MetadataTestCase(unittest.TestCase):
filename = 'whipper.release.d8e6153a-2c47-4804-9d73-0aac1081c3b1.json'
path = os.path.join(os.path.dirname(__file__), filename)
handle = open(path, "rb")
response = json.loads(handle.read())
response = json.loads(handle.read().decode('utf-8'))
handle.close()
discid = "xu338_M8WukSRi0J.KTlDoflB8Y-" # disc 4
@@ -228,7 +228,7 @@ class MetadataTestCase(unittest.TestCase):
filename = 'whipper.release.6109ceed-7e21-490b-b5ad-3a66b4e4cfbb.json'
path = os.path.join(os.path.dirname(__file__), filename)
handle = open(path, "rb")
response = json.loads(handle.read())
response = json.loads(handle.read().decode('utf-8'))
handle.close()
discid = "cHW1Uutl_kyWNaLJsLmTGTe4rnE-"