Python Programming, news on the Voidspace Python Projects and all things techie.
New IronPython Articles: Introduction to IronPython, Python for .NET Programmers, Dark Corners and Metaprogramming
I've put up three new articles in the IronPython section of this website. The first two are aimed at developers new to IronPython, particularly .NET developers. The third article should be useful to anyone using or interested in IronPython:
Just getting started with IronPython or wondering why you should be interested? This article introduces IronPython, explains how it came into existence and some of its more common use cases. The article also shows the basic IronPython and .NET integration with the interactive interpreter. The IronPython interactive interpreter is a great way to learn plus a useful tool for working with the .NET framework. The article even shows how the Dynamic Language Runtime allows languages to interoperate by using a Ruby library (through IronRuby) from IronPython.
An introduction to the Python programming language for programmers interested in IronPython. It covers the basic syntax and semantics and touches on how dynamic languages are better (oops - I mean different) to statically typed languages.
The IronPython team have done a very good job of integrating Python and the .NET framework without having to change Python or introduce new syntax. Despite this there are various areas where you need to know some IronPython specific information; previous experience of Python or C# alone will not be enough.
This article contains a lot of the nitty gritty details of how to use Python the language to integrate with the underlying .NET framework.
A fourth article of mine has also gone online, although without any action - or even knowledge - on my part. An extract from chapter 8 of IronPython in Action has been posted to Developer Zone. This is the section on metaprogramming, introducing and explaining metaclasses in Python:
New and Improved: Coming soon to unittest
I finally got it together to write a proposal for a talk at PyCon US 2010 . The proposal is on the new features that have been added to the Python unittest module in recent months. unittest is the Python standard library testing framework. It is sometimes known as PyUnit and has a rich heritage as part of the xUnit family of testing libraries.
Until sometime after Python 2.6 was released unittest was stable to the point of rigor mortis, but several developers have been working on adding much needed features and some of the most successful concepts (like test discovery) from the other major Python test frameworks. These changes will arrive in Python 2.7 and 3.2 (although a few of them made it into Python 3.1).
Putting together the list of changes since Python 2.6 for the talk made me realise just how much has changed. Here's an overview of the most important changes from the talk description:
- Brief introduction to unittest, its past and its present
- New assert methods
- assertGreater / assertLess etc
- assertIn / assertNotIn
- assertNone / assertNotNone
- assertIs / assertIsNot
- assertIsInstance / assertNotIsInstance
- Deprecated methods (failIf / failUnless variants and assertEquals)
- New type specific equality functions
- assertMultilineEqual - better string comparison
- New assertRaises behavior
- Acts as a context manager
- Keeps exception instance as context attribute
- New command line behavior
- New exit and verbosity parameters to main
- python -m unittest foo
- Test discovery (python -m unittest discover)
- The load_tests protocol
- The discover module
- Better resource handling with addCleanup
- Better messages with the longMessage class attribute
- Test skipping
- TestResult: startTestRun and stopTestRun
- The unittestbp package (back-port to Python 2.4 of the changes)
- The way forward (perhaps...)
- generational and parameterized tests
- shared fixtures
- doctest integration
- test outcomes (mentioning the vision of Robert Collins)
Of course, if you want to know more you'll have to come to the talk (assuming it gets accepted) or wait until I write it up in more detail. That second part will happen, but I wouldn't hold your breath waiting for it... In the meantime the changes are all documented so you can read about them in the development documentation for unittest.
|||Although there is currently some controversy around whether the Python conference that happens in North America every year is the US PyCon or the international PyCon.|
This work is licensed under a Creative Commons Attribution-Share Alike 2.0 License.