'AttributeError: module 'sys' has no attribute 'append' , Pytest , FastAPI [closed]

Test file code for my fastapi app. Using Mas Os

from fastapi.testclient import TestClient
import json

import os 
import sys



sys.append.path(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from main import app

client = TestClient(app)



# email already exists
def test_createAccount_existing_User():
    input_data = {"first_name":"first", "last_name":"last", "email":"[email protected]", "password":"1234"}
    response = client.post('/account/', json.dump(input_data))
    assert response.status_code ==  400

Error that I am getting:

ERROR test_userRoute.py - AttributeError: module 'sys' has no attribute 'append'

When I am running pytest -v, showing error in the terminal.



Solution 1:[1]

To append to the path variable, use the syntax:

sys.path.append

You have these out of order.

sys.path is a list of search paths - append is just a built in method of list.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Michael Delgado