From 0fb7cb93314b95f615b641b8ddb076e3223fa59e Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Wed, 1 May 2019 16:11:21 -0700 Subject: [PATCH] kvstore: Convert tests to pytest style Signed-off-by: Sunil Mohan Adapa Reviewed-by: Joseph Nuthalapati --- plinth/tests/test_kvstore.py | 48 +++++++++++++++++------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/plinth/tests/test_kvstore.py b/plinth/tests/test_kvstore.py index dab38a4be..4f1792a89 100644 --- a/plinth/tests/test_kvstore.py +++ b/plinth/tests/test_kvstore.py @@ -21,34 +21,32 @@ Test module for key/value store. import pytest -from django.test import TestCase - from plinth import kvstore +pytestmark = pytest.mark.django_db -@pytest.mark.django_db -class KVStoreTestCase(TestCase): - """Verify the behavior of the kvstore module.""" - def test_get_set(self): - """Verify that a set value can be retrieved.""" - key = 'name' - expected_value = 'Guido' - kvstore.set(key, expected_value) - actual_value = kvstore.get(key) - self.assertEqual(expected_value, actual_value) +def test_get_set(): + """Verify that a set value can be retrieved.""" + key = 'name' + expected_value = 'Guido' + kvstore.set(key, expected_value) + actual_value = kvstore.get(key) + assert expected_value == actual_value - def test_get_set_complex_structures(self): - """Verify that complex structures can be stored and retrieved.""" - key = 'compex_structure' - expected_value = {'k1': 1, 'k2': [2, 3], 'k3': 4.5, 'k4': 'Hello', - 'k5': {'a': 'b'}} - kvstore.set(key, expected_value) - actual_value = kvstore.get(key) - self.assertEqual(expected_value, actual_value) - def test_get_default(self): - """Verify that either a set value or its default can be retrieved.""" - expected = 'default' - actual = kvstore.get_default('bad_key', expected) - self.assertEqual(expected, actual) +def test_get_set_complex_structures(): + """Verify that complex structures can be stored and retrieved.""" + key = 'compex_structure' + expected_value = {'k1': 1, 'k2': [2, 3], 'k3': 4.5, 'k4': 'Hello', + 'k5': {'a': 'b'}} + kvstore.set(key, expected_value) + actual_value = kvstore.get(key) + assert expected_value == actual_value + + +def test_get_default(): + """Verify that either a set value or its default can be retrieved.""" + expected = 'default' + actual = kvstore.get_default('bad_key', expected) + assert expected == actual