-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#3309|GTK] Fix cmp function for None types
Comparisons on Python 3 are much stricter resulting in the following error comparing with None: TypeError: '>' not supported between instances of 'NoneType' and 'str' Fix this by getting the type of the other value and getting it's default value.
- Loading branch information
Showing
2 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with | ||
# the additional special exception to link portions of this program with the OpenSSL library. | ||
# See LICENSE for more details. | ||
# | ||
|
||
from __future__ import unicode_literals | ||
|
||
import sys | ||
|
||
import mock | ||
import pytest | ||
from twisted.trial import unittest | ||
|
||
|
||
@pytest.mark.gtkui | ||
class GTK3CommonTestCase(unittest.TestCase): | ||
def setUp(self): | ||
sys.modules['gi.repository'] = mock.MagicMock() | ||
|
||
def tearDown(self): | ||
pass | ||
|
||
def test_cmp(self): | ||
from deluge.ui.gtk3.common import cmp | ||
|
||
self.assertEqual(cmp(None, None), 0) | ||
self.assertEqual(cmp(1, None), 1) | ||
self.assertEqual(cmp(0, None), 1) | ||
self.assertEqual(cmp(None, 7), -1) | ||
self.assertEqual(cmp(None, 'bar'), -1) | ||
self.assertEqual(cmp('foo', None), 1) | ||
self.assertEqual(cmp('', None), 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters