Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #1621 Update hamming_tests to v2.2.0 #1632

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion exercises/binary-search/binary_search_test.py
Expand Up @@ -47,7 +47,7 @@ def test_empty_array(self):
# Utility functions
def setUp(self):
try:
self.assertRaisesRegex
self.assertRaisesRegexgit
except AttributeError:
self.assertRaisesRegex = self.assertRaisesRegexp

Expand Down
38 changes: 7 additions & 31 deletions exercises/hamming/hamming_test.py
Expand Up @@ -3,47 +3,23 @@
import hamming


# Tests adapted from `problem-specifications//canonical-data.json` @ v2.1.1
# Tests adapted from `problem-specifications//canonical-data.json` @ v2.2.0

class HammingTest(unittest.TestCase):

def test_empty_strands(self):
self.assertEqual(hamming.distance("", ""), 0)

def test_identical_strands(self):
def test_single_letter_identical_strands(self):
self.assertEqual(hamming.distance("A", "A"), 0)

def test_long_identical_strands(self):
self.assertEqual(hamming.distance("GGACTGA", "GGACTGA"), 0)

def test_complete_distance_in_single_nucleotide_strands(self):
self.assertEqual(hamming.distance("A", "G"), 1)

def test_complete_distance_in_small_strands(self):
self.assertEqual(hamming.distance("AG", "CT"), 2)

def test_small_distance_in_small_strands(self):
self.assertEqual(hamming.distance("AT", "CT"), 1)

def test_small_distance(self):
self.assertEqual(hamming.distance("GGACG", "GGTCG"), 1)
def test_single_letter_different_strands(self):
self.assertEqual(hamming.distance("G", "T"), 1)

def test_small_distance_in_long_strands(self):
self.assertEqual(hamming.distance("ACCAGGG", "ACTATGG"), 2)

def test_non_unique_character_in_first_strand(self):
self.assertEqual(hamming.distance("AAG", "AAA"), 1)

def test_non_unique_character_in_second_strand(self):
self.assertEqual(hamming.distance("AAA", "AAG"), 1)

def test_same_nucleotides_in_different_positions(self):
self.assertEqual(hamming.distance("TAG", "GAT"), 2)

def test_large_distance(self):
self.assertEqual(hamming.distance("GATACA", "GCATAA"), 4)
def test_long_identical_strands(self):
self.assertEqual(hamming.distance("GGACTGAAATCTG", "GGACTGAAATCTG"), 0)

def test_large_distance_in_off_by_one_strand(self):
def test_long_different_strands(self):
self.assertEqual(hamming.distance("GGACGGATTCTG", "AGGACGGATTCT"), 9)

def test_disallow_first_strand_longer(self):
Expand Down