def test_invalid_octal_string_returns_default_and_warns(self): """A string with invalid octal should warn and return default.""" found = decode_perms("999", None) self.assertIsNone(found) self.assertIn("WARNING: Undecodable", self.logs.getvalue())
def test_integer(self): """A valid integer should return itself.""" found = decode_perms(0o755, None) self.assertEqual(0o755, found)
def test_valid_octal_string(self): """A string should be read as octal.""" found = decode_perms("644", None) self.assertEqual(0o644, found)
def test_none_returns_default(self): """If None is passed as perms, then default should be returned.""" default = object() found = decode_perms(None, default) self.assertEqual(default, found)