コード例 #1
0
    def test_reset(self):
        rotor = emul.Rotor(string.ascii_uppercase, [])
        rotor.ring_pos = 7
        rotor.position = 3
        rotor.just_turned_over = True

        rotor.reset()
        assert rotor.ring_pos == rotor.position == 0
        assert not rotor.just_turned_over
コード例 #2
0
 def test_init_can_set_thin_true(self):
     rotor = emul.Rotor(string.ascii_uppercase, [], thin=True)
     assert rotor.thin
コード例 #3
0
 def test_init_normalizes_turnover_case(self):
     rotor = emul.Rotor(string.ascii_uppercase, 'aBCdeF')
     assert rotor.turnovers == [0, 1, 2, 3, 4, 5]
コード例 #4
0
 def test_init_defaults_thin_false(self):
     rotor = emul.Rotor(string.ascii_uppercase, [])
     assert not rotor.thin
コード例 #5
0
 def test_init_sets_turnovers_correctly_str_len3(self):
     rotor = emul.Rotor(string.ascii_uppercase, 'ABC')
     assert rotor.turnovers == [0, 1, 2]
コード例 #6
0
 def test_init_sets_turnovers_correctly_list(self):
     rotor = emul.Rotor(string.ascii_uppercase, ['A', 'B', 'C'])
     assert rotor.turnovers == [0, 1, 2]
コード例 #7
0
 def test_init_allows_empty_turnover(self):
     rotor = emul.Rotor(string.ascii_uppercase, [])
     assert rotor.turnovers == []
コード例 #8
0
 def test_init_rejects_improper_turnover_list(self):
     with pytest.raises(ValueError):
         emul.Rotor(string.ascii_uppercase, ['AB', 'CD'])
コード例 #9
0
 def test_init_normalizes_cipher_case(self):
     rotor = emul.Rotor('ABcdEfGhIjklMnoPQRstuVWxyZ', [])
     assert rotor.cipher == list(string.ascii_uppercase)
コード例 #10
0
 def test_init_rejects_mixed_cipher(self):
     with pytest.raises(ValueError):
         emul.Rotor('@BCD3FG#!JKLMNOPQR$TUVWXYZ', [])
コード例 #11
0
 def test_init_rejects_nonalphabetical_cipher(self):
     with pytest.raises(ValueError):
         emul.Rotor('1234567890!@#$%^&*()_-+=[]', [])
コード例 #12
0
 def test_init_rejects_short_cipher(self):
     with pytest.raises(ValueError):
         emul.Rotor('ABC', [])
コード例 #13
0
 def test_init_rejects_long_cipher(self):
     with pytest.raises(ValueError):
         emul.Rotor(string.ascii_uppercase * 2, [])