Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kyclark committed Oct 31, 2020
1 parent e54d9c7 commit 7e0ad66
Show file tree
Hide file tree
Showing 24 changed files with 416 additions and 232 deletions.
8 changes: 4 additions & 4 deletions 01_dna/tests/dna_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@


# --------------------------------------------------
def test_exists():
def test_exists() -> None:
""" Program exists """

assert os.path.exists(PRG)


# --------------------------------------------------
def test_usage():
def test_usage() -> None:
""" Prints usage with no args or for help """

for arg in ['', '-h', '--help']:
Expand All @@ -26,7 +26,7 @@ def test_usage():


# --------------------------------------------------
def test_arg():
def test_arg() -> None:
""" Uses command-line arg """

for file, expected in [TEST1, TEST2, TEST3]:
Expand All @@ -37,7 +37,7 @@ def test_arg():


# --------------------------------------------------
def test_file():
def test_file() -> None:
""" Uses file arg """

for file, expected in [TEST1, TEST2, TEST3]:
Expand Down
16 changes: 8 additions & 8 deletions 02_rna/tests/rna_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@


# --------------------------------------------------
def test_exists():
def test_exists() -> None:
""" Program exists """

assert os.path.isfile(PRG)


# --------------------------------------------------
def test_usage():
def test_usage() -> None:
""" Usage """

for flag in ['-h', '--help']:
Expand All @@ -31,7 +31,7 @@ def test_usage():


# --------------------------------------------------
def test_no_args():
def test_no_args() -> None:
""" Dies on no args """

retval, out = getstatusoutput(PRG)
Expand All @@ -40,7 +40,7 @@ def test_no_args():


# --------------------------------------------------
def test_bad_file():
def test_bad_file() -> None:
""" Die on missing input """

bad = random_filename()
Expand All @@ -51,7 +51,7 @@ def test_bad_file():


# --------------------------------------------------
def test_good_input1():
def test_good_input1() -> None:
""" Runs on good input """

out_dir = 'out'
Expand All @@ -73,7 +73,7 @@ def test_good_input1():


# --------------------------------------------------
def test_good_input2():
def test_good_input2() -> None:
""" Runs on good input """

out_dir = random_filename()
Expand Down Expand Up @@ -128,7 +128,7 @@ def test_good_multiple_inputs():


# --------------------------------------------------
def output3():
def output3() -> str:
""" Output for 3rd input """

return '\n'.join([('CUUAGGUCAGUGGUCUCUAAACUUUCGGUUCUGUCGUCUUCAUAGGCAAA'
Expand Down Expand Up @@ -173,7 +173,7 @@ def output3():


# --------------------------------------------------
def random_filename():
def random_filename() -> str:
""" Generate a random filename """

return ''.join(random.choices(string.ascii_uppercase + string.digits, k=5))
14 changes: 7 additions & 7 deletions 03_revc/tests/revc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@


# --------------------------------------------------
def test_exists():
def test_exists() -> None:
""" Program exists """

assert os.path.isfile(PRG)


# --------------------------------------------------
def test_usage():
def test_usage() -> None:
""" Prints usage """

for arg in ['-h', '--help']:
Expand All @@ -28,7 +28,7 @@ def test_usage():


# --------------------------------------------------
def test_no_args():
def test_no_args() -> None:
""" Dies on no args """

rv, out = getstatusoutput(PRG)
Expand All @@ -37,7 +37,7 @@ def test_no_args():


# --------------------------------------------------
def test_uppercase():
def test_uppercase() -> None:
""" Runs on uppercase input """

rv, out = getstatusoutput(f'{PRG} AAAACCCGGT')
Expand All @@ -46,7 +46,7 @@ def test_uppercase():


# --------------------------------------------------
def test_lowercase():
def test_lowercase() -> None:
""" Runs on lowercase input """

rv, out = getstatusoutput(f'{PRG} aaaaCCCGGT')
Expand All @@ -55,7 +55,7 @@ def test_lowercase():


# --------------------------------------------------
def test_input1():
def test_input1() -> None:
""" Runs on file input """

file, expected = TEST1
Expand All @@ -65,7 +65,7 @@ def test_input1():


# --------------------------------------------------
def test_input2():
def test_input2() -> None:
""" Runs on file input """

file, expected = TEST2
Expand Down
14 changes: 7 additions & 7 deletions 04_fib/tests/fib_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@


# --------------------------------------------------
def test_exists():
def test_exists() -> None:
""" Program exists """

assert os.path.isfile(PRG)


# --------------------------------------------------
def test_usage():
def test_usage() -> None:
""" Usage """

for arg in ['-h', '--help']:
Expand All @@ -26,7 +26,7 @@ def test_usage():


# --------------------------------------------------
def test_bad_n():
def test_bad_n() -> None:
""" Dies when n is bad """

n = random.choice(list(range(-10, 0)) + list(range(41, 50)))
Expand All @@ -38,7 +38,7 @@ def test_bad_n():


# --------------------------------------------------
def test_bad_k():
def test_bad_k() -> None:
""" Dies when k is bad """

n = random.randint(1, 40)
Expand All @@ -50,7 +50,7 @@ def test_bad_k():


# --------------------------------------------------
def test_1():
def test_1() -> None:
"""runs on good input"""

rv, out = getstatusoutput(f'{PRG} 5 3')
Expand All @@ -59,7 +59,7 @@ def test_1():


# --------------------------------------------------
def test_2():
def test_2() -> None:
"""runs on good input"""

rv, out = getstatusoutput(f'{PRG} 30 4')
Expand All @@ -68,7 +68,7 @@ def test_2():


# --------------------------------------------------
def test_3():
def test_3() -> None:
"""runs on good input"""

rv, out = getstatusoutput(f'{PRG} 29 2')
Expand Down
2 changes: 1 addition & 1 deletion 05_gc/solution2_unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def gc(seq: str) -> float:


# --------------------------------------------------
def test_gc():
def test_gc() -> None:
""" Test gc """

assert gc('') == 0.
Expand Down
12 changes: 6 additions & 6 deletions 05_gc/tests/cgc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@


# --------------------------------------------------
def test_exists():
def test_exists() -> None:
""" Program exists """

assert os.path.isfile(PRG)


# --------------------------------------------------
def test_usage():
def test_usage() -> None:
""" Usage """

for flag in ['-h', '--help']:
Expand All @@ -29,7 +29,7 @@ def test_usage():


# --------------------------------------------------
def test_bad_input():
def test_bad_input() -> None:
""" Fails on bad input """

bad = random_string()
Expand All @@ -40,7 +40,7 @@ def test_bad_input():


# --------------------------------------------------
def test_good_input1():
def test_good_input1() -> None:
""" Works on good input """

rv, out = getstatusoutput(f'{PRG} {SAMPLE1}')
Expand All @@ -49,7 +49,7 @@ def test_good_input1():


# --------------------------------------------------
def test_good_input2():
def test_good_input2() -> None:
""" Works on good input """

rv, out = getstatusoutput(f'{PRG} {SAMPLE2}')
Expand All @@ -58,7 +58,7 @@ def test_good_input2():


# --------------------------------------------------
def random_string():
def random_string() -> str:
""" Generate a random string """

k = random.randint(5, 10)
Expand Down
4 changes: 2 additions & 2 deletions 06_hamm/solution2_unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Args(NamedTuple):


# --------------------------------------------------
def get_args():
def get_args() -> Args:
""" Get command-line arguments """

parser = argparse.ArgumentParser(
Expand All @@ -30,7 +30,7 @@ def get_args():


# --------------------------------------------------
def main():
def main() -> None:
""" Make a jazz noise here """

args = get_args()
Expand Down
16 changes: 8 additions & 8 deletions 06_hamm/tests/hamm_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@


# --------------------------------------------------
def test_exists():
def test_exists() -> None:
""" Program exists """

assert os.path.isfile(PRG)


# --------------------------------------------------
def test_usage():
def test_usage() -> None:
""" Usage """

for flag in ['-h', '--help']:
Expand All @@ -31,7 +31,7 @@ def test_usage():


# --------------------------------------------------
def test_bad_file():
def test_bad_file() -> None:
""" Dies on bad file """

bad = random_string()
Expand All @@ -41,7 +41,7 @@ def test_bad_file():


# --------------------------------------------------
def run(file, expected):
def run(file: str, expected: str) -> None:
""" Run with input """

rv, out = getstatusoutput(f'{PRG} {file}')
Expand All @@ -50,21 +50,21 @@ def run(file, expected):


# --------------------------------------------------
def test_input1():
def test_input1() -> None:
""" Test with input1 """

run(INPUT1, '7')


# --------------------------------------------------
def test_input2():
def test_input2() -> None:
""" Test with input2 """

run(INPUT2, '503')


# --------------------------------------------------
def test_empty_file():
def test_empty_file() -> None:
""" Empty file """

rv, out = getstatusoutput(f'{PRG} {EMPTY}')
Expand All @@ -73,7 +73,7 @@ def test_empty_file():


# --------------------------------------------------
def random_string():
def random_string() -> str:
""" Generate a random string """

k = random.randint(5, 10)
Expand Down
Loading

0 comments on commit 7e0ad66

Please sign in to comment.