Almost certainly some easy points here for someone. I've been using Python for about a week and am getting a NameError: global name '_build_response' is not defined when I attempt to call a function to build a text fixture in my unit test. Been scratching my head for a while at this, code snippet looks like:
class HttpTestCase(unittest.TestCase):
def _build_response():
#build and returns some text fixtures
def test_http_get(self):
response = _build_response()
Am I missing something in my understanding of inheritance or scoping, or is there something more embarrassing? Any pointers appreciated.
setUpand store the objects as attributes ofself. Then you don't have to call it at the top of every test. (Of course you'll still have to know why this doesn't work as soon as you run into it in other code.)