jeudi 5 mai 2016

python unittest patch vs file imports

file1.py has

from pkg1 import Class1

test_file1.py has

import file1

@patch('file1.Class1')

This works fine.

But file2.py has

from file1 import AppClass1

and I can't seem to come up with a @patch for Class1 in test_file2.py. My application is not a package. I've tried a few.

test_file2.py:

import file2

# @patch('file1.Class1')
# @patch('file2.Class1')
# @patch('file2.file1.Class1')
# @patch('pkg1.Class1')

Thanks

Aucun commentaire:

Enregistrer un commentaire