Sha256: 22125d624ef200cce52420fa575ed112df86332b7161dba0372e80cd5051cda2

Contents?: true

Size: 1.33 KB

Versions: 165

Compression:

Stored size: 1.33 KB

Contents

"""Tests for the nucleotide-count exercise

Implementation note:
The count function must raise a ValueError with a meaningful error message
in case of a bad argument.
"""
import unittest

from nucleotide_count import count, nucleotide_counts


class DNATest(unittest.TestCase):
    def test_empty_dna_string_has_no_adenosine(self):
        self.assertEqual(count('', 'A'), 0)

    def test_empty_dna_string_has_no_nucleotides(self):
        expected = {'A': 0, 'T': 0, 'C': 0, 'G': 0}
        self.assertEqual(nucleotide_counts(""), expected)

    def test_repetitive_cytidine_gets_counted(self):
        self.assertEqual(count('CCCCC', 'C'), 5)

    def test_repetitive_sequence_has_only_guanosine(self):
        expected = {'A': 0, 'T': 0, 'C': 0, 'G': 8}
        self.assertEqual(nucleotide_counts('GGGGGGGG'), expected)

    def test_counts_only_thymidine(self):
        self.assertEqual(count('GGGGGTAACCCGG', 'T'), 1)

    def test_validates_nucleotides(self):
        with self.assertRaises(ValueError):
            count("GACT", 'X')

    def test_counts_all_nucleotides(self):
        dna = ('AGCTTTTCATTCTGACTGCAACGGGCAATATGTCT'
               'CTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC')
        expected = {'A': 20, 'T': 21, 'G': 17, 'C': 12}
        self.assertEqual(nucleotide_counts(dna), expected)


if __name__ == '__main__':
    unittest.main()

Version data entries

165 entries across 165 versions & 1 rubygems

Version Path
trackler-2.2.1.74 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.2.1.73 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.2.1.72 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.2.1.71 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.2.1.70 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.2.1.69 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.2.1.68 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.2.1.67 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.2.1.66 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.2.1.65 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.2.1.64 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.2.1.63 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.2.1.62 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.2.1.61 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.2.1.60 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.2.1.59 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.2.1.58 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.2.1.57 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.2.1.56 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.2.1.55 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py