示例#1
0
def test_unicode():
    assert str(Suit('c')) == '♣'
    assert str(Suit('d')) == '♦'
    assert str(Suit('h')) == '♥'
    assert str(Suit('s')) == '♠'
示例#2
0
def test_str():
    assert str(Suit('c')) == u'♣'
    assert str(Suit('d')) == u'♦'
    assert str(Suit('h')) == u'♥'
    assert str(Suit('s')) == u'♠'
示例#3
0
def test_suit_order_reverse():
    assert Suit('d') > Suit('c')
    assert Suit('h') > Suit('c')
    assert Suit('s') > Suit('c')
    assert Suit('h') > Suit('d')
    assert Suit('s') > Suit('d')
    assert Suit('s') > Suit('h')

    assert (Suit('d') < Suit('c')) is False
    assert (Suit('h') < Suit('c')) is False
    assert (Suit('s') < Suit('c')) is False
    assert (Suit('h') < Suit('d')) is False
    assert (Suit('s') < Suit('d')) is False
    assert (Suit('s') < Suit('h')) is False
示例#4
0
def test_case_insensitive_reverse():
    assert Suit('c') == Suit('C')
    assert Suit('d') > Suit('C')
    assert Suit('h') > Suit('C')
    assert Suit('s') > Suit('C')
    assert Suit('h') > Suit('D')
    assert Suit('s') > Suit('D')
    assert Suit('s') > Suit('H')
示例#5
0
def test_make_random_is_instance_of_Suit():
    assert isinstance(Suit.make_random(), Suit)
示例#6
0
def test_putting_them_in_set_doesnt_raise_Exception():
    {Suit('c')}

    {Suit.CLUBS, Suit.SPADES}
示例#7
0
def test_suit_order_reverse():
    assert Suit("d") > Suit("c")
    assert Suit("h") > Suit("c")
    assert Suit("s") > Suit("c")
    assert Suit("h") > Suit("d")
    assert Suit("s") > Suit("d")
    assert Suit("s") > Suit("h")

    assert (Suit("d") < Suit("c")) is False
    assert (Suit("h") < Suit("c")) is False
    assert (Suit("s") < Suit("c")) is False
    assert (Suit("h") < Suit("d")) is False
    assert (Suit("s") < Suit("d")) is False
    assert (Suit("s") < Suit("h")) is False
示例#8
0
def test_suits_are_singletons():
    assert Suit('c') is Suit.CLUBS
    assert Suit('c') is Suit('c')
    assert Suit('c') is Suit('♣')

    assert Suit('s') is Suit.SPADES
示例#9
0
def test_hash():
    assert hash(Suit.CLUBS) == hash(Suit("c")) == hash(Suit("C")) == hash(
        Suit("♣"))

    assert hash(Suit.SPADES) == hash(Suit("s"))
示例#10
0
def test_unicode_suit_order():
    assert Suit("♣") < Suit("♦")
    assert Suit("♣") < Suit("♥")
    assert Suit("♣") < Suit("♠")
    assert Suit("♦") < Suit("♥")
    assert Suit("♦") < Suit("♠")
    assert Suit("♥") < Suit("♠")
示例#11
0
def test_suits_are_singletons():
    assert Suit("c") is Suit.CLUBS
    assert Suit("c") is Suit("c")
    assert Suit("c") is Suit("♣")

    assert Suit("s") is Suit.SPADES
示例#12
0
def test_class_is_iterable():
    assert list(Suit) == [Suit('♣'), Suit('♦'), Suit('♥'), Suit('♠')]
    assert list(Suit) == list(tuple(Suit))
示例#13
0
def test_repr():
    assert repr(Suit('c')) == "Suit('♣')"
    assert repr(Suit('d')) == "Suit('♦')"
    assert repr(Suit('h')) == "Suit('♥')"
    assert repr(Suit('s')) == "Suit('♠')"
示例#14
0
def test_str():
    assert str(Suit('c')) == '♣' == b'\xe2\x99\xa3'.decode('utf-8')
    assert str(Suit('d')) == '♦' == b'\xe2\x99\xa6'.decode('utf-8')
    assert str(Suit('h')) == '♥' == b'\xe2\x99\xa5'.decode('utf-8')
    assert str(Suit('s')) == '♠' == b'\xe2\x99\xa0'.decode('utf-8')
示例#15
0
def test_case_insensitive():
    assert Suit("C") == Suit("c")
    assert Suit("C") < Suit("d")
    assert Suit("C") < Suit("h")
    assert Suit("C") < Suit("s")
    assert Suit("D") < Suit("h")
    assert Suit("D") < Suit("s")
    assert Suit("H") < Suit("s")
示例#16
0
def test_case_insensitive():
    assert Card('aH').rank == Rank('A')
    assert Card('aH').suit == Suit('h') == Suit('♥')
示例#17
0
def test_suit_order():
    assert Suit("c") < Suit("d")
    assert Suit("c") < Suit("h")
    assert Suit("c") < Suit("s")
    assert Suit("d") < Suit("h")
    assert Suit("d") < Suit("s")
    assert Suit("h") < Suit("s")
示例#18
0
def test_suits_are_pickable():
    assert pickle.loads(pickle.dumps(Suit('c'))) == Suit('c')
    assert pickle.loads(pickle.dumps(Suit('c'))) is Suit('c')
示例#19
0
def test_case_insensitive_reverse():
    assert Suit("c") == Suit("C")
    assert Suit("d") > Suit("C")
    assert Suit("h") > Suit("C")
    assert Suit("s") > Suit("C")
    assert Suit("h") > Suit("D")
    assert Suit("s") > Suit("D")
    assert Suit("s") > Suit("H")
示例#20
0
def test_hash():
    assert (hash(Suit.CLUBS) == hash(Suit('c')) == hash(Suit('C')) == hash(
        Suit('♣')))

    assert hash(Suit.SPADES) == hash(Suit('s'))
示例#21
0
def test_str():
    assert str(Suit("c")) == "♣"
    assert str(Suit("d")) == "♦"
    assert str(Suit("h")) == "♥"
    assert str(Suit("s")) == "♠"
示例#22
0
def test_unicode_suit_order():
    assert Suit('♣') < Suit('♦')
    assert Suit('♣') < Suit('♥')
    assert Suit('♣') < Suit('♠')
    assert Suit('♦') < Suit('♥')
    assert Suit('♦') < Suit('♠')
    assert Suit('♥') < Suit('♠')
示例#23
0
def test_repr():
    assert repr(Suit("c")) == "Suit('♣')"
    assert repr(Suit("d")) == "Suit('♦')"
    assert repr(Suit("h")) == "Suit('♥')"
    assert repr(Suit("s")) == "Suit('♠')"
示例#24
0
def test_case_insensitive():
    assert Suit('C') == Suit('c')
    assert Suit('C') < Suit('d')
    assert Suit('C') < Suit('h')
    assert Suit('C') < Suit('s')
    assert Suit('D') < Suit('h')
    assert Suit('D') < Suit('s')
    assert Suit('H') < Suit('s')
示例#25
0
def test_class_is_iterable():
    assert list(Suit) == [Suit("♣"), Suit("♦"), Suit("♥"), Suit("♠")]
    assert list(Suit) == list(tuple(Suit))
示例#26
0
def test_wrong_value_raises_ValueError():
    with pytest.raises(ValueError):
        Suit('k')
示例#27
0
def test_unicode_suits():
    assert Card('A♠') > Card('Kd')
    assert Card('K♥') > Card('Kc')
    assert Card('aH').suit == Suit('♥')
    assert Card('2d').suit == Suit('♦')
示例#28
0
def test_suit_order():
    assert Suit('c') < Suit('d')
    assert Suit('c') < Suit('h')
    assert Suit('c') < Suit('s')
    assert Suit('d') < Suit('h')
    assert Suit('d') < Suit('s')
    assert Suit('h') < Suit('s')
示例#29
0
def test_suit():
    assert Card('Ac').suit == Suit('c')
示例#30
0
def test_make_random_is_instance_of_Suit():
    assert isinstance(Suit.make_random(), Suit)
示例#31
0
def test_case_insensitive():
    assert Card("aH").rank == Rank("A")
    assert Card("aH").suit == Suit("h") == Suit("♥")