Skip to content

Instantly share code, notes, and snippets.

@k0emt
Last active June 11, 2023 15:41
Show Gist options
  • Save k0emt/1187769 to your computer and use it in GitHub Desktop.
Save k0emt/1187769 to your computer and use it in GitHub Desktop.
Basic Hello world in Python with corresponding unittest
__author__ = 'k0emt'
class Greeter:
def __init__(self):
self.message = 'Hello world'
# print self.message
__author__ = 'k0emt'
import unittest
from Experiment import Greeter
class MyTestCase(unittest.TestCase):
def test_default_greeting_set(self):
greeter = Greeter()
# this test will fail until you change the Greeter to return this expected message
self.assertEqual(greeter.message, 'Hello world!')
if __name__ == '__main__':
unittest.main()
@SchofieldChris
Copy link

Thanks for this, I was looking for a simple example and this is exactly what I needed.

@ronilpatel
Copy link

https://gist.github.com/ronilpatel/4b28e0f821ef119c8a8d223c89987f8a

Have a look at this with additional basic test cases appended to the above python files.
Thank You!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment