示例#1
0
def test_decode_header_randomness():
    assert_equal(mail._decode_header_randomness(None), set())
    assert_equal(mail._decode_header_randomness(["z@localhost", '"Z A" <z@localhost>']), 
                 set(["z@localhost", "z@localhost"]))
    assert_equal(mail._decode_header_randomness("z@localhost"),
                 set(["z@localhost"]))
    assert_raises(encoding.EncodingError, mail._decode_header_randomness, 1)
示例#2
0
def test_decode_header_randomness():
    assert_equal(mail._decode_header_randomness(None), set())

    # with strings
    assert_equal(mail._decode_header_randomness(["z@localhost", '"Z A" <z@localhost>']), set(["z@localhost", "z@localhost"]))
    assert_equal(mail._decode_header_randomness("z@localhost"), set(["z@localhost"]))

    # with bytes
    assert_equal(mail._decode_header_randomness([b"z@localhost", b'"Z A" <z@localhost>']), set(["z@localhost", "z@localhost"]))
    assert_equal(mail._decode_header_randomness(b"z@localhost"), set(["z@localhost"]))

    # with literal nonsense
    assert_raises(encoding.EncodingError, mail._decode_header_randomness, 1)
    assert_raises(encoding.EncodingError, mail._decode_header_randomness, [1, "m@localhost"])
示例#3
0
def test_decode_header_randomness():
    assert_equal(mail._decode_header_randomness(None), set())

    # with strings
    assert_equal(mail._decode_header_randomness(["z@localhost", '"Z A" <z@localhost>']),
                 set(["z@localhost", "z@localhost"]))
    assert_equal(mail._decode_header_randomness("z@localhost"), set(["z@localhost"]))

    # with bytes
    assert_equal(mail._decode_header_randomness([b"z@localhost", b'"Z A" <z@localhost>']),
                 set(["z@localhost", "z@localhost"]))
    assert_equal(mail._decode_header_randomness(b"z@localhost"), set(["z@localhost"]))

    # with literal nonsense
    assert_raises(encoding.EncodingError, mail._decode_header_randomness, 1)
    assert_raises(encoding.EncodingError, mail._decode_header_randomness, [1, "m@localhost"])
示例#4
0
    def test_decode_header_randomness(self):
        self.assertEqual(mail._decode_header_randomness(None), set())

        # with strings
        self.assertEqual(mail._decode_header_randomness(["z@localhost", '"Z A" <z@localhost>']),
                         set(["z@localhost", "z@localhost"]))
        self.assertEqual(mail._decode_header_randomness("z@localhost"), set(["z@localhost"]))

        # with bytes
        self.assertEqual(mail._decode_header_randomness([b"z@localhost", b'"Z A" <z@localhost>']),
                         set(["z@localhost", "z@localhost"]))
        self.assertEqual(mail._decode_header_randomness(b"z@localhost"), set(["z@localhost"]))

        # with literal nonsense
        with self.assertRaises(encoding.EncodingError):
            mail._decode_header_randomness(1)
        with self.assertRaises(encoding.EncodingError):
            mail._decode_header_randomness([1, "m@localhost"])