-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_task.py
More file actions
44 lines (32 loc) · 1.25 KB
/
test_task.py
File metadata and controls
44 lines (32 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import pytest
from task import hamming_distance
def test_hamming_distance_returns_0_if_two_empty_strings_are_passed():
strand_1 = ''
strand_2 = ''
distance: int = hamming_distance(strand_1, strand_2)
assert distance == 0
def test_hamming_distance_returns_0_if_two_identical_strings_are_passed():
strand_1 = 'AGG'
strand_2 = 'AGG'
distance: int = hamming_distance(strand_1, strand_2)
assert distance == 0
def test_hamming_distance_returns_1_if_two_strings_with_1_difference_are_passed():
strand_1 = 'AGT'
strand_2 = 'AGG'
distance: int = hamming_distance(strand_1, strand_2)
assert distance == 1
def test_hamming_distance_returns_3_if_two_strings_with_3_differences_are_passed():
strand_1 = 'AGT'
strand_2 = 'TTG'
distance: int = hamming_distance(strand_1, strand_2)
assert distance == 3
def test_hamming_distance_raises_value_error_if_one_string_is_empty_and_other_is_not():
strand_1 = ''
strand_2 = 'TTG'
with pytest.raises(ValueError):
hamming_distance(strand_1, strand_2)
def test_hamming_distance_raises_value_error_if_one_string_is_longer_than_the_other():
strand_1 = 'TTGAA'
strand_2 = 'TTG'
with pytest.raises(ValueError):
hamming_distance(strand_1, strand_2)