Skip to content

Instantly share code, notes, and snippets.

@23jodys
Created April 17, 2015 16:48
Show Gist options
  • Save 23jodys/d2c88506d7cf5e1b4659 to your computer and use it in GitHub Desktop.
Save 23jodys/d2c88506d7cf5e1b4659 to your computer and use it in GitHub Desktop.
import os
import shutil
import tempfile
import textwrap
import unittest
class TestFileReader(unittest.TestCase):
def setUp(self):
self.tempdir = tempfile.mkdtemp()
test_data = """\
192.168.0.1 testname
192.168.1.10 test2
"""
self.filename = os.path.join(self.tempdir, "hosts")
with open(self.filename, "w") as file_to_write:
file_to_write.writelines(textwrap.dedent(test_data))
def tearDown(self):
shutil.rmtree(self.tempdir)
def test_001(self):
print "testing some stuff on '{}' here".format(self.filename)
self.assertFalse(True)
if __name__ == '__main__':
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment