From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sean McAfee Newsgroups: gmane.emacs.help Subject: ERT: should-error doesn't catch failed assertions Date: Sun, 17 Jul 2016 15:24:21 -0700 Organization: A noiseless patient Spider Message-ID: <87d1mb9a3u.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1468794332 7834 80.91.229.3 (17 Jul 2016 22:25:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 17 Jul 2016 22:25:32 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jul 18 00:25:32 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bOuV9-0000pA-5b for geh-help-gnu-emacs@m.gmane.org; Mon, 18 Jul 2016 00:25:31 +0200 Original-Received: from localhost ([::1]:43265 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bOuV8-0003I7-3Z for geh-help-gnu-emacs@m.gmane.org; Sun, 17 Jul 2016 18:25:30 -0400 Original-Path: usenet.stanford.edu!news.glorb.com!2.us.feeder.erje.net!feeder.erje.net!1.eu.feeder.erje.net!feeder2.usenet.farm!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 18 Injection-Info: mx02.eternal-september.org; posting-host="bcb44ed1b062cc9c0e7688e840c91257"; logging-data="27788"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18U7cfhV63/idTXU6A/4YshfhaUrOOx7eg=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) Cancel-Lock: sha1:7NqbN2dSUhaUkEadDajmWHLH/Z8= sha1:+SQngTt0u3OhUfX7rLXwdlkAFmY= Original-Xref: usenet.stanford.edu gnu.emacs.help:218564 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:110875 Archived-At: I've just begin trying to use ERT to write unit tests for my code. I got hung up almost immediately when trying to confirm that a particular function call fails an assertion. A simple example: (should-error (cl-assert nil)) The assertion failure escapes the should-error form and causes a stack trace. Is there a way to catch assertion failures like this? The code I'm testing implements a checksum of sorts that can only work with strings of length exactly 5, ie: (def my-checksum (str) (cl-assert (= 5 (length str))) ; ... )