def dictionary_should_not_contain_path(dictionary, path): try: xpathget(dictionary, path, separator='.') except KeyError: return raise RuntimeError("Dictionary contains path '%s'." % path)