December 2018
Intermediate to advanced
374 pages
11h 39m
English
With this, we know how to write a simple benchmark. So, how about writing something similar for our API? Let's take a look at how we can modify one of our API tests that we used to validate the functioning of our index API endpoint and see how we can run a benchmark on that.
The following code modifies our existing index API test case to include a benchmark test for the API:
'''File: test_index_benchmark.pyDescription: Benchmark the index API endpoint'''import osimport pytestimport sysimport tempfilesys.path.append('.')import bugzot@pytest.fixture(scope='module')def test_client(): db, bugzot.app.config['DATABASE'] = tempfile.mkstemp() bugzot.app.config['TESTING'] = True test_client = bugzot.app.test_client() with ...Read now
Unlock full access