def test_disallow_second_strand_longer(self): with self.assertRaises(ValueError) as err: distance("ATA", "AGTG") self.assertEqual(type(err.exception), ValueError) self.assertEqual(err.exception.args[0], "Strands must be of equal length.")
def test_disallow_right_empty_strand(self): with self.assertRaises(ValueError) as err: distance("G", "") self.assertEqual(type(err.exception), ValueError) self.assertEqual(err.exception.args[0], "Strands must be of equal length.")
def test_disallow_second_strand_longer(self): with self.assertRaisesWithMessage(ValueError): hamming.distance("ATA", "AGTG")
def test_empty_strands(self): self.assertEqual(hamming.distance("", ""), 0)
def test_raises_with_msg_if_second_has_invalid_base(): with pytest.raises(ValueError) as exception_info: hamming.distance("CAGT", "CAGE") assert hamming.INVALID_BASE_MESSAGE in str(exception_info)
def test_long_different_strands(self): self.assertEqual(hamming.distance("GGACGGATTCTG", "AGGACGGATTCT"), 9)
def test_three_different_at_end_means_distance_one(): assert hamming.distance("GCA", "GCG") == 1
def test_different_three_means_distance_three(): assert hamming.distance("GCA", "CAG") == 3
def test_same_nucleotides_in_different_positions(self): self.assertEqual(hamming.distance("TAG", "GAT"), 2)
def test_different_singles_means_distance_one(): assert hamming.distance("G", "C") == 1
def test_small_distance_in_long_strands(self): self.assertEqual(hamming.distance("ACCAGGG", "ACTATGG"), 2)
def test_non_unique_character_in_second_strand(self): self.assertEqual(hamming.distance("AGG", "AGA"), 1)
def test_small_distance(self): self.assertEqual(hamming.distance("GGACG", "GGTCG"), 1)
def test_small_distance_in_small_strands(self): self.assertEqual(hamming.distance("AT", "CT"), 1)
def test_complete_distance_in_small_strands(self): self.assertEqual(hamming.distance("AG", "CT"), 2)
def test_complete_distance_in_single_nucleotide_strands(self): self.assertEqual(hamming.distance("A", "G"), 1)
def test_large_distance(self): self.assertEqual(hamming.distance("GATACA", "GCATAA"), 4)
def test_distance_returns_zero_with_two_empty_strings(): assert distance('', '') == 0
def test_large_distance_in_off_by_one_strand(self): self.assertEqual(hamming.distance("GGACGGATTCTG", "AGGACGGATTCT"), 9)
def test_three_different_at_start_means_distance_one(): assert hamming.distance("GCA", "CCA") == 1
def test_three_same_only_in_middle_means_distance_two(): assert hamming.distance("GCA", "TCC") == 2
def test_disallow_first_strand_longer(self): with self.assertRaises(ValueError): hamming.distance("AATG", "AAA")
def test_raises_with_msg_if_second_shorter(): with pytest.raises(ValueError) as exception_info: hamming.distance("GCA", "TG") assert hamming.LENGTH_MISMATCH_MESSAGE in str(exception_info)
def test_disallow_second_strand_longer(self): with self.assertRaises(ValueError): hamming.distance("ATA", "AGTG")
def test_small_hamming_distance2(self): self.assertEqual(2, hamming.distance('ATA', 'CTG'))
def test_identical_strands(self): self.assertEqual(hamming.distance("A", "A"), 0)
def test_disallow_first_strand_longer(self): with self.assertRaisesWithMessage(ValueError): hamming.distance("AATG", "AAA")
def test_distance_raises_exception_with_more_than_two_strings(): with pytest.raises(Exception): distance('', '', '')
def test_disallow_right_empty_strand(self): with self.assertRaisesWithMessage(ValueError): hamming.distance("G", "")
def test_distance_returns_zero_with_one_non_empty_and_one_space_string(): assert distance('ab', ' ab') == 0
def test_distance_raises_exception_with_one_string(): with pytest.raises(Exception): distance('')
def test_long_identical_strands(self): self.assertEqual(hamming.distance("GGACTGA", "GGACTGA"), 0)
def test_distance_raises_exception_when_left_non_empty_string_shorter_than_right(): with pytest.raises(Exception): distance('st', 'str')
def test_complete_hamming_distance_of_for_single_nucleotide_strand(self): self.assertEqual(1, hamming.distance('A', 'G'))
def test_distance_with_distance_two(): assert distance('abc', 'aeo') == 2
def test_complete_hamming_distance_of_for_small_strand(self): self.assertEqual(2, hamming.distance('AG', 'CT'))
def test_distance_raises_exception_without_strings(): with pytest.raises(Exception): distance()
def test_small_hamming_distance(self): self.assertEqual(1, hamming.distance('AT', 'CT'))
def test_same_three_means_distance_zero(): assert hamming.distance("GCA", "GCA") == 0
def test_small_hamming_distance_in_longer_strand(self): self.assertEqual(1, hamming.distance('GGACG', 'GGTCG'))
def test_three_different_in_middle_means_distance_one(): assert hamming.distance("GCA", "GGA") == 1
def test_large_hamming_distance(self): self.assertEqual(4, hamming.distance('GATACA', 'GCATAA'))
def test_three_same_only_at_start_means_distance_two(): assert hamming.distance("GCA", "GTG") == 2
def test_hamming_distance_in_very_long_strand(self): self.assertEqual(9, hamming.distance('GGACGGATTCTG', 'AGGACGGATTCT'))
def test_three_same_only_at_end_means_distance_two(): assert hamming.distance("GCA", "CGA") == 2
def test_no_difference_between_identical_strands(self): self.assertEqual(0, hamming.distance('A', 'A'))
def test_two_empty_means_distance_zero(): assert hamming.distance("", "") == 0
def test_single_letter_different_strands(self): self.assertEqual(hamming.distance("G", "T"), 1)
def test_same_singles_means_distance_zero(): assert hamming.distance("G", "G") == 0
def test_long_identical_strands(self): self.assertEqual(hamming.distance("GGACTGAAATCTG", "GGACTGAAATCTG"), 0)
def test_raises_with_msg_if_second_not_string(): with pytest.raises(ValueError) as exception_info: hamming.distance("TG", 3) assert hamming.NOT_STRING_MESSAGE in str(exception_info)
def test_non_unique_character_in_first_strand(self): self.assertEqual(hamming.distance("AAG", "AAA"), 1)