コード例 #1
0
ファイル: test_mutations.py プロジェクト: acorg/dark-matter
 def testZeroLength(self):
     """
     The function should raise when given an empty string
     """
     error = 'Empty original string passed.'
     with six.assertRaisesRegex(self, ValueError, error):
         mutateString('', 1)
コード例 #2
0
 def testZeroLength(self):
     """
     The function should raise when given an empty string
     """
     error = 'Empty original string passed.'
     with six.assertRaisesRegex(self, ValueError, error):
         mutateString('', 1)
コード例 #3
0
 def testReplacementLengthOneAppearsInOriginal(self):
     """
     The function should raise when given a replacement string that contains
     just one letter if that letter also appears in the original.
     """
     error = 'Impossible replacement'
     with six.assertRaisesRegex(self, ValueError, error):
         mutateString('x', 1, 'x')
コード例 #4
0
 def testDuplicateReplacementLetter(self):
     """
     The function should raise when given a replacement string that contains
     a duplicate letter.
     """
     error = 'Replacement string contains duplicates'
     with six.assertRaisesRegex(self, ValueError, error):
         mutateString('x', 1, 'aa')
コード例 #5
0
 def testTooManyMutationsRequested(self):
     """
     The function should raise when asked to perform more mutations than
     there are in the original string.
     """
     error = 'Cannot make 2 mutations in a string of length 1'
     with six.assertRaisesRegex(self, ValueError, error):
         mutateString('x', 2)
コード例 #6
0
ファイル: test_mutations.py プロジェクト: acorg/dark-matter
 def testReplacementLengthOneAppearsInOriginal(self):
     """
     The function should raise when given a replacement string that contains
     just one letter if that letter also appears in the original.
     """
     error = 'Impossible replacement'
     with six.assertRaisesRegex(self, ValueError, error):
         mutateString('x', 1, 'x')
コード例 #7
0
ファイル: test_mutations.py プロジェクト: acorg/dark-matter
 def testDuplicateReplacementLetter(self):
     """
     The function should raise when given a replacement string that contains
     a duplicate letter.
     """
     error = 'Replacement string contains duplicates'
     with six.assertRaisesRegex(self, ValueError, error):
         mutateString('x', 1, 'aa')
コード例 #8
0
ファイル: test_mutations.py プロジェクト: acorg/dark-matter
 def testTooManyMutationsRequested(self):
     """
     The function should raise when asked to perform more mutations than
     there are in the original string.
     """
     error = 'Cannot make 2 mutations in a string of length 1'
     with six.assertRaisesRegex(self, ValueError, error):
         mutateString('x', 2)
コード例 #9
0
    def testOneReplacement(self):
        """
        The function should return all possible correct results (and only those
        results) when one mutation is requested and two outcomes are possible.

        NOTE: this test is a bit bad because it's non-deterministic.
        """
        possible = set(['ab', 'ba'])
        seen = set()

        for _ in range(100):
            result = mutateString('aa', 1, 'ab')
            self.assertTrue(result in possible)
            seen.add(result)
        self.assertEqual(seen, possible)
コード例 #10
0
ファイル: test_mutations.py プロジェクト: acorg/dark-matter
    def testOneReplacement(self):
        """
        The function should return all possible correct results (and only those
        results) when one mutation is requested and two outcomes are possible.

        NOTE: this test is a bit bad because it's non-deterministic.
        """
        possible = set(['ab', 'ba'])
        seen = set()

        for _ in range(100):
            result = mutateString('aa', 1, 'ab')
            self.assertTrue(result in possible)
            seen.add(result)
        self.assertEqual(seen, possible)
コード例 #11
0
 def testOneDeterministicReplacement(self):
     """
     The function should return the correct result when one mutation is
     requested and only one mutation is possible.
     """
     self.assertEqual('c', mutateString('a', 1, 'ac'))
コード例 #12
0
 def testZeroReplacements(self):
     """
     The function should return the original string when zero mutations
     are requested.
     """
     self.assertEqual('acgt', mutateString('acgt', 0, 'x'))
コード例 #13
0
 def testFiveDeterminsticReplacements(self):
     """
     The function should return the correct result when five mutations are
     requested and only one outcome is possible.
     """
     self.assertEqual('ccccc', mutateString('aaaaa', 5, 'ac'))
コード例 #14
0
ファイル: test_mutations.py プロジェクト: acorg/dark-matter
 def testFiveDeterminsticReplacements(self):
     """
     The function should return the correct result when five mutations are
     requested and only one outcome is possible.
     """
     self.assertEqual('ccccc', mutateString('aaaaa', 5, 'ac'))
コード例 #15
0
ファイル: test_mutations.py プロジェクト: acorg/dark-matter
 def testOneDeterministicReplacement(self):
     """
     The function should return the correct result when one mutation is
     requested and only one mutation is possible.
     """
     self.assertEqual('c', mutateString('a', 1, 'ac'))
コード例 #16
0
ファイル: test_mutations.py プロジェクト: acorg/dark-matter
 def testZeroReplacements(self):
     """
     The function should return the original string when zero mutations
     are requested.
     """
     self.assertEqual('acgt', mutateString('acgt', 0, 'x'))