vendredi 20 octobre 2017

Classes not working properly when imported for testing.

I'm trying to run a test on a number of class I've created. Here's how my current folder looks like for my project (called gemini)

project_folder/
    __init___.py
    gemini/
        __init__.py
        public_client.py 
        private_client.py
        cached.py 
        singular.py 
    tests/
        __init__.py
        test_file.py

Inside my test_file.py, this is how my code looks like:

import sys
sys.path.append('..')
from gemini.public_client import PublicClient

However, using the methods of the PublicClient class doesn't seem to be working. I can only instantiate the class in my code. For example, suppose, I have the following code in my test_file.py file:

import sys
sys.path.append('..')
from gemini.public_client import PublicClient

r = PublicClient()
r.get_ticker("btcusd")

I get the following error:

TypeError: get_ticker() missing 1 required positional argument: 'product_id'

Even thought I provided the 'product_id' which is "btcusd". However, if i create a file in the main project folder and create a PublicClient instance and run r.get_ticker("btcusd") it works perfectly. I don't understand what I'm doing wrong.

Aucun commentaire:

Enregistrer un commentaire