`WebTest` argument `relative_to` shall assume current directory
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 346
- Forks
- 113
- PR merge metrics
- No merged PRs in 30d
Description
WebTest works well with WSGI applications as well as urls provided via environment variable WEBTEST_TARGET_URL.
WebTest.__init__ provides argument relative_to with default value None.
Typical creation of TestApp instance is:
from webtest import TestApp
# somehow create `app`, can be WSGI application or url to use
...
testapp = TestApp(app)
There are multiple options for providing argument app:
- instance of WSGI application
- url of web application to use via WsgiProxy2
- reference to Paste config section, e.g.
config:local.ini#testorconfig:local.ini(value being the same as when used aspservecommand line argument.
Failures when using reference to config file
When using the reference to config file (either as direct value or indirectly via environment variable WEBTEST_TARGET_URL), the instantiation fails at http://webtest.pythonpaste.org/en/latest/api.html#webtest.app.TestApp as the relative_to is None.
Quick fix is to
testapp = TestApp(app, relative_to=".")
which in most cases works as expected, however it seems inconsistent with all other calls as one has to provide extra argument just in case, someone would be willing to define app via a reference to config file.
Proposed resolution
Keep default value of relative_to as None, but if to be used (before the call to loadapp, check if it is None and if so, set it to ".".
Existing line:
app = loadapp(app, relative_to=relative_to)
could change to:
app = loadapp(app, relative_to=relative_to or ".")
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at WebTest.init and the shown loadapp(app, relative_to=relative_to) call. Check how config references are loaded when relative_to is None, then verify that TestApp(app) works for config references while explicit relative_to values continue to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100