Ticket #2510: 0001-Added-test-case-for-overwriting-null-config-values.patch

File 0001-Added-test-case-for-overwriting-null-config-values.patch, 1.4 KB (added by awknaust, 10 years ago)
  • deluge/tests/test_config.py

    From d4a77454e73ed472a5a892e203fc671ba6cd6598 Mon Sep 17 00:00:00 2001
    From: Alex Knaust <awknaust@gmail.com>
    Date: Sat, 27 Sep 2014 18:13:01 -0600
    Subject: [PATCH] Added test case for overwriting null config values
    
    ---
     deluge/tests/test_config.py | 20 ++++++++++++++++++++
     1 file changed, 20 insertions(+)
    
    diff --git a/deluge/tests/test_config.py b/deluge/tests/test_config.py
    index 5fa4d15..587bd4c 100644
    a b def test_set_get_item(self):  
    4343        self.assertTrue(isinstance(config.get_item("unicode"), unicode))
    4444
    4545        config._save_timer.cancel()
     46   
     47    def test_set_get_overwrite_null(self):
     48        config = Config("test.conf", config_dir=self.config_dir)
     49       
     50        #We should be able to overwrite a null config value with a real one
     51        config["foo"] = None
     52        self.assertIsNone(config["foo"])
     53        self.assertIsInstance(config["foo"], type(None))
     54
     55        config["foo"] = 1
     56        self.assertEquals(config.get("foo"), 1)
     57        self.assertIsInstance(config.get("foo"), type(1))
     58
     59        #Should also be possible
     60        config["bar"] = None
     61        self.assertIsNone(config["bar"])
     62        config["bar"] = None
     63        self.assertIsNone(config["bar"])
     64
     65        config._save_timer.cancel()
    4666
    4767    def test_get(self):
    4868        config = Config("test.conf", config_dir=self.config_dir)