Say I have a function
def f(filename):
result = openFileAndProcessContents(filename)
return result
Can that function be unit tested without having a real file as input?
Something along the lines of
import unittest
class tests(unittest.TestCase):
def test1(self):
fileContents
Helge Stenstroem wrote:
Say I have a function
def f(filename):
result = openFileAndProcessContents(filename)
return result
Can that function be unit tested without having a real file as input?
Something along the lines of
import unittest
class tests(unittest.TestCase):
Helge Stenstroem wrote:
Say I have a function
def f(filename):
result = openFileAndProcessContents(filename)
return result
Can that function be unit tested without having a real file as input?
If you can refactor openFileAndProcessContents() so it looks like this:
def
Hi!
You can use tempfile.mktemp(), then write test contents to this temp
file,
pass it to your function, unlink tempfile.
you can create / unlink temp file in setUp() / tearDown() methods.
Alexander.
--
http://mail.python.org/mailman/listinfo/python-list
* Helge Stenstroem wrote:
Say I have a function
def f(filename):
result = openFileAndProcessContents(filename)
return result
Can that function be unit tested without having a real file as input?
Something along the lines of
import unittest
class tests(unittest.TestCase):