19

I am reading Flask's tutorial about testing. There's such code there:

rv = self.app.get('/')
assert 'No entries here so far' in rv.data

My question is: why is there a variable called rv? What does this abbreviation mean?

I've been looking for it in Flask source code for a while, and I found several variables called that way:

app_rv = app(environ, start_response)

and

rv = run_wsgi_app(self.application, environ, buffered=buffered)

But, as you can see, rv here is not even possibly related to rv as response object in testing.

I've been able to find out that "r" stays probably for "response", but what does the "v" mean?

m4tx
  • 4,139
  • 5
  • 37
  • 61
  • 1
    This is the perfect example of why variable names should be descriptive. If that variable had been named descriptively, you wouldn't have had to ask the question, Jorden wouldn't have had to answer it, and umpteen other people (at least 17 other people based on your question's upvotes) would not have to go looking for the meaning of rv themselves. – mojave Dec 09 '19 at 23:27
  • @mojave, it gets worse than that. It seems in the source code of flask `rv` just means `maybe return value, or maybe I just don't know`. I'm looking at https://github.com/pallets/flask/blob/8e62bf6b17238bc09e6ad01eae64d5c2d559aad8/src/flask/config.py#L88 ... Note that `rv` is passed into `from_pyfile` which necessarily either returns `True` or raises an exception. – Nathan Chappell Jul 06 '21 at 07:33

1 Answers1

31

It says just below that code snippet in your link you provided:

By using self.app.get we can send an HTTP GET request to the application with the given path. The return value will be a response_class object.

So rv is just short for return value.

Jorden
  • 653
  • 5
  • 11