Issue 1:
Expected Behavior

I was trying to write unit tests for my flask restful api which uses BasicHttpAuth on the initial request and returns a JWT token. All subsequent requests have this token in an x-access-header up to an expiry of 15 mins, then re-authentication happens( the code for this is in the anacropapi repo on my profile under api.init.py). I have noted the error in the template. I thought this test client would be fully compatible with the requests package. Does anyone know of a work around for this or can an auth keyword arg be added ?

import unittest

class ApiTest(unittest.TestCase):

def setUp(self):
# creates a test client
self.app = app.test_client()
# add a user into the account code goes here ...

def tearDown(self):
db.drop_all()
# etc...

def test_login(self):
# sends HTTP GET request to the application
# on the specified path with an auth kwarg passed like in requests
result = self.app.get('/login', auth=requests.auth.BasicHttpAuth(username, password))

Actual Behavior

this returns no auth arg found error i cant remember the specfic error off hand

Environment

Python version: 3.6

Flask version: latest

Werkzeug version: latest

Issue 2:
Expected Behavior

According to https://flask.palletsprojects.com/en/master/testing/#the-first-test, test should pass

import os
import tempfile

import pytest

from flaskr import create_app

@pytest.fixture
def client():
db_fd, flaskr.app.config['DATABASE'] = tempfile.mkstemp()
flaskr.app.config['TESTING'] = True

with flaskr.app.test_client() as client:
with flaskr.app.app_context():
flaskr.init_db()
yield client

os.close(db_fd)
os.unlink(flaskr.app.config['DATABASE'])

def test_empty_db(client):
"""Start with a blank database."""

rv = client.get('/')
assert b'No entries here so far' in rv.data

Actual Behavior

The test fail

(test2) florian@POC-Docker-1:~/test_testing_flask/flask/examples/tutorial$ pytest -v
========================================================================================================== test session starts ==========================================================================================================
platform linux -- Python 3.6.9, pytest-6.0.1, py-1.9.0, pluggy-0.13.1 -- /home/florian/.pyenv/versions/3.6.9/envs/test2/bin/python3.6
cachedir: .pytest_cache
rootdir: /home/florian/test_testing_flask/flask/examples/tutorial, configfile: setup.cfg, testpaths: tests
collected 25 items

tests/test_auth.py::test_register PASSED [ 4%]
tests/test_auth.py::test_register_validate_input[--Username is required.] PASSED [ 8%]
tests/test_auth.py::test_register_validate_input[a--Password is required.] PASSED [ 12%]
tests/test_auth.py::test_register_validate_input[test-test-already registered] PASSED [ 16%]
tests/test_auth.py::test_login PASSED [ 20%]
tests/test_auth.py::test_login_validate_input[a-test-Incorrect username.] PASSED [ 24%]
tests/test_auth.py::test_login_validate_input[test-a-Incorrect password.] PASSED [ 28%]
tests/test_auth.py::test_logout PASSED [ 32%]
tests/test_blog.py::test_index PASSED [ 36%]
tests/test_blog.py::test_login_required[/create] PASSED [ 40%]
tests/test_blog.py::test_login_required[/1/update] PASSED [ 44%]
tests/test_blog.py::test_login_required[/1/delete] PASSED [ 48%]
tests/test_blog.py::test_author_required PASSED [ 52%]
tests/test_blog.py::test_exists_required[/2/update] PASSED [ 56%]
tests/test_blog.py::test_exists_required[/2/delete] PASSED [ 60%]
tests/test_blog.py::test_create PASSED [ 64%]
tests/test_blog.py::test_update PASSED [ 68%]
tests/test_blog.py::test_create_update_validate[/create] PASSED [ 72%]
tests/test_blog.py::test_create_update_validate[/1/update] PASSED [ 76%]
tests/test_blog.py::test_delete PASSED [ 80%]
tests/test_db.py::test_get_close_db PASSED [ 84%]
tests/test_db.py::test_init_db_command PASSED [ 88%]
tests/test_factory.py::test_config PASSED [ 92%]
tests/test_factory.py::test_hello PASSED [ 96%]
tests/test_flaskr.py::test_empty_db ERROR [100%]

================================================================================================================ ERRORS =================================================================================================================
____________________________________________________________________________________________________ ERROR at setup of test_empty_db ____________________________________________________________________________________________________

@pytest.fixture
def client():
> db_fd, flaskr.app.config['DATABASE'] = tempfile.mkstemp()
E NameError: name 'flaskr' is not defined

tests/test_flaskr.py:11: NameError
======================================================================================================== short test summary info ========================================================================================================
ERROR tests/test_flaskr.py::test_empty_db - NameError: name 'flaskr' is not defined
====================================================================================================== 24 passed, 1 error in 1.30s ======================================================================================================

Environment

Python version: Python 3.6.9

Flask version: 1.1.2

Werkzeug version: 1.0.1