Thursday, October 29, 2009

Console colors on Windows in .NET

Changing the console output color is easy on *nix terminals with escape sequences, but has a funky API on Windows (see the color support code from Testoob for a Python example with pywin32/ctypes).

It turns out that there's a very nice .NET API for it, though (there's a nice article by Sam Allen on the Dot Net Perls site). This would be awesome for Testoob's IronPython support.

Monday, October 26, 2009

Include literal file contents in ASP.NET

I was looking for something similar to Velocity's #include for ASP.NET. <% Response.WriteFile([filename]); %> works well, but a .NET control for this could be nice. Here is my attempt (MIT license):

using System.IO;
using System.Web;
using System.Web.UI;

namespace FooControls
{
  public class LiteralContentFromFile : Control
  {
    public string Path { get; set; }

    protected override void Render(HtmlTextWriter writer)
    {
      var server = HttpContext.Current.Server;
      var physicalPath = server.MapPath(Path);
      var fileContents = File.ReadAllText(physicalPath);
      writer.Write(fileContents);
    }
  }
}

Usage in an .aspx file (WebForms or ASP.NET MVC):

<%@ Register TagPrefix="foo"
  Namespace="FooControls" Assembly="FooControls" %>
...
<foo:LiteralContentFromFile runat="server"
  Path="~/path/to/file" />

Edit: subclassing System.Web.UI.Control instead of System.Web.UI.WebControls.WebControl which added unnecessary and unwanted behavior (for example, wrapped the output with <span>).

Thursday, October 22, 2009

Issues API for Google Code Hosting

Google have recently released an issue-management API for projects hosted on Google Code.

That's good news for Testoob - I've been wanting to import its old Trac tickets for ages!

Thursday, October 8, 2009

Testoob 1.15 released

I'm very happy to announce that after nearly 3 years Testoob sees another release.

Testoob is the advanced Python test runner and testing framework that spices up any existing unittest test suite.

Changes: Version 1.15 (Oct. 2009) adds better Python 2.6, IronPython, and Jython support, as well as test coverage improvements, better color support, and some new options and bugfixes. A full list of changes is available in the release announcement.

A big shout out to Ronnie van 't Westeinde - without him this version wouldn't have been possible.

Options to install: