Flask Documentation (1.1.x)
the Database Blueprints and Views Templates Static Files Blog Blueprint Make the Project Installable Test Coverage Deploy to Production Keep Developing! Templates Jinja Setup Standard Context Standard Filters Processors Testing Flask Applications The Application The Testing Skeleton The First Test Logging In and Out Test Adding Messages Other Testing Tricks Faking Resources and Context Keeping the Context Object Blueprint Objects Incoming Request Data Response Objects Sessions Session Interface Test Client Test CLI Runner Application Globals Useful Functions and Classes Message Flashing JSON Support Template0 码力 | 428 页 | 895.98 KB | 1 年前3Flask Documentation (1.1.x)
url_for() properly handles that for you. For example, here we use the test_request_context() method to try out url_for(). test_request_context() tells Flask to behave as though it’s handling a request route('/user/') def profile(username): return '{}\'s profile'.format(escape(username)) with app.test_request_context(): print(url_for('index')) print(url_for('login')) print(url_for('login', next='/')) The easiest solution for unit testing is to use the test_request_context() context manager. In combination with the with statement it will bind a test request so that you can interact with it. Here is an 0 码力 | 291 页 | 1.25 MB | 1 年前3Django 2.2.x Documentation
first Django app, part 5 Introducing automated testing Basic testing strategies Writing our first test Test a view When testing, more is better Further testing What’s next? Writing your first Django app Running Django’s test suite for the first time Working on a feature Creating a branch for your patch Writing some tests for your ticket Writing the code for your ticket Running Django’s test suite for the database Give Django your database parameters Auto-generate the models Install the core Django tables Test and tweak Outputting CSV with Django Using the Python CSV library Using the template system Other0 码力 | 2915 页 | 2.83 MB | 1 年前3Django 2.1.x Documentation
first Django app, part 5 Introducing automated testing Basic testing strategies Writing our first test Test a view When testing, more is better Further testing What’s next? Writing your first Django app Running Django’s test suite for the first time Working on a feature Creating a branch for your patch Writing some tests for your ticket Writing the code for your ticket Running Django’s test suite for the database Give Django your database parameters Auto-generate the models Install the core Django tables Test and tweak Outputting CSV with Django Using the Python CSV library Using the template system Other0 码力 | 2790 页 | 2.71 MB | 1 年前3Django 2.1.x Documentation
particular, this means you should avoid using names like django (which will conflict with Django itself) or test (which conflicts with a built-in Python package). Where should this code live? If your background provided in mysite/settings.py has “create database” privileges. This allows automatic creation of a test database which will be needed in a later tutorial. If you’re using SQLite, you don’t need to create will save you time Up to a certain point, ‘checking that it seems to work’ will be a satisfactory test. In a more sophisticated application, you might have dozens of complex interactions between components0 码力 | 1910 页 | 6.49 MB | 1 年前3Django 4.0.x Documentation
first Django app, part 5 Introducing automated testing Basic testing strategies Writing our first test Test a view When testing, more is better Further testing What’s next? Writing your first Django app Running Django’s test suite for the first time Working on a feature Creating a branch for your patch Writing some tests for your ticket Writing the code for your ticket Running Django’s test suite for the database Give Django your database parameters Auto-generate the models Install the core Django tables Test and tweak How to configure and use logging Make a basic logging call Customize logging configuration0 码力 | 3184 页 | 3.14 MB | 1 年前3Django 4.2.x Documentation
first Django app, part 5 Introducing automated testing Basic testing strategies Writing our first test Test a view When testing, more is better Further testing What’s next? Writing your first Django app Running Django’s test suite for the first time Working on a feature Creating a branch for your patch Writing some tests for your ticket Writing the code for your ticket Running Django’s test suite for the database Give Django your database parameters Auto-generate the models Install the core Django tables Test and tweak How to configure and use logging Make a basic logging call Customize logging configuration0 码力 | 3305 页 | 3.16 MB | 1 年前3Django 4.1.x Documentation
first Django app, part 5 Introducing automated testing Basic testing strategies Writing our first test Test a view When testing, more is better Further testing What’s next? Writing your first Django app Running Django’s test suite for the first time Working on a feature Creating a branch for your patch Writing some tests for your ticket Writing the code for your ticket Running Django’s test suite for the database Give Django your database parameters Auto-generate the models Install the core Django tables Test and tweak How to configure and use logging Make a basic logging call Customize logging configuration0 码力 | 3240 页 | 3.13 MB | 1 年前3Django 4.0.x Documentation
particular, this means you should avoid using names like django (which will conflict with Django itself) or test (which conflicts with a built-in Python package). Where should this code live? If your background provided in mysite/settings.py has “create database” privileges. This allows automatic creation of a test database which will be needed in a later tutorial. If you’re using SQLite, you don’t need to create will save you time Up to a certain point, ‘checking that it seems to work’ will be a satisfactory test. In a more sophisticated application, you might have dozens of complex interactions between components0 码力 | 2248 页 | 7.90 MB | 1 年前3Django 2.0.x Documentation
first Django app, part 5 Introducing automated testing Basic testing strategies Writing our first test Test a view When testing, more is better Further testing What’s next? Writing your first Django app Django Running Django’s test suite for the first time Creating a branch for your patch Writing some tests for your ticket Writing the code for your ticket Running Django’s test suite for the second time database Give Django your database parameters Auto-generate the models Install the core Django tables Test and tweak Outputting CSV with Django Using the Python CSV library Using the template system Other0 码力 | 2746 页 | 2.67 MB | 1 年前3
共 439 条
- 1
- 2
- 3
- 4
- 5
- 6
- 44