Skip to content

Instantly share code, notes, and snippets.

@trekr5
Created October 4, 2016 18:28
Show Gist options
  • Save trekr5/215ea60bb65cde244884d8ca16a0988c to your computer and use it in GitHub Desktop.
Save trekr5/215ea60bb65cde244884d8ca16a0988c to your computer and use it in GitHub Desktop.
Source python file and test python file
#test.py
class Test:
def __init__(self, members):
self.members = members
def printMembers(self):
print('Printing members of Test class...')
for member in self.members: print('\t%s ' % member)
test = Test(['Gazelle', 'Elephant', 'Lion', 'Fish'])
test.printMembers()
#test_test.py
import unittest
from test import Test
class TestTestCase(unittest.TestCase):
"""Tests for `test.py`."""
#preparing to test
def setUp(self):
"""Sample test case"""
print "TestTest::setUp_:begin"
# self.members = [1, 2, 3, 4, 5]
self.members = Test([1, 2, 3, 4])
def test_is_printMembers(self):
"""Will print a list of contents?"""
self.assertTrue(self.members.printMembers)
if __name__ == '__main__':
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment