Home > database >  TypeError: iText() missing 2 required positional arguments: 'text' and 'data_frame�
TypeError: iText() missing 2 required positional arguments: 'text' and 'data_frame�

Time:11-29

this is my function.py

def iText(text, data_frame):
    url = requests.get("http://nlp.cs.aueb.gr/software_and_datasets/lingspam_public.tar.gz")
    text = url\[-1\].strip()      
    label = url\[-1\].strip()                   
    data_frame = pd.DataFrame(text, label)

    return text, data_frame

this my file test_fc.py

def test_coba():
    text = iText
    data_frame = iText
    assert text, data_frame

It runs but I'm not sure if it is right. Can anyone help?

CodePudding user response:

No, it's not right. Your iText function doesn't have any inputs, so it shouldn't have any parameters. Next, in your test function, you need to CALL iText and check what it returns:

def iText():
    url = requests.get("http://nlp.cs.aueb.gr/software_and_datasets/lingspam_public.tar.gz")
    text = url[-1].strip()      
    label = url[-1].strip()                   
    data_frame = pd.DataFrame(text, label)
    return text, data_frame

def test_coba():
    text, data_frame = iText()
    assert text, data_frame

However, if you're fetching a tarball, what do you think url[-1].strip() is going to do?

  • Related