This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
def assert_on_file(self, path, length, lines): | |
with open(path, "r") as file: | |
lines = file.read().splitlines() | |
assert len(lines) == length | |
for index, line in enumerate(lines): | |
assert lines[index] == line |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
def assert_on_file(self, path, length, lines): | |
with open(path, "r") as file: | |
lines = file.read().split("\n") | |
assert len(lines) == length | |
for index, line in enumerate(lines): | |
assert lines[index] == line |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self = <tests.test_keyValueStore.TestKeyValueStore object at 0x10d80f0f0> | |
path = 'tests/test_kvs_logs.txt', length = 1 | |
lines = ['set Sibyl cruelty', ''] | |
def assert_on_file(self, path, length, lines): | |
with open(path, "r") as file: | |
lines = file.read().split("\n") | |
> assert len(lines) == length | |
E AssertionError: assert 2 == 1 | |
E + where 2 = len(['set Sibyl cruelty', '']) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class KeyValueStore: | |
... | |
def write_to_log(self, string_operation, path_to_logs=''): | |
if path_to_logs == '': | |
path_to_logs = "logs/" + self.server_name + "_log.txt" | |
f = open(path_to_logs, "a+") | |
f.write(string_operation + '\n') | |
f.close() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from threading import Event, Thread | |
import queue | |
class TrafficLight: | |
def __init__(self, name, state): | |
self.name = str(name) | |
self.current_state = state | |
def progress(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TrafficLight: | |
def __init__(self, name, state): | |
self.name = str(name) | |
self.current_state = state | |
def progress(self): | |
if self.current_state == "green": | |
print(self.name + " light yellow") | |
self.current_state = "yellow" | |
elif self.current_state == "yellow": |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Initial state of traffic light | |
Init = { | |
'out1': 'G', | |
'out2': 'R', | |
'clock': 0, | |
'button': False, | |
'pc': 'G1' | |
} | |
# Define functions that determine state membership and state update. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(try '(define (require predicate) (if predicate #t (amb))) env) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(try '(define (a-number-between low-number high-number) | |
(if (= low-number high-number) | |
low-number | |
(amb low-number (a-number-between (+ low-number 1) high-number)) | |
) | |
) env) | |
(try '(a-number-between 1 9) env) ; --> 1 | |
(try '(a-number-between 1 9) env) ; --> 1 | |
(try '(a-number-between 1 9) env) ; --> 1 |