def test_object_beta_warning(self, mock_warning): class Multiplier: def multiply(self, a, b): return a * b beta_multiplier = object_beta_warning(Multiplier(), "multiplier", "1980-01-01") expected_warning = ( "Please replace `st.beta_multiplier` with `st.multiplier`.\n\n" "`st.beta_multiplier` will be removed after 1980-01-01." ) self.assertEqual(beta_multiplier.multiply(3, 2), 6) self.assertEqual(beta_multiplier.multiply(5, 4), 20) # We only show the warning a single time for a given object. mock_warning.assert_called_once_with(expected_warning)
def test_object_beta_warning(self, mock_warning): class Multiplier: def multiply(self, a, b): return a * b beta_multiplier = object_beta_warning(Multiplier(), "multiplier", "1980-01-01") expected_warning = ( "`st.multiplier` has graduated out of beta. On 1980-01-01, the beta_ version will be removed." "\n\nBefore then, update your code from `st.beta_multiplier` to `st.multiplier`." ) self.assertEqual(beta_multiplier.multiply(3, 2), 6) self.assertEqual(beta_multiplier.multiply(5, 4), 20) # We only show the warning a single time for a given object. mock_warning.assert_called_once_with(expected_warning)
def test_object_beta_warning_magic_function(self, mock_warning): """Test that we override dunder methods.""" class DictClass(dict): pass beta_dict = object_beta_warning(DictClass(), "my_dict", "1980-01-01") expected_warning = ( "`st.my_dict` has graduated out of beta. On 1980-01-01, the beta_ version will be removed." "\n\nBefore then, update your code from `st.beta_my_dict` to `st.my_dict`." ) beta_dict["foo"] = "bar" self.assertEqual(beta_dict["foo"], "bar") self.assertEqual(len(beta_dict), 1) self.assertEqual(list(beta_dict), ["foo"]) # We only show the warning a single time for a given object. mock_warning.assert_called_once_with(expected_warning)
def test_object_beta_warning_magic_function(self, mock_warning): """Test that we override dunder methods.""" class DictClass(dict): pass beta_dict = object_beta_warning(DictClass(), "my_dict", "1980-01-01") expected_warning = ( "Please replace `st.beta_my_dict` with `st.my_dict`.\n\n" "`st.beta_my_dict` will be removed after 1980-01-01." ) beta_dict["foo"] = "bar" self.assertEqual(beta_dict["foo"], "bar") self.assertEqual(len(beta_dict), 1) self.assertEqual(list(beta_dict), ["foo"]) # We only show the warning a single time for a given object. mock_warning.assert_called_once_with(expected_warning)
video = _main.video warning = _main.warning write = _main.write color_picker = _main.color_picker # Config get_option = _config.get_option from streamlit.commands.page_config import set_page_config # Beta APIs beta_container = _main.beta_container beta_expander = _main.beta_expander beta_columns = _main.beta_columns beta_secrets = object_beta_warning(secrets, "secrets", "2021-06-30") def set_option(key, value): """Set config option. Currently, only the following config options can be set within the script itself: * client.caching * client.displayEnabled * deprecation.* Calling with any other options will raise StreamlitAPIException. Run `streamlit config show` in the terminal to see all available options. Parameters