aboutsummaryrefslogtreecommitdiff
path: root/wqflask/tests/base/test_trait.py
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask/tests/base/test_trait.py')
-rw-r--r--wqflask/tests/base/test_trait.py15
1 files changed, 6 insertions, 9 deletions
diff --git a/wqflask/tests/base/test_trait.py b/wqflask/tests/base/test_trait.py
index 960f2c81..bf4e88e0 100644
--- a/wqflask/tests/base/test_trait.py
+++ b/wqflask/tests/base/test_trait.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Tests wqflask/base/trait.py"""
import unittest
-import mock
+from unittest import mock
from base.trait import GeneralTrait
from base.trait import retrieve_trait_info
@@ -38,9 +38,8 @@ class TestRetrieveTraitInfo(unittest.TestCase):
dataset={})
@mock.patch('base.trait.requests.get')
- @mock.patch('base.trait.g')
+ @mock.patch('base.trait.g', mock.Mock())
def test_retrieve_trait_info_with_empty_trait_info(self,
- g_mock,
requests_mock):
"""Empty trait info"""
requests_mock.return_value = TestNilResponse()
@@ -49,9 +48,8 @@ class TestRetrieveTraitInfo(unittest.TestCase):
dataset=mock.MagicMock())
@mock.patch('base.trait.requests.get')
- @mock.patch('base.trait.g')
+ @mock.patch('base.trait.g', mock.Mock())
def test_retrieve_trait_info_with_non_empty_trait_info(self,
- g_mock,
requests_mock):
"""Test that attributes are set"""
mock_dataset = mock.MagicMock()
@@ -66,9 +64,8 @@ class TestRetrieveTraitInfo(unittest.TestCase):
self.assertEqual(test_trait.d, 4)
@mock.patch('base.trait.requests.get')
- @mock.patch('base.trait.g')
+ @mock.patch('base.trait.g', mock.Mock())
def test_retrieve_trait_info_utf8_parsing(self,
- g_mock,
requests_mock):
"""Test that utf-8 strings are parsed correctly"""
utf_8_string = "test_string"
@@ -96,6 +93,6 @@ class TestRetrieveTraitInfo(unittest.TestCase):
test_trait = retrieve_trait_info(trait=mock_trait,
dataset=mock_dataset)
self.assertEqual(test_trait.abbreviation,
- "ファイルを画面毎に見て行くには、次のコマンドを使います。".decode('utf-8'))
+ "ファイルを画面毎に見て行くには、次のコマンドを使います。")
self.assertEqual(test_trait.authors,
- "Jane Doe かいと".decode('utf-8'))
+ "Jane Doe かいと")