Exemplo n.º 1
0
def test_safe_bytes():
    text = b'some text'
    assert utils.safe(text) == text.decode('utf-8')
    assert utils.safe(text + b'\r\n') == text.decode('utf-8')
    assert utils.safe(text + b'\n') == text.decode('utf-8')
    assert utils.safe(text + b'\r') == text.decode('utf-8')
    assert utils.safe(b'\r\n' + text) == text.decode('utf-8')
    assert utils.safe(b'\n' + text) == text.decode('utf-8')
    assert utils.safe(b'\r' + text) == text.decode('utf-8')
    assert utils.safe(b'some \r\ntext') == text.decode('utf-8')
    assert utils.safe(b'some \ntext') == text.decode('utf-8')
    assert utils.safe(b'some \rtext') == text.decode('utf-8')
Exemplo n.º 2
0
def test_safe():
    text = 'some text'
    assert utils.safe(text + '\r\n') == text
    assert utils.safe(text + '\n') == text
    assert utils.safe(text + '\r') == text
    assert utils.safe('\r\n' + text) == text
    assert utils.safe('\n' + text) == text
    assert utils.safe('\r' + text) == text
    assert utils.safe('some \r\ntext') == text
    assert utils.safe('some \ntext') == text
    assert utils.safe('some \rtext') == text
Exemplo n.º 3
0
def test_safe_empty():
    text = ''
    assert utils.safe(text) == text
Exemplo n.º 4
0
def test_safe_null():
    with pytest.raises(TypeError):
        utils.safe(None)
Exemplo n.º 5
0
 def write(self, args, text=None):
     while not self.ircbackend:
         pass
     args = [safe(arg) for arg in args]
     self.ircbackend.send_command(*args, text=text)