aboutsummaryrefslogtreecommitdiff
path: root/ihatemoney/tests
diff options
context:
space:
mode:
authorAlexis M <alexis@notmyidea.org>2019-10-07 00:07:25 +0200
committerAlexis Metaireau <alexis@notmyidea.org>2019-10-11 19:52:37 +0200
commit480939afe54fc6e8e79d6d74b8a8a3991276d460 (patch)
tree17ef49f564a1b976bd82ed488dcbcfc647336db0 /ihatemoney/tests
parent9fe84bc1a2ef088e345e6215cf2e2fa3b53fc2da (diff)
downloadihatemoney-mirror-480939afe54fc6e8e79d6d74b8a8a3991276d460.zip
ihatemoney-mirror-480939afe54fc6e8e79d6d74b8a8a3991276d460.tar.gz
ihatemoney-mirror-480939afe54fc6e8e79d6d74b8a8a3991276d460.tar.bz2
Remove support for python2.
In the same move : - use a setup.cfg file for packaging - remove the use of six
Diffstat (limited to 'ihatemoney/tests')
-rw-r--r--ihatemoney/tests/tests.py27
1 files changed, 11 insertions, 16 deletions
diff --git a/ihatemoney/tests/tests.py b/ihatemoney/tests/tests.py
index 5043977..3ff8a72 100644
--- a/ihatemoney/tests/tests.py
+++ b/ihatemoney/tests/tests.py
@@ -1,19 +1,14 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-try:
- import unittest2 as unittest
-except ImportError:
- import unittest # NOQA
-try:
- from unittest.mock import patch
-except ImportError:
- from mock import patch
+# coding: utf8
+import unittest
+from unittest.mock import patch
import datetime
import os
+import io
import json
+import base64
+
from collections import defaultdict
-import six
from time import sleep
from werkzeug.security import generate_password_hash, check_password_hash
@@ -67,7 +62,7 @@ class BaseTestCase(TestCase):
def create_project(self, name):
project = models.Project(
id=name,
- name=six.text_type(name),
+ name=str(name),
password=generate_password_hash(name),
contact_email="%s@notmyidea.org" % name)
models.db.session.add(project)
@@ -711,7 +706,7 @@ class BudgetTestCase(IhatemoneyTestCase):
# rounding issues that prevent test from working.
# However, we should obtain the same values as the theorical ones if we
# round to 2 decimals, like in the UI.
- for key, value in six.iteritems(balance):
+ for key, value in balance.items():
self.assertEqual(round(value, 2), result[key])
def test_edit_project(self):
@@ -1043,7 +1038,7 @@ class APITestCase(IhatemoneyTestCase):
def get_auth(self, username, password=None):
password = password or username
- base64string = utils.base64_encode(
+ base64string = base64.encodebytes(
('%s:%s' % (username, password)).encode('utf-8')).decode('utf-8').replace('\n', '')
return {"Authorization": "Basic %s" % base64string}
@@ -1605,14 +1600,14 @@ class CommandTestCase(BaseTestCase):
"""
cmd = GenerateConfig()
for config_file in cmd.get_options()[0].kwargs['choices']:
- with patch('sys.stdout', new=six.StringIO()) as stdout:
+ with patch('sys.stdout', new=io.StringIO()) as stdout:
cmd.run(config_file)
print(stdout.getvalue())
self.assertNotEqual(len(stdout.getvalue().strip()), 0)
def test_generate_password_hash(self):
cmd = GeneratePasswordHash()
- with patch('sys.stdout', new=six.StringIO()) as stdout, \
+ with patch('sys.stdout', new=io.StringIO()) as stdout, \
patch('getpass.getpass', new=lambda prompt: 'secret'): # NOQA
cmd.run()
print(stdout.getvalue())