Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8841001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:36:09+00:00 2026-06-14T10:36:09+00:00

Running the code below I get E TypeError: unbound method make_request() must be called

  • 0

Running the code below I get

E TypeError: unbound method make_request() must be called with A instance as first argument (got str instance instead)

I dont want to set make_request method as static, I want to call it from an instance of an object.

The example http://pytest.org/latest/fixture.html#fixture-function

# content of ./test_smtpsimple.py
import pytest

@pytest.fixture
def smtp():
    import smtplib
    return smtplib.SMTP("merlinux.eu")

def test_ehlo(smtp):
    response, msg = smtp.ehlo()
    assert response == 250
    assert "merlinux" in msg
    assert 0 # for demo purposes

My code

""" """
import pytest


class  A(object):
    """  """
    def __init__(self, name ):
        """ """
        self._prop1 = [name]


    @property
    def prop1(self):
        return self._prop1  

    @prop1.setter
    def prop1(self, arguments):
        self._prop1 = arguments

    def make_request(self, sex):
        return 'result'

    def __call__(self):
        return self


@pytest.fixture()
def myfixture():
    """ """
    A('BigDave')
    return A

def test_validateA(myfixture):
    result = myfixture.make_request('male')
    assert result =='result'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T10:36:11+00:00Added an answer on June 14, 2026 at 10:36 am

    You can try replacing your last two methods as: –

    @pytest.fixture()
    def myfixture():
        """ """
        return A('BigDave')
    
    def test_validateA(myfixture):
        result = myfixture().make_request('male')
        assert result =='result'
    

    myfixture is the function object. To invoke the function you need a bracket on it. So, myfixture().

    Now in myfixture() method, return A again returns the class object. In order to return an instance of class A, on which you will call your method, you need to return either A() or just return the A('BigDave') you are using there.

    So, now your test_validateA method will get an instance of class A from myfixture method, on which you are invoking the method, thus passing the self as first argument.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get the following error when running the code below: invalid byte sequence in
I am getting an argument of length zero after running the code below. I
I get this message when running the code below: There is an error in
Could someone explain me, why I get 12 Februray when running the code below?
After running the code below I get this output: Eve 1200 Could anyone explain
Monotouch 5.0.2. Running the simple code below I get this in the output panel:
I'm running into a problem with method overwriting. Look at the src code below,
I got the process id of the running service using the code below as
I get this error when running the code below: Dim sqlSCIQty As String Dim
I'm running rails on ubuntu 12.04. When I run the code below I get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.