From b60dce5612d4dc32491787c7229552225560d183 Mon Sep 17 00:00:00 2001 From: Mathieu Comandon Date: Fri, 13 Nov 2015 00:34:11 -0800 Subject: [PATCH] Fix some unittests --- lutris/config.py | 2 +- lutris/util/strings.py | 4 ++-- tests/test_pga.py | 2 +- tests/test_runners.py | 2 +- tests/test_utils.py | 21 +++++++++++---------- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/lutris/config.py b/lutris/config.py index 29f715bac..1ce2021b7 100644 --- a/lutris/config.py +++ b/lutris/config.py @@ -273,7 +273,7 @@ class LutrisConfig(object): """Return a dict of options' default value.""" options_dict = self.options_as_dict(options_type) defaults = {} - for option, params in options_dict.iteritems(): + for option, params in options_dict.items(): if 'default' in params: defaults[option] = params['default'] return defaults diff --git a/lutris/util/strings.py b/lutris/util/strings.py index 578a548c2..044f9879d 100644 --- a/lutris/util/strings.py +++ b/lutris/util/strings.py @@ -8,9 +8,9 @@ def slugify(value): Normalizes string, converts to lowercase, removes non-alpha characters, and converts spaces to hyphens. """ - value = value.decode('UTF-8') + value = str(value) value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore') - value = unicode(re.sub('[^\w\s-]', '', value).strip().lower()) + value = str(re.sub('[^\w\s-]', '', value)).strip().lower() return re.sub('[-\s]+', '-', value) diff --git a/tests/test_pga.py b/tests/test_pga.py index b298cc5eb..228c43c23 100644 --- a/tests/test_pga.py +++ b/tests/test_pga.py @@ -53,7 +53,7 @@ class TestPersonnalGameArchive(DatabaseTester): pga.add_game(name="installed_game", runner="Linux", installed=1) pga.add_game(name="bang", runner="Linux", installed=0) game_list = pga.get_games(filter_installed=True) - print game_list + print(game_list) self.assertEqual(len(game_list), 1) self.assertEqual(game_list[0]['name'], 'installed_game') diff --git a/tests/test_runners.py b/tests/test_runners.py index a66a13803..a83a727e0 100644 --- a/tests/test_runners.py +++ b/tests/test_runners.py @@ -1,5 +1,5 @@ import logging -from mock import patch +from unittest.mock import patch from lutris.config import LutrisConfig from lutris import runners diff --git a/tests/test_utils.py b/tests/test_utils.py index 55138b473..b63d423bf 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,3 +1,4 @@ +from collections import OrderedDict from unittest import TestCase from lutris.util import system from lutris.util import steam @@ -34,16 +35,16 @@ class TestFileUtils(TestCase): class TestSteamUtils(TestCase): def test_dict_to_vdf(self): - dict_data = { - 'AppState': { - 'appID': '13240', - 'StateFlags': '4', - 'UserConfig': { - "name": "Unreal Tournament", - "gameid": "13240" - } - } - } + appstate = OrderedDict() + userconfig = OrderedDict() + userconfig['gameid'] = "13240" + userconfig['name'] = "Unreal Tournament" + appstate['UserConfig'] = userconfig + appstate['StateFlags'] = '4' + appstate['appID'] = '13240' + dict_data = OrderedDict() + dict_data['AppState'] = appstate + expected_vdf = """"AppState" { \t"UserConfig"