pydata/pandas — pull request #4451 by jtratner (2013-08-02 21:25:27+00:00)
Title: TST: pandas/util/testing : assertRaises(Regexp) contextmanager + test cleanups

A few things

1. Make with-statement-capable `assertRaises` and `assertRaisesRegexp` (which I want to use later in a cleanup of some of the parser tests).
2. Earlier introduction of `assert_attr_equal` changed it so that, if one object had an attribute that was `None` and the other did not have that attribute at all, it would pass. This is now fixed. Also added a `confirm_hasattr` kwarg which, if True, passes the test if neither object has the attribute. (for some reason the existing test code has a panel test which checks freqstr even though it doesn't exist).
3. combines `assert_panel_equal` and `assert_panel4d_equal`, because they are both doing the same thing. Now it's just `assert_panelnd_equal` with specific assert functions for each.

Specifically, it's a test in pytables that does this:

```bash
ERROR: pandas.io.tests.test_pytables:TestHDFStore.test_index_types
/usr/local/bin/vim +1770 pandas/io/tests/test_pytables.py # test_index_types
self._check_roundtrip(ser, func)
/usr/local/bin/vim +2638 pandas/io/tests/test_pytables.py # _check_roundtrip
comparator(retrieved, obj, **kwargs)
/usr/local/bin/vim +1766 pandas/io/tests/test_pytables.py #
func = lambda l, r: tm.assert_series_equal(l, r, True, True, True)
/usr/local/bin/vim +258 pandas/util/testing.py # assert_series_equal
confirm_hasattr=False)
/usr/local/bin/vim +162 pandas/util/testing.py # assert_attr_equal
left_attr = getattr(left, attr)
AttributeError: 'Index' object has no attribute 'freqstr'
```

That should probably be fixed up at some point, but it's beyond the scope of this commit. (can be fixed simply by just removing the `check_freq=True`, but I don't know whether it's necessary for other tests.