def test_deprecate_option(self):
        # we can deprecate non-existent options
        self.cf.deprecate_option('foo')

        self.assertTrue(self.cf._is_deprecated('foo'))
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter('always')
            try:
                self.cf.get_option('foo')
            except __HOLE__:
                pass
            else:
                self.fail("Nonexistent option didn't raise KeyError")

            self.assertEqual(len(w), 1)  # should have raised one warning
            self.assertTrue(
                'deprecated' in str(w[-1]))  # we get the default message

        self.cf.register_option('a', 1, 'doc', validator=self.cf.is_int)
        self.cf.register_option('b.c', 'hullo', 'doc2')
        self.cf.register_option('foo', 'hullo', 'doc2')

        self.cf.deprecate_option('a', removal_ver='nifty_ver')
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter('always')
            self.cf.get_option('a')

            self.assertEqual(len(w), 1)  # should have raised one warning
            self.assertTrue(
                'eprecated' in str(w[-1]))  # we get the default message
            self.assertTrue(
                'nifty_ver' in str(w[-1]))  # with the removal_ver quoted

            self.assertRaises(
                KeyError, self.cf.deprecate_option, 'a')  # can't depr. twice

        self.cf.deprecate_option('b.c', 'zounds!')
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter('always')
            self.cf.get_option('b.c')

            self.assertEqual(len(w), 1)  # should have raised one warning
            self.assertTrue(
                'zounds!' in str(w[-1]))  # we get the custom message

        # test rerouting keys
        self.cf.register_option('d.a', 'foo', 'doc2')
        self.cf.register_option('d.dep', 'bar', 'doc2')
        self.assertEqual(self.cf.get_option('d.a'), 'foo')
        self.assertEqual(self.cf.get_option('d.dep'), 'bar')

        self.cf.deprecate_option('d.dep', rkey='d.a')  # reroute d.dep to d.a
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter('always')
            self.assertEqual(self.cf.get_option('d.dep'), 'foo')

            self.assertEqual(len(w), 1)  # should have raised one warning
            self.assertTrue(
                'eprecated' in str(w[-1]))  # we get the custom message

        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter('always')
            self.cf.set_option('d.dep', 'baz')  # should overwrite "d.a"

            self.assertEqual(len(w), 1)  # should have raised one warning
            self.assertTrue(
                'eprecated' in str(w[-1]))  # we get the custom message

        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter('always')
            self.assertEqual(self.cf.get_option('d.dep'), 'baz')

            self.assertEqual(len(w), 1)  # should have raised one warning
            self.assertTrue(
                'eprecated' in str(w[-1]))  # we get the custom message
dataset/ETHPy150Open pydata/pandas/pandas/tests/test_config.py/TestConfig.test_deprecate_option