Sha256: 539a316d215692e44ad0ac70adeff1b91fb1d2e4e39de78dbf89a5c423ab82cf

Contents?: true

Size: 1.33 KB

Versions: 101

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(0, count('', 'A'))

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

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

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

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

    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(expected, nucleotide_counts(dna))


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

Version data entries

101 entries across 101 versions & 1 rubygems

Version Path
trackler-2.0.8.27 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.0.8.26 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.0.8.24 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.0.8.23 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.0.8.22 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.0.8.21 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.0.8.20 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.0.8.19 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.0.8.18 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.0.8.17 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.0.8.16 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.0.8.15 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.0.8.14 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.0.8.13 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.0.8.12 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.0.8.11 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.0.8.10 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.0.8.9 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.0.8.8 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py
trackler-2.0.8.7 tracks/python/exercises/nucleotide-count/nucleotide_count_test.py