Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beautiful Soup & Pytest conflict #12808

Closed
pariah140 opened this issue Sep 12, 2024 · 3 comments
Closed

Beautiful Soup & Pytest conflict #12808

pariah140 opened this issue Sep 12, 2024 · 3 comments
Labels
stale status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity

Comments

@pariah140
Copy link

pariah140 commented Sep 12, 2024

Overview of issue

I am having an issue with BeautifulSoup and pytest. When I run pytest I get the following error:

TypeError: object.new() takes exactly one argument (the type to instantiate)

at this line of code in the function being tested:

soup = BeautifulSoup(response.text, 'html.parser')

I have no idea why this is happening but it means that I can't perform testing where BeautifulSoup is present. If I mock it I still run into the error, the only way to suppress it is to mock the new function, but this then leads to a whole host of other issues.

Here is the test code that fails:

def test_some_function(mocker):
    mocker.patch('requests.get')
    response_mock = mocker.Mock()
    response_mock.text = 'some text'
    requests.get.return_value = response_mock
    _some_function('https://example.com')
    requests.get.assert_called_once_with(
    url='https://example.com', headers=headers)

Pip List output

annotated-types    0.6.0
anyio              4.3.0
asttokens          2.4.1
beautifulsoup4     4.12.3
blessed            1.20.0
botocore           1.34.75
bs4                0.0.2
certifi            2024.2.2
chalice            1.31.0
charset-normalizer 3.3.2
click              8.1.7
decorator          5.1.1
distro             1.9.0
executing          2.1.0
h11                0.14.0
httpcore           1.0.5
httpx              0.27.0
idna               3.6
iniconfig          2.0.0
inquirer           2.10.1
ipython            8.27.0
jedi               0.19.1
jmespath           1.0.1
matplotlib-inline  0.1.7
openai             1.16.1
packaging          24.0
parso              0.8.4
pexpect            4.9.0
pinecone-client    3.2.2
pip                23.3.2
pluggy             1.4.0
prompt_toolkit     3.0.47
ptyprocess         0.7.0
pure_eval          0.2.3
pydantic           2.6.4
pydantic_core      2.16.3
Pygments           2.18.0
pytest             8.1.1
pytest-mock        3.14.0
python-dateutil    2.9.0.post0
python-dotenv      1.0.1
python-editor      1.0.4
PyYAML             6.0.1
readchar           4.0.6
requests           2.31.0
setuptools         69.2.0
six                1.16.0
sniffio            1.3.1
soupsieve          2.5
stack-data         0.6.3
tqdm               4.66.2
traitlets          5.14.3
typing_extensions  4.10.0
urllib3            2.2.1
wcwidth            0.2.13
wheel              0.43.0

Pytest version & OS Version
Pytest 8.1.1
mac sonoma 14.6.1

@RonnyPfannschmidt RonnyPfannschmidt added the status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity label Sep 12, 2024
@RonnyPfannschmidt
Copy link
Member

Neither a full traceback nor a runnable reproducer was provided

Without more details there's nothing we can do

Copy link
Contributor

This issue is stale because it has the status: needs information label and requested follow-up information was not provided for 14 days.

@github-actions github-actions bot added the stale label Sep 27, 2024
Copy link
Contributor

github-actions bot commented Oct 4, 2024

This issue was closed because it has the status: needs information label and follow-up information has not been provided for 7 days since being marked as stale.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity
Projects
None yet
Development

No branches or pull requests

2 participants