class_docstr: Tests for the Morsel object.
class_docstr_tok: ["Tests","for","the","Morsel","object","."]
code: def test_setdefault(self):
      morsel = cookies.Morsel()
      morsel.update(
          {
              "domain": "example.com",
              "version": 2,
          }
      )
      # this shouldn't override the default value
      self.assertEqual(morsel.setdefault("expires", "value"), "")
      self.assertEqual(morsel["expires"], "")
      self.assertEqual(morsel.setdefault("Version", 1), 2)
      self.assertEqual(morsel["version"], 2)
      self.assertEqual(
          morsel.setdefault("DOMAIN", "value"), "example.com"
      )
      self.assertEqual(morsel["domain"], "example.com")
  
      with self.assertRaises(cookies.CookieError):
          morsel.setdefault("invalid", "value")
      self.assertNotIn("invalid", morsel)
  
imports: import copy
  import unittest
  import doctest
  from http import cookies
  import pickle
label_desc: Use image node_id 8 for calling the MorselTests obj's underlying member method code with example usage: obj.test_setdefault() without return types