You are not currently catching the exception correctly - this should instead be something like:

```
def test_scale_error():
    from astropy.table import Table
    a = ...
    ...
    with pytest.raises(UnitScaleError) as exc:
        t.write('t.fits', ...)
    assert exc.value.args[0] == "The column ..."
```