Skip to content

fixing errors on pytest #5

@taka-rl

Description

@taka-rl

Currently, the following errors happen when the commit or push are executed.
However, no errors happen when I execute pytest in my laptop.

■Goal: To find reasons why these error happen and fix them

ーーーーーーーーーー GitHub actions error messages ーーーーーーーーーー
Run pytest
============================= test session starts ==============================
platform linux -- Python 3.10.15, pytest-8.3.3, pluggy-1.5.0
rootdir: /home/runner/work/flask_webapp/flask_webapp
plugins: flask-1.3.0
collected 24 items

tests/test_about.py . [ 4%]
tests/test_admin.py .EEE [ 20%]
tests/test_auth.py ...... [ 45%]
tests/test_blog.py EEEE [ 62%]
tests/test_collection.py .EEE [ 79%]
tests/test_contact.py . [ 83%]
tests/test_error.py ... [ 95%]
tests/test_useful_info.py E [100%]

==================================== ERRORS ====================================
________________ ERROR at setup of test_admin_dashboard_access _________________

client = <FlaskClient <Flask 'flask_app'>>

@pytest.fixture
def super_admin_client(client):
    """Log in as the super admin and return the authenticated client."""
    login_response = client.post('/login', data={
        'email': SUPER_ADMIN_EMAIL,
        'password': SUPER_ADMIN_PASSWORD
    }, follow_redirects=True)

    # Make sure if login was successful
    assert login_response.status_code == 200
  assert b"admin-dashboard" in login_response.data

E assert b'admin-dashboard' in b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n'
E + where b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n' = <WrapperTestResponse 7962 bytes [200 OK]>.data

tests/conftest.py:50: AssertionError
___________________ ERROR at setup of test_change_user_role ____________________

client = <FlaskClient <Flask 'flask_app'>>

@pytest.fixture
def super_admin_client(client):
    """Log in as the super admin and return the authenticated client."""
    login_response = client.post('/login', data={
        'email': SUPER_ADMIN_EMAIL,
        'password': SUPER_ADMIN_PASSWORD
    }, follow_redirects=True)

    # Make sure if login was successful
    assert login_response.status_code == 200
  assert b"admin-dashboard" in login_response.data

E assert b'admin-dashboard' in b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n'
E + where b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n' = <WrapperTestResponse 7962 bytes [200 OK]>.data

tests/conftest.py:50: AssertionError
______________________ ERROR at setup of test_delete_user ______________________

client = <FlaskClient <Flask 'flask_app'>>

@pytest.fixture
def super_admin_client(client):
    """Log in as the super admin and return the authenticated client."""
    login_response = client.post('/login', data={
        'email': SUPER_ADMIN_EMAIL,
        'password': SUPER_ADMIN_PASSWORD
    }, follow_redirects=True)

    # Make sure if login was successful
    assert login_response.status_code == 200
  assert b"admin-dashboard" in login_response.data

E assert b'admin-dashboard' in b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n'
E + where b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n' = <WrapperTestResponse 7962 bytes [200 OK]>.data

tests/conftest.py:50: AssertionError
____________________ ERROR at setup of test_create_new_post ____________________

client = <FlaskClient <Flask 'flask_app'>>

@pytest.fixture
def super_admin_client(client):
    """Log in as the super admin and return the authenticated client."""
    login_response = client.post('/login', data={
        'email': SUPER_ADMIN_EMAIL,
        'password': SUPER_ADMIN_PASSWORD
    }, follow_redirects=True)

    # Make sure if login was successful
    assert login_response.status_code == 200
  assert b"admin-dashboard" in login_response.data

E assert b'admin-dashboard' in b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n'
E + where b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n' = <WrapperTestResponse 7962 bytes [200 OK]>.data

tests/conftest.py:50: AssertionError
_______________________ ERROR at setup of test_edit_post _______________________

client = <FlaskClient <Flask 'flask_app'>>

@pytest.fixture
def super_admin_client(client):
    """Log in as the super admin and return the authenticated client."""
    login_response = client.post('/login', data={
        'email': SUPER_ADMIN_EMAIL,
        'password': SUPER_ADMIN_PASSWORD
    }, follow_redirects=True)

    # Make sure if login was successful
    assert login_response.status_code == 200
  assert b"admin-dashboard" in login_response.data

E assert b'admin-dashboard' in b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n'
E + where b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n' = <WrapperTestResponse 7962 bytes [200 OK]>.data

tests/conftest.py:50: AssertionError
______________________ ERROR at setup of test_delete_post ______________________

client = <FlaskClient <Flask 'flask_app'>>

@pytest.fixture
def super_admin_client(client):
    """Log in as the super admin and return the authenticated client."""
    login_response = client.post('/login', data={
        'email': SUPER_ADMIN_EMAIL,
        'password': SUPER_ADMIN_PASSWORD
    }, follow_redirects=True)

    # Make sure if login was successful
    assert login_response.status_code == 200
  assert b"admin-dashboard" in login_response.data

E assert b'admin-dashboard' in b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n'
E + where b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n' = <WrapperTestResponse 7962 bytes [200 OK]>.data

tests/conftest.py:50: AssertionError
______________________ ERROR at setup of test_add_comment ______________________

client = <FlaskClient <Flask 'flask_app'>>

@pytest.fixture
def super_admin_client(client):
    """Log in as the super admin and return the authenticated client."""
    login_response = client.post('/login', data={
        'email': SUPER_ADMIN_EMAIL,
        'password': SUPER_ADMIN_PASSWORD
    }, follow_redirects=True)

    # Make sure if login was successful
    assert login_response.status_code == 200
  assert b"admin-dashboard" in login_response.data

E assert b'admin-dashboard' in b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n'
E + where b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n' = <WrapperTestResponse 7962 bytes [200 OK]>.data

tests/conftest.py:50: AssertionError
_______________________ ERROR at setup of test_add_place _______________________

client = <FlaskClient <Flask 'flask_app'>>

@pytest.fixture
def super_admin_client(client):
    """Log in as the super admin and return the authenticated client."""
    login_response = client.post('/login', data={
        'email': SUPER_ADMIN_EMAIL,
        'password': SUPER_ADMIN_PASSWORD
    }, follow_redirects=True)

    # Make sure if login was successful
    assert login_response.status_code == 200
  assert b"admin-dashboard" in login_response.data

E assert b'admin-dashboard' in b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n'
E + where b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n' = <WrapperTestResponse 7962 bytes [200 OK]>.data

tests/conftest.py:50: AssertionError
______________________ ERROR at setup of test_edit_place _______________________

client = <FlaskClient <Flask 'flask_app'>>

@pytest.fixture
def super_admin_client(client):
    """Log in as the super admin and return the authenticated client."""
    login_response = client.post('/login', data={
        'email': SUPER_ADMIN_EMAIL,
        'password': SUPER_ADMIN_PASSWORD
    }, follow_redirects=True)

    # Make sure if login was successful
    assert login_response.status_code == 200
  assert b"admin-dashboard" in login_response.data

E assert b'admin-dashboard' in b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n'
E + where b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n' = <WrapperTestResponse 7962 bytes [200 OK]>.data

tests/conftest.py:50: AssertionError
_____________________ ERROR at setup of test_delete_place ______________________

client = <FlaskClient <Flask 'flask_app'>>

@pytest.fixture
def super_admin_client(client):
    """Log in as the super admin and return the authenticated client."""
    login_response = client.post('/login', data={
        'email': SUPER_ADMIN_EMAIL,
        'password': SUPER_ADMIN_PASSWORD
    }, follow_redirects=True)

    # Make sure if login was successful
    assert login_response.status_code == 200
  assert b"admin-dashboard" in login_response.data

E assert b'admin-dashboard' in b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n'
E + where b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n' = <WrapperTestResponse 7962 bytes [200 OK]>.data

tests/conftest.py:50: AssertionError
________________ ERROR at setup of test_access_useful_info_page ________________

client = <FlaskClient <Flask 'flask_app'>>

@pytest.fixture
def super_admin_client(client):
    """Log in as the super admin and return the authenticated client."""
    login_response = client.post('/login', data={
        'email': SUPER_ADMIN_EMAIL,
        'password': SUPER_ADMIN_PASSWORD
    }, follow_redirects=True)

    # Make sure if login was successful
    assert login_response.status_code == 200
  assert b"admin-dashboard" in login_response.data

E assert b'admin-dashboard' in b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n'
E + where b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n' = <WrapperTestResponse 7962 bytes [200 OK]>.data

tests/conftest.py:50: AssertionError
=========================== short test summary info ============================
ERROR tests/test_admin.py::test_admin_dashboard_access - assert b'admin-dashboard' in b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n'

  • where b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n' = <WrapperTestResponse 7962 bytes [200 OK]>.data
    ERROR tests/test_admin.py::test_change_user_role - assert b'admin-dashboard' in b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n'
  • where b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n' = <WrapperTestResponse 7962 bytes [200 OK]>.data
    ERROR tests/test_admin.py::test_delete_user - assert b'admin-dashboard' in b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n'
  • where b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n' = <WrapperTestResponse 7962 bytes [200 OK]>.data
    ERROR tests/test_blog.py::test_create_new_post - assert b'admin-dashboard' in b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n'
  • where b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n' = <WrapperTestResponse 7962 bytes [200 OK]>.data
    ERROR tests/test_blog.py::test_edit_post - assert b'admin-dashboard' in b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n'
  • where b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n' = <WrapperTestResponse 7962 bytes [200 OK]>.data
    ERROR tests/test_blog.py::test_delete_post - assert b'admin-dashboard' in b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n'
  • where b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n' = <WrapperTestResponse 7962 bytes [200 OK]>.data
    ERROR tests/test_blog.py::test_add_comment - assert b'admin-dashboard' in b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n'
  • where b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n' = <WrapperTestResponse 7962 bytes [200 OK]>.data
    ERROR tests/test_collection.py::test_add_place - assert b'admin-dashboard' in b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n'
  • where b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n' = <WrapperTestResponse 7962 bytes [200 OK]>.data
    ERROR tests/test_collection.py::test_edit_place - assert b'admin-dashboard' in b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n'
  • where b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n' = <WrapperTestResponse 7962 bytes [200 OK]>.data
    ERROR tests/test_collection.py::test_delete_place - assert b'admin-dashboard' in b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n'
  • where b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n' = <WrapperTestResponse 7962 bytes [200 OK]>.data
    ERROR tests/test_useful_info.py::test_access_useful_info_page - assert b'admin-dashboard' in b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n'
  • where b'\n\n \n \n <meta\n name="viewport"\n c...in.js"></script>\n \n <script src="/static/js/scripts.js"></script>\n \n' = <WrapperTestResponse 7962 bytes [200 OK]>.data
    ======================== 13 passed, 11 errors in 4.06s =========================

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions