def test_deprecated_missing_args(self):
    date = "2016-07-04"
    instructions = "This is how you update..."

    def _fn(arg0, arg1, deprecated=None):
      return arg0 + arg1 if deprecated else arg1 + arg0

    # Assert calls without the deprecated argument log nothing.
    with self.assertRaisesRegexp(ValueError, "not present.*\\['missing'\\]"):
      deprecation.deprecated_args(date, instructions, "missing")(_fn)
  def test_deprecated_missing_args(self, mock_warning):
    date = "2016-07-04"
    instructions = "This is how you update..."

    def _fn(arg0, arg1, deprecated=None):
      return arg0 + arg1 if deprecated else arg1 + arg0

    # Assert calls without the deprecated argument log nothing.
    with self.assertRaisesRegexp(ValueError, "not present.*\\['missing'\\]"):
      deprecation.deprecated_args(date, instructions, "missing")(_fn)
 def test_deprecated_illegal_args(self):
   instructions = "This is how you update..."
   date = "2016-07-04"
   with self.assertRaisesRegexp(ValueError, "date"):
     deprecation.deprecated_args(None, instructions, "deprecated")
   with self.assertRaisesRegexp(ValueError, "date"):
     deprecation.deprecated_args("", instructions, "deprecated")
   with self.assertRaisesRegexp(ValueError, "YYYY-MM-DD"):
     deprecation.deprecated_args("07-04-2016", instructions, "deprecated")
   with self.assertRaisesRegexp(ValueError, "instructions"):
     deprecation.deprecated_args(date, None, "deprecated")
   with self.assertRaisesRegexp(ValueError, "instructions"):
     deprecation.deprecated_args(date, "", "deprecated")
   with self.assertRaisesRegexp(ValueError, "argument"):
     deprecation.deprecated_args(date, instructions)
 def test_deprecated_illegal_args(self):
   instructions = "This is how you update..."
   date = "2016-07-04"
   with self.assertRaisesRegexp(ValueError, "date"):
     deprecation.deprecated_args(None, instructions, "deprecated")
   with self.assertRaisesRegexp(ValueError, "date"):
     deprecation.deprecated_args("", instructions, "deprecated")
   with self.assertRaisesRegexp(ValueError, "YYYY-MM-DD"):
     deprecation.deprecated_args("07-04-2016", instructions, "deprecated")
   with self.assertRaisesRegexp(ValueError, "instructions"):
     deprecation.deprecated_args(date, None, "deprecated")
   with self.assertRaisesRegexp(ValueError, "instructions"):
     deprecation.deprecated_args(date, "", "deprecated")
   with self.assertRaisesRegexp(ValueError, "argument"):
     deprecation.deprecated_args(date, instructions)