Comments (9)
Hey @HenriqueAJNB
I was doing some research on pytest and how could we replace this with fixtures. What do you think on something about this (test_pandasai.py
)
import pytest
@pytest.fixture
def llm(request):
return pytest.Mock()
@pytest.fixture
def pandasai(request, llm):
return PandasAI(llm)
def test_init(pandasai, llm):
assert pandasai._llm == llm
assert pandasai._is_conversational_answer is True
assert pandasai._verbose is False
def test_init_with_llm(pandasai, llm):
assert pandasai._llm == llm
assert pandasai._is_conversational_answer is True
assert pandasai._verbose is False
def test_init_without_llm():
with pytest.raises(LLMNotFoundError):
PandasAI()
Haven't tested it yet, but I think you meant something in this sense?
from pandas-ai.
@HenriqueAJNB @Lorenzobattistela merged, feel free to move on! :)
from pandas-ai.
Yes, although pytest
is not being used at the moment. I've opened this suggestion #26 for changing from unittest
to pytest
.
from pandas-ai.
Let's wait the decision and then we can create a branch to start changing it. I'm willing to contribute
from pandas-ai.
This would definitely help the way we test it, let's go for it. Does anyone of you @HenriqueAJNB @Lorenzobattistela want to work on it?
Before we pick this one, though, we should work on #26 and have it merged!
from pandas-ai.
I want to work on it. I can start working on the fixtures and then if @HenriqueAJNB is picking up #26 we wait for it to be merged to merge this one. Otherwise I can start working on #26 too. Let's wait for his answer
from pandas-ai.
Ok @Lorenzobattistela I'll assign it to you then! 🎉
from pandas-ai.
Started to work on this, is this the way to go?
import pytest
from typing import Optional
from unittest.mock import Mock, patch
import pandas as pd
from pandasai import PandasAI
from pandasai.exceptions import LLMNotFoundError
from pandasai.llm.fake import FakeLLM
@pytest.fixture
def llm(output: Optional[str] = None):
return FakeLLM(output=output)
@pytest.fixture
def pandasai(llm):
return PandasAI(llm)
def test_init(pandasai):
assert pandasai._llm is not None
assert pandasai._is_conversational_answer is True
assert pandasai._verbose is False
def test_init_without_llm():
with pytest.raises(LLMNotFoundError):
PandasAI()
def test_conversational_answer(pandasai, llm):
result = "2"
llm._output = result
assert pandasai.conversational_answer(
"What is the sum of 1 + 1?", "1 + 1", 2
) == result
def test_run(pandasai, llm):
df = pd.DataFrame()
llm._output = "1"
assert pandasai.run(df, "What number comes before 2?") == "1"
def test_run_with_conversational_answer(pandasai, llm):
df = pd.DataFrame()
llm._output = "1 + 1"
assert pandasai.run(
df, "What is the sum of 1 + 1?", is_conversational_answer=True
) == "1 + 1"
from pandas-ai.
@Lorenzobattistela, as soon as #67 is merged, you are able to go on.
from pandas-ai.
Related Issues (20)
- no working: Passing name and description for a dataframe
- Could there be some example of how to use pandasai to produce summary tables HOT 3
- AttributeError: 'PipelineContext' object has no attribute 'prompt_id' - New release(v2.0.23) introduced HOT 4
- Missing store vector when using training feature HOT 5
- LLM Inference Limit Reached! HOT 1
- openai should support modify base_url
- SqliteConnector has no attribute host HOT 8
- Agent requires pandasai api key HOT 2
- "enforce_privacy": True seems not work? HOT 1
- Code execute raise TypeError: 'PandasConnector' object is not subscriptable, looks PandasConnector not be well linked to a DataFrame. HOT 1
- Allow Custom API Base url HOT 2
- duckdb.IOException: IO Error: Trying to read a database file with version number 64, but we can only read version 51.
- Add skill function not work HOT 2
- pandasai.exceptions.PandasAIApiCallError: Training failed because of internal server error try again later! HOT 3
- Custom Prompts HOT 1
- Pandas 2.0 conflicts with the SQL connectors HOT 1
- FileNotFoundError: [Errno 2] No such file or directory: 'path/to/project/exports/charts/temp_chart.png'
- Add "map" function to the API
- Can’t force my agent to produce a conversational response. HOT 1
- 'NoneType' object has no attribute 'split' HOT 39
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pandas-ai.