Skip to content

Instantly share code, notes, and snippets.

@dhilst
Created June 2, 2017 21:52
Show Gist options
  • Select an option

  • Save dhilst/6e4e76824467d21f12b74f1bd53dbf35 to your computer and use it in GitHub Desktop.

Select an option

Save dhilst/6e4e76824467d21f12b74f1bd53dbf35 to your computer and use it in GitHub Desktop.
Validate PR for flask-restful
import sys
sys.path.append('./flask-restful')
from flask import Flask
from flask_restful import Api,Resource, reqparse
app = Flask(__name__)
api = Api(app)
class Foo(Resource):
def post(self):
parser = reqparse.RequestParser()
parser.add_argument('foo')
parser.add_argument('bar', location='file')
args = parser.parse_args()
return {'foo': 'bar'}
api.add_resource(Foo, '/')
if __name__ == '__main__':
import unittest
class FooTest(unittest.TestCase):
def setUp(self):
self.app = app.test_client()
def test_foo(self):
self.app.post('/', data={'foo': 123})
unittest.main(verbosity=2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment