
import warnings

from unittest import TestCase

from ipywidgets import Dropdown


class TestDropdown(TestCase):

    def test_construction(self):
        Dropdown()

    def test_deprecation_warning_mapping_options(self):
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("module")
            Dropdown(options={'One': 1, 'Two': 2, 'Three': 3})
            assert len(w) == 1
            assert issubclass(w[-1].category, DeprecationWarning)
            assert "deprecated" in str(w[-1].message)




import warnings

from unittest import TestCase

from ipywidgets import Dropdown


class TestDropdown(TestCase):

    def test_construction(self):
        Dropdown()

    def test_deprecation_warning_mapping_options(self):
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            Dropdown(options={'One': 1, 'Two': 2, 'Three': 3})
            assert len(w) > 0
            assert issubclass(w[-1].category, DeprecationWarning)
            assert "Support for mapping types has been deprecated" in str(w[-1].message)



Use simplefilter('always') for testing the warning
Use simplefilter('always') for testing the warning

* Use `warnings.simplefilter('always')` for DeprecationWarning
* More specific test on warning message

  
  import warnings
  
  from unittest import TestCase
  
  from ipywidgets import Dropdown
  
  
  class TestDropdown(TestCase):
  
      def test_construction(self):
          Dropdown()
  
      def test_deprecation_warning_mapping_options(self):
          with warnings.catch_warnings(record=True) as w:
-             warnings.simplefilter("module")
+             warnings.simplefilter("always")
              Dropdown(options={'One': 1, 'Two': 2, 'Three': 3})
-             assert len(w) == 1
+             assert len(w) > 0
              assert issubclass(w[-1].category, DeprecationWarning)
-             assert "deprecated" in str(w[-1].message)
+             assert "Support for mapping types has been deprecated" in str(w[-1].message)
  
  
  
Use simplefilter('always') for testing the warning
## Code Before:

import warnings

from unittest import TestCase

from ipywidgets import Dropdown


class TestDropdown(TestCase):

    def test_construction(self):
        Dropdown()

    def test_deprecation_warning_mapping_options(self):
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("module")
            Dropdown(options={'One': 1, 'Two': 2, 'Three': 3})
            assert len(w) == 1
            assert issubclass(w[-1].category, DeprecationWarning)
            assert "deprecated" in str(w[-1].message)



## Instruction:
Use simplefilter('always') for testing the warning
## Code After:

import warnings

from unittest import TestCase

from ipywidgets import Dropdown


class TestDropdown(TestCase):

    def test_construction(self):
        Dropdown()

    def test_deprecation_warning_mapping_options(self):
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            Dropdown(options={'One': 1, 'Two': 2, 'Three': 3})
            assert len(w) > 0
            assert issubclass(w[-1].category, DeprecationWarning)
            assert "Support for mapping types has been deprecated" in str(w[-1].message)


