title: Testing (unittest) if a variable is a nonempty string in python the right way?
body: <p>Maybe this question is trivial, but I am still trying to warm up with unittests in python, so please have patience with me. :-) While trying to write some tests of my own, the following question araised. Assuming a function that processes nonempty strings:</p>
  
  <pre><code>class BadInputError(Exception): pass
  
  class FooBar(object):
      def take_a_string_and_do_something(param):
          if param == '':
              raise BadInputError('param should not be an empty string')
          if param is None:
              raise BadInputError('param should not be None')
          if not isinstance(param, basestring):
              raise BadInputError('param must be of type string)
          # process nonempty string
  </code></pre>
  
  <p>The first thing I wanted to make sure (by unittests) is that <code>param</code> is only a <em>nonempty</em> string. So I wrote my testcases this way.</p>
  
  <pre><code>class TestFooBar(unittest.TestCase):
      def test_take_a_string_and_do_something(self):
          foo = FooBar()
          self.failUnlessRaises(BadInputError, foo.take_a_string_and_do_something, '')
          self.failUnlessRaises(BadInputError, foo.take_a_string_and_do_something, None)
          self.failUnlessRaises(BadInputError, foo.take_a_string_and_do_something, 234)
  </code></pre>
  
  <p>Is this acceptable or am I making heavy rookie mistake? Your feedback means a lot!</p>