Skip to content

Instantly share code, notes, and snippets.

@chelseatroy
Last active December 24, 2019 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chelseatroy/96754ce15247b23267d7386a68172fe4 to your computer and use it in GitHub Desktop.
Save chelseatroy/96754ce15247b23267d7386a68172fe4 to your computer and use it in GitHub Desktop.
Unit Test Example
from src.key_value_store import KeyValueStore
TEST_LOG_PATH = "tests/test_kvs_logs.txt"
class TestKeyValueStore():
...
def test_write_to_log(self):
self.clean_up_file(TEST_LOG_PATH)
kvs = KeyValueStore(server_name="DorianGray")
kvs.write_to_log("set Sibyl cruelty", TEST_LOG_PATH)
self.assert_on_file(path=TEST_LOG_PATH, length=1, lines="0 set Sibyl cruelty")
kvs.write_to_log("Set Basil wrath", TEST_LOG_PATH)
self.assert_on_file(path=TEST_LOG_PATH, length=2, lines=["0 set Sibyl cruelty", "0 set Basil wrath"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment