コード例 #1
0
 def test_crossing_change_pathfail_0(self):
     """Should raise error if randon_index
     set to False and index not set or
     not set to int"""
     bw = BraidWord([1, 2, 3])
     with self.assertRaises(ValueError) as te:
         bw.crossing_change(random_index=False)
コード例 #2
0
 def test_crossing_change_pathsuccess_2(self):
     """Should return new BraidWord with
     manually set generator inverted"""
     bw = BraidWord([1, 2, 3])
     newbraidword = bw.crossing_change(random_index=False, index=1)
     # Check that manually set generator has been inverted
     self.assertEqual(newbraidword.word, [1, -2, 3])
コード例 #3
0
 def test_crossing_change_pathsuccess_0(self):
     """Should return new BraidWord with
     random generator inverted"""
     bw = BraidWord([1, 2, 3])
     newbraidword = bw.crossing_change()
     # Check that one generator has been inverted
     x = list((i == -abs(i) for i in newbraidword.word))
     self.assertTrue(any(x) and not all(x))
コード例 #4
0
 def test_crossing_change_pathsuccess_1(self):
     """Should return new BraidWord with
     same length as previous"""
     bw = BraidWord([1, 2, 3])
     newbraidword = bw.crossing_change()
     self.assertEqual(len(newbraidword.word), 3)