[Tutor] Python&Pytest

Laura Creighton lac at openend.se
Fri Jun 12 22:08:55 CEST 2015


In a message of Fri, 12 Jun 2015 17:26:42 +0100, Alan Gauld writes:
>I stand corrected but it still seems to me like its easier to
>test in the language in which you develop. And most languages
>have testing frameworks these days.

Many languages have extremely poor testing frameworks.  And when it
came time to do testing of the javascript code of the web client
of our python app, we found that there wasn't anything available
for doing exactly that.

>And when there are large paradigm differences in the languages
>that's even more true. Testing JS (or even Haskell) in Python
>seems like a weird choice!

I don't see this at all.  By this logic, we would have been better
off writing a test framework in javascript to handle our javascript
code.  But our experience is that, whenever possible, you are always
better off not using javascript and programming in another language.
Plus the real challenge here was testing our code in the collection
of browsers expected to run it.  We found lots and lots and lots
of javascript bugs.

Py.test (as pytest was called at the time) was already happy to do
practically all of the heavy lifting for us.  Pick this up, throw it
at something, get a result compare the result to what you are looking
for -- all of that was handled.  So all we had to do was write the
stuff that actually went out and ran the things in the browser.

It's not a lot of code.
https://bitbucket.org/pedronis/js-infrastructure/src

Laura

>-- 
>Alan G
>Author of the Learn to Program web site
>http://www.alan-g.me.uk/


More information about the Tutor mailing list