Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
only uppercase HTTP methods are allowed. (fix for bug@#176415)
- Loading branch information
1 parent
77a888e
commit ca35d12
Showing
4 changed files
with
68 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import webtest | ||
import time | ||
|
||
import web | ||
|
||
data = """ | ||
import web | ||
urls = ("/", "%(classname)s") | ||
app = web.application(urls, globals(), autoreload=True) | ||
class %(classname)s: | ||
def GET(self): | ||
return "%(output)s" | ||
""" | ||
|
||
def write(filename, data): | ||
f = open(filename, 'w') | ||
f.write(data) | ||
f.close() | ||
|
||
class ApplicationTest(webtest.TestCase): | ||
def test_reloader(self): | ||
write('foo.py', data % dict(classname='a', output='a')) | ||
import foo | ||
app = foo.app | ||
|
||
self.assertEquals(app.request('/').data, 'a') | ||
|
||
# test class change | ||
time.sleep(1) | ||
write('foo.py', data % dict(classname='a', output='b')) | ||
self.assertEquals(app.request('/').data, 'b') | ||
|
||
# test urls change | ||
time.sleep(1) | ||
write('foo.py', data % dict(classname='c', output='c')) | ||
self.assertEquals(app.request('/').data, 'c') | ||
|
||
def testUppercaseMethods(self): | ||
urls = ("/", "hello") | ||
app = web.application(urls, locals()) | ||
class hello: | ||
def GET(self): return "hello" | ||
def internal(self): return "secret" | ||
|
||
response = app.request('/', method='internal') | ||
self.assertEquals(response.status, '405 Method Not Allowed') | ||
|
||
if __name__ == '__main__': | ||
webtest.main() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters