Order of arguments to assertEqual: is Pythoscope consistent with the convention in Python?

311 views
Skip to first unread message

FM

unread,
Jan 14, 2011, 10:25:25 AM1/14/11
to Pythoscope
I don't know whether Python has a consistent convention on this
subject. The documentation for Python's unittest does not make a
strong statement, referring to the two arguments simply as `first` and
`second`. However, all of the examples for assertEqual are framed in
this order:

assertEqual(ACTUAL, EXPECTED, MESSAGE)

In addition, the documentation for assertItemsEqual and
assertDictEqual explicitly uses that ordering.

Based on some quick Googling, I observed the following camps regarding
this issue:

Actual first:

Python unittest
Perl Test::More

Expected first:

Java
C#
Ruby
Pythoscope's generated test methods

I don't have a preference. I simply want to follow a standard that
works well with most tools in Python. Thanks.

Michał Kwiatkowski

unread,
Jan 14, 2011, 10:31:27 AM1/14/11
to pytho...@googlegroups.com
Hi!

I like assert(expected, actual) because usually expected is a value
(thus short), while actual is a call (longer). Putting expected value
first makes the assertion a bit more readable for me.

Cheers,
mk

> --
> You received this message because you are subscribed to the Google Groups "Pythoscope" group.
> To post to this group, send email to pytho...@googlegroups.com.
> To unsubscribe from this group, send email to pythoscope+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/pythoscope?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages