pylint or similar to test version-specific language constructs?

jkn jkn_gg at nicorp.f9.co.uk
Sun Jan 13 18:56:38 CET 2013


Hi Dave

On 11 Jan, 15:06, Dave Angel <d... at davea.name> wrote:
>
> Not sure what you mean by beforehand.  Don't you run all your unit tests
> before putting each revision of your code into production?  So run those
> tests twice, once on 2.7, and once on 2.4.  A unit test that's testing
> code with a ternary operator will fail, without any need for a separate
> test.
>
> if it doesn't, then you've got some coverage gaps in your unit tests.

By 'beforehand' I meant 'before testing on my target 2.4 system;
perhaps I should have been clearer in that I am running 2.7 on my
'development' platform, and 2.4 on my target. It would be painful to
put 2.4 on my target system (although I continue to wonder about
that...). So I was looking to catch such errors before migrating to
the target.

[Steven D'Aprano]
> Decorators work fine in Python 2.4.

Yes, I was just coming up with another example of a language construct
which didn't exist at one point.

> You don't even need tests for the code that includes the ternary
> operator. The module simply won't compile in Python 2.4, you get a
> SyntaxError when you try to import it or run it.

In fact I had a misapprehension about this; for some reason (I thought
I'd tried it) I thought such an error only got caught at runtime, not
'compile-time'. I now see that this is not the case, which means the
athe problem is less of a concern than I thought.

Thanks for the comments.

    Jon N



More information about the Python-list mailing list