mercredi 31 janvier 2018

python mock Django settings variable

settings.py

IMAGE_LIMIT = 256

thumbnail_utils.py

from settings import IMAGE_LIMIT

def thumbnail():
    image_memory = 10   
    if image_memory > IMAGE_LIMIT:
        return Ture
    else:
        pass

test.py

@patch('thumbnail.IMAGE_LIMIT', '0')
def test_thumbnail(self, mock_IMAGE_LIMIT):
    status = thumbnail()
    assert status == False

The above is the wrong test.I urgently want to know how I should do it.

Aucun commentaire:

Enregistrer un commentaire