python -m pytest ================================================================================= test session starts ================================================================================= platform win32 -- Python 3.9.12, pytest-7.1.2, pluggy-1.0.0 rootdir: C:\Users\nmyle\OneDrive\Desktop\flaskcode\flaskblog2 plugins: anyio-3.5.0 collected 8 items app\tests\test_testingpytest.py ... [ 37%] app\tests\functional\test_routes.py FFFE [ 87%] app\tests\unit\test_models.py . [100%] ======================================================================================= ERRORS ======================================================================================== _________________________________________________________________________ ERROR at setup of test_valid_login __________________________________________________________________________ self = , dialect = constructor = > statement = 'INSERT INTO user (username, hashed_password, email, confirmation_email, reset_email_password) VALUES (?, ?, ?, ?, ?)' parameters = ('fkpr[kfkuh', b'$2b$12$hAnRfVSm6r0uTMB29QikPek13Kw6c3g1lYJpD2v3n2EyUUBO6zjQC', 'nmyles@mail.com', 0, 0) execution_options = immutabledict({'autocommit': True, 'compiled_cache': {(, 1]}}) args = (, [{'confirmation_email': False, 'email'...w6c3g1lYJpD2v3n2EyUUBO6zjQC', 'username': 'fkpr[kfkuh'}], , []) kw = {'cache_hit': symbol('CACHE_MISS')}, branched = conn = , context = cursor = , fn = .wrap_before_cursor_execute at 0x0000023137D94550>, evt_handled = False def _execute_context( self, dialect, constructor, statement, parameters, execution_options, *args, **kw ): """Create an :class:`.ExecutionContext` and execute, returning a :class:`_engine.CursorResult`.""" branched = self if self.__branch_from: # if this is a "branched" connection, do everything in terms # of the "root" connection, *except* for .close(), which is # the only feature that branching provides self = self.__branch_from try: conn = self._dbapi_connection if conn is None: conn = self._revalidate_connection() context = constructor( dialect, self, conn, execution_options, *args, **kw ) except (exc.PendingRollbackError, exc.ResourceClosedError): raise except BaseException as e: self._handle_dbapi_exception( e, util.text_type(statement), parameters, None, None ) if ( self._transaction and not self._transaction.is_active or ( self._nested_transaction and not self._nested_transaction.is_active ) ): self._invalid_transaction() elif self._trans_context_manager: TransactionalContext._trans_ctx_check(self) if self._is_future and self._transaction is None: self._autobegin() context.pre_exec() if dialect.use_setinputsizes: context._set_input_sizes() cursor, statement, parameters = ( context.cursor, context.statement, context.parameters, ) if not context.executemany: parameters = parameters[0] if self._has_events or self.engine._has_events: for fn in self.dispatch.before_cursor_execute: statement, parameters = fn( self, cursor, statement, parameters, context, context.executemany, ) if self._echo: self._log_info(statement) stats = context._get_cache_stats() if not self.engine.hide_parameters: self._log_info( "[%s] %r", stats, sql_util._repr_params( parameters, batches=10, ismulti=context.executemany ), ) else: self._log_info( "[%s] [SQL parameters hidden due to hide_parameters=True]" % (stats,) ) evt_handled = False try: if context.executemany: if self.dialect._has_events: for fn in self.dialect.dispatch.do_executemany: if fn(cursor, statement, parameters, context): evt_handled = True break if not evt_handled: self.dialect.do_executemany( cursor, statement, parameters, context ) elif not parameters and context.no_parameters: if self.dialect._has_events: for fn in self.dialect.dispatch.do_execute_no_params: if fn(cursor, statement, context): evt_handled = True break if not evt_handled: self.dialect.do_execute_no_params( cursor, statement, context ) else: if self.dialect._has_events: for fn in self.dialect.dispatch.do_execute: if fn(cursor, statement, parameters, context): evt_handled = True break if not evt_handled: > self.dialect.do_execute( cursor, statement, parameters, context ) ..\..\..\..\anaconda3\lib\site-packages\sqlalchemy\engine\base.py:1808: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , cursor = statement = 'INSERT INTO user (username, hashed_password, email, confirmation_email, reset_email_password) VALUES (?, ?, ?, ?, ?)' parameters = ('fkpr[kfkuh', b'$2b$12$hAnRfVSm6r0uTMB29QikPek13Kw6c3g1lYJpD2v3n2EyUUBO6zjQC', 'nmyles@mail.com', 0, 0) context = def do_execute(self, cursor, statement, parameters, context=None): > cursor.execute(statement, parameters) E sqlite3.OperationalError: no such table: user ..\..\..\..\anaconda3\lib\site-packages\sqlalchemy\engine\default.py:732: OperationalError The above exception was the direct cause of the following exception: new_user = @pytest.fixture() def init_database(new_user): # Create the database and the database table db.create_all() # Insert user data # fill out the data that is new. ] db.session.add(new_user) # Commit the changes for the users > db.session.commit() app\tests\conftest.py:93: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ..\..\..\..\anaconda3\lib\site-packages\sqlalchemy\orm\session.py:1431: in commit self._transaction.commit(_to_root=self.future) ..\..\..\..\anaconda3\lib\site-packages\sqlalchemy\orm\session.py:829: in commit self._prepare_impl() ..\..\..\..\anaconda3\lib\site-packages\sqlalchemy\orm\session.py:808: in _prepare_impl self.session.flush() ..\..\..\..\anaconda3\lib\site-packages\sqlalchemy\orm\session.py:3363: in flush self._flush(objects) ..\..\..\..\anaconda3\lib\site-packages\sqlalchemy\orm\session.py:3503: in _flush transaction.rollback(_capture_exception=True) ..\..\..\..\anaconda3\lib\site-packages\sqlalchemy\util\langhelpers.py:70: in __exit__ compat.raise_( ..\..\..\..\anaconda3\lib\site-packages\sqlalchemy\util\compat.py:207: in raise_ raise exception ..\..\..\..\anaconda3\lib\site-packages\sqlalchemy\orm\session.py:3463: in _flush flush_context.execute() ..\..\..\..\anaconda3\lib\site-packages\sqlalchemy\orm\unitofwork.py:456: in execute rec.execute(self) ..\..\..\..\anaconda3\lib\site-packages\sqlalchemy\orm\unitofwork.py:630: in execute util.preloaded.orm_persistence.save_obj( ..\..\..\..\anaconda3\lib\site-packages\sqlalchemy\orm\persistence.py:244: in save_obj _emit_insert_statements( ..\..\..\..\anaconda3\lib\site-packages\sqlalchemy\orm\persistence.py:1237: in _emit_insert_statements result = connection._execute_20( ..\..\..\..\anaconda3\lib\site-packages\sqlalchemy\engine\base.py:1620: in _execute_20 return meth(self, args_10style, kwargs_10style, execution_options) ..\..\..\..\anaconda3\lib\site-packages\sqlalchemy\sql\elements.py:325: in _execute_on_connection return connection._execute_clauseelement( ..\..\..\..\anaconda3\lib\site-packages\sqlalchemy\engine\base.py:1487: in _execute_clauseelement ret = self._execute_context( ..\..\..\..\anaconda3\lib\site-packages\sqlalchemy\engine\base.py:1851: in _execute_context self._handle_dbapi_exception( ..\..\..\..\anaconda3\lib\site-packages\sqlalchemy\engine\base.py:2032: in _handle_dbapi_exception util.raise_( ..\..\..\..\anaconda3\lib\site-packages\sqlalchemy\util\compat.py:207: in raise_ raise exception ..\..\..\..\anaconda3\lib\site-packages\sqlalchemy\engine\base.py:1808: in _execute_context self.dialect.do_execute( _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , cursor = statement = 'INSERT INTO user (username, hashed_password, email, confirmation_email, reset_email_password) VALUES (?, ?, ?, ?, ?)' parameters = ('fkpr[kfkuh', b'$2b$12$hAnRfVSm6r0uTMB29QikPek13Kw6c3g1lYJpD2v3n2EyUUBO6zjQC', 'nmyles@mail.com', 0, 0) context = def do_execute(self, cursor, statement, parameters, context=None): > cursor.execute(statement, parameters) E sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: user E [SQL: INSERT INTO user (username, hashed_password, email, confirmation_email, reset_email_password) VALUES (?, ?, ?, ?, ?)] E [parameters: ('fkpr[kfkuh', b'$2b$12$hAnRfVSm6r0uTMB29QikPek13Kw6c3g1lYJpD2v3n2EyUUBO6zjQC', 'nmyles@mail.com', 0, 0)] E (Background on this error at: https://sqlalche.me/e/14/e3q8) ..\..\..\..\anaconda3\lib\site-packages\sqlalchemy\engine\default.py:732: OperationalError ====================================================================================== FAILURES ======================================================================================= _______________________________________________________________________________ test_register_page_get ________________________________________________________________________________ make_app_run_in_test_env = > def test_register_page_get(make_app_run_in_test_env): client = make_app_run_in_test_env """ GIVEN a Flask application configured for testing WHEN the '/register requested (GET) THEN check that the response is valid """ response = client.get('/register') """ In Python, the assert statement is used to continue the execute if the given condition evaluates to True. If the assert condition evaluates to False, then it raises the AssertionError exception with the specified error message. """ # Why use a b string? What is response.data? Answer it only work if I have a status code 200. > assert response.status_code == 200 E assert 404 == 200 E + where 404 = .status_code app\tests\functional\test_routes.py:24: AssertionError _______________________________________________________________________________ test_register_page_post _______________________________________________________________________________ make_app_run_in_test_env = > def test_register_page_post(make_app_run_in_test_env): client = make_app_run_in_test_env """ GIVEN a Flask application configured for testing WHEN the '/register requested (POST) THEN check that the response is valid """ response = client.post('/register') """ In Python, the assert statement is used to continue the execute if the given condition evaluates to True. If the assert condition evaluates to False, then it raises the AssertionError exception with the specified error message. """ # Why use a b string? What is response.data? Answer it only work if I have a status code 200. > assert response.status_code == 200 E assert 404 == 200 E + where 404 = .status_code app\tests\functional\test_routes.py:41: AssertionError _________________________________________________________________________________ test_verified_email _________________________________________________________________________________ make_app_run_in_test_env = >, new_user = def test_verified_email( make_app_run_in_test_env, new_user): # making the token work because I can't import methods client = make_app_run_in_test_env ''' example uid is a variable in the function response = make_app_run_in_test_env.get(f'/user/{uid}') ''' response = client.get("/verified_email", follow_redirects=True) # user = User.query.filter_by(email=new_user.email).first() #token = user.create_token() > assert response.status_code == 200 E assert 404 == 200 E + where 404 = .status_code app\tests\functional\test_routes.py:61: AssertionError ================================================================================== warnings summary =================================================================================== ..\..\..\..\anaconda3\lib\site-packages\flask\json\__init__.py:31 C:\Users\nmyle\anaconda3\lib\site-packages\flask\json\__init__.py:31: DeprecationWarning: Importing 'itsdangerous.json' is deprecated and will be removed in ItsDangerous 2.1. Use Python's 'json' module instead. _slash_escape = "\\/" not in _json.dumps("/") ..\..\..\..\anaconda3\lib\site-packages\flask\json\__init__.py:61 C:\Users\nmyle\anaconda3\lib\site-packages\flask\json\__init__.py:61: DeprecationWarning: Importing 'itsdangerous.json' is deprecated and will be removed in ItsDangerous 2.1. Use Python's 'json' module instead. class JSONEncoder(_json.JSONEncoder): ..\..\..\..\anaconda3\lib\site-packages\flask\json\__init__.py:103 C:\Users\nmyle\anaconda3\lib\site-packages\flask\json\__init__.py:103: DeprecationWarning: Importing 'itsdangerous.json' is deprecated and will be removed in ItsDangerous 2.1. Use Python's 'json' module instead. class JSONDecoder(_json.JSONDecoder): app/tests/functional/test_routes.py::test_register_page_get app/tests/functional/test_routes.py::test_register_page_post app/tests/functional/test_routes.py::test_verified_email C:\Users\nmyle\anaconda3\lib\site-packages\flask\app.py:2113: DeprecationWarning: 'BaseResponse' is deprecated and will be removed in Werkzeug 2.1. Use 'isinstance(obj, Response)' instead. elif isinstance(rv, BaseResponse) or callable(rv): -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html =============================================================================== short test summary info =============================================================================== FAILED app/tests/functional/test_routes.py::test_register_page_get - assert 404 == 200 FAILED app/tests/functional/test_routes.py::test_register_page_post - assert 404 == 200 FAILED app/tests/functional/test_routes.py::test_verified_email - assert 404 == 200 ERROR app/tests/functional/test_routes.py::test_valid_login - sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: user