Wednesday, March 25, 2009

Anniversary

I have now officially been a CPython developer for 1 year. At first it doesn't seem like that long ago, but then I remember all the things I've done over the past year. I had a few imfamous screw-ups in the beginning, but now apparently I'm trusted enough to be the 2.7/3.1 release manager. I'd like to thank all the wonderful people I've met so far (and will soon see in person) including Georg Brandl, Brett Cannon, and Guido himself.

Tuesday, March 24, 2009

unittest - now with test skipping (finally)

Yesterday, I was happy to commit a patch which added test skipping and expected failure support to the venerable unittest module. It adds a skip() method to TestCase, which marks the current test being run as skipped, as well as a set of useful decorators. Here's a short example:

import sys
import unittest

class SkippingExample(unittest.TestCase):

@unittest.skip("testing skipping")
def test_skip_me(self):
self.fail("shouldn't happen")

def test_normal(self):
self.assertEqual(1, 1)

@unittest.skipIf(sys.version_info < (2, 6),
"not supported in this veresion")
def test_show_skip_if(self):
# testing some things here
pass

@unittest.expectedFailure
def test_expected_failure(self):
self.fail("this should happen unfortunately")


# Yes, you can skip whole classes, too!
@unittest.skip("classing skipping")
class CompletelySkippedTest(unittest.TestCase):

def test_not_run_at_all(self):
self.fail("shouldn't happen")


if __name__ == "__main__":
unittest.main()


Running it in verbose mode gives:


__main__.CompletelySkippedTest ... skipped 'classing skipping'
test_expected_failure (__main__.SkippingExample) ... expected failure
test_normal (__main__.SkippingExample) ... ok
test_show_skip_if (__main__.SkippingExample) ... ok
test_skip_me (__main__.SkippingExample) ... skipped 'testing skipping'

----------------------------------------------------------------------
Ran 5 tests in 0.010s

OK (skipped=2, expected failures=1)


I have high hopes for this and Python's regression tests. Hopefully it will simplify the ugly system of test skipping we have now. It should also help us pacify other implementations who want CPython implementation detail tests skipped.

Sunday, March 22, 2009

What awesome feature would you like 2to3 to have?

I'm asking because it's that time of year again where Google pays college students to work on opensource projects. Since Python 3.x is such an important issue in the Python community, the PSF organizers have decided emphasize projects related to 2to3. So far, I've been asked by a few interested students for ideas, and I didn't have many, so I thought I'd ask the users of 2to3. What killer features do you want to see in 2to3?

Saturday, March 7, 2009

First alpha of Python 3.1 released

Today, I released the first alpha of the next version of Python 3000, Python 3.1. Most people will be excited about the rewrite of the io module in C for speed, but 3.1 also includes some neat features. The collections module acquired both an ordered dictionary and a multiset.

You can download it on python.org. Please test the new version with your applications and libraries and report bugs to bugs.python.org.