Sha256: 5ffadcb96eba8bd1a50b7d056b2466cac6c228630ec6f18f6e51930761962d57

Contents?: true

Size: 1.41 KB

Versions: 10

Compression:

Stored size: 1.41 KB

Contents

import unittest

from rna_transcription import to_rna


# Tests adapted from `problem-specifications//canonical-data.json` @ v1.0.1

class DNATests(unittest.TestCase):

    def test_transcribes_cytosine_to_guanine(self):
        self.assertEqual(to_rna('C'), 'G')

    def test_transcribes_guanine_to_cytosine(self):
        self.assertEqual(to_rna('G'), 'C')

    def test_transcribes_thymine_to_adenine(self):
        self.assertEqual(to_rna('T'), 'A')

    def test_transcribes_adenine_to_uracil(self):
        self.assertEqual(to_rna('A'), 'U')

    def test_transcribes_all_occurences(self):
        self.assertEqual(to_rna('ACGTGGTCTTAA'), 'UGCACCAGAAUU')

    def test_correctly_handles_single_invalid_input(self):
        with self.assertRaisesWithMessage(ValueError):
            to_rna('U')

    def test_correctly_handles_completely_invalid_input(self):
        with self.assertRaisesWithMessage(ValueError):
            to_rna('XXX')

    def test_correctly_handles_partially_invalid_input(self):
        with self.assertRaisesWithMessage(ValueError):
            to_rna('ACGTXXXCTTAA')

    # Utility functions
    def setUp(self):
        try:
            self.assertRaisesRegex
        except AttributeError:
            self.assertRaisesRegex = self.assertRaisesRegexp

    def assertRaisesWithMessage(self, exception):
        return self.assertRaisesRegex(exception, r".+")


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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
trackler-2.2.1.105 tracks/python/exercises/rna-transcription/rna_transcription_test.py
trackler-2.2.1.104 tracks/python/exercises/rna-transcription/rna_transcription_test.py
trackler-2.2.1.103 tracks/python/exercises/rna-transcription/rna_transcription_test.py
trackler-2.2.1.102 tracks/python/exercises/rna-transcription/rna_transcription_test.py
trackler-2.2.1.101 tracks/python/exercises/rna-transcription/rna_transcription_test.py
trackler-2.2.1.100 tracks/python/exercises/rna-transcription/rna_transcription_test.py
trackler-2.2.1.99 tracks/python/exercises/rna-transcription/rna_transcription_test.py
trackler-2.2.1.98 tracks/python/exercises/rna-transcription/rna_transcription_test.py
trackler-2.2.1.97 tracks/python/exercises/rna-transcription/rna_transcription_test.py
trackler-2.2.1.96 tracks/python/exercises/rna-transcription/rna_transcription_test.py