当前位置: 首页>>代码示例>>Python>>正文


Python sure.that函数代码示例

本文整理汇总了Python中sure.that函数的典型用法代码示例。如果您正苦于以下问题:Python that函数的具体用法?Python that怎么用?Python that使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了that函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_tempo_should_descrever_quando_difereca_de_tempo_ocorreu_ha_55_minutos_atras

def test_tempo_should_descrever_quando_difereca_de_tempo_ocorreu_ha_55_minutos_atras():
    u"TempoRelativo deveria descrever quando diferenca de tempo ocorreu ha 55 minutos atras"
    relative_time = datetime.now() - timedelta(minutes=55)
    decorrido = TempoRelativo(relative_time)
    assert that(decorrido.ha).equals(u"há 55 minutos")
    assert that(decorrido.atras).equals(u"55 minutos atrás")
    assert that(unicode(decorrido)).equals(u"há 55 minutos")
开发者ID:pombredanne,项目名称:vargas,代码行数:7,代码来源:tests.py

示例2: test_tempo_should_descrever_quando_difereca_de_tempo_ocorreu_ha_1_mes_atras_com_31_dias

def test_tempo_should_descrever_quando_difereca_de_tempo_ocorreu_ha_1_mes_atras_com_31_dias():
    u"TempoRelativo deveria descrever quando diferenca de tempo ocorreu ha 1 mês atras"
    relative_time = datetime.now() - timedelta(minutes=60 * 24 * 31)
    decorrido = TempoRelativo(relative_time)
    assert that(decorrido.ha).equals(u"há 1 mês")
    assert that(decorrido.atras).equals(u"1 mês atrás")
    assert that(unicode(decorrido)).equals(u"há 1 mês")
开发者ID:pombredanne,项目名称:vargas,代码行数:7,代码来源:tests.py

示例3: select_by_attribute_id

def select_by_attribute_id(context):
    "selecting by attribute (id)"
    dom = DOM(context.html)

    (body, ) = dom.find("[id=firstp]")
    assert that(body).is_a(Element)
    assert that(body.attribute['id']).equals("firstp")
开发者ID:eroh92,项目名称:dominic,代码行数:7,代码来源:test_selectors.py

示例4: see_the_right_stop_and_duration_time

def see_the_right_stop_and_duration_time(step):
    stop_cell = world.wait_for_element('#stop-%s' % world.rows, 5, 0.5)
    assert that(stop_cell.text).equals(datetime.datetime.now().strftime("%B%e, %Y,%l:%M %P")), \
        'The stop time is not current'
    duration_cell = world.wait_for_element('#duration-%s' % world.rows, 5, 0.5)
    assert that(duration_cell.text).equals("00:00:03"), \
        'The duration is incorrect'
开发者ID:GunioRobot,项目名称:agile-django,代码行数:7,代码来源:details_steps.py

示例5: test_tempo_should_descrever_quando_difereca_de_tempo_ocorreu_ha_menos_de_1_minuto_atras

def test_tempo_should_descrever_quando_difereca_de_tempo_ocorreu_ha_menos_de_1_minuto_atras():
    u"TempoRelativo deveria descrever quando difereça de tempo ocorreu ha menos de 1 minuto atras"
    relative_time = datetime.now() - timedelta(seconds=55)
    decorrido = TempoRelativo(relative_time)
    assert that(decorrido.ha).equals(u"há menos de um minuto")
    assert that(decorrido.atras).equals(u"alguns segundos atrás")
    assert that(unicode(decorrido)).equals(u"há menos de um minuto")
开发者ID:wpjunior,项目名称:vargas,代码行数:7,代码来源:tests.py

示例6: test_that_something_iterable_matches_another

def test_that_something_iterable_matches_another():
    "sure.that(something_iterable).matches(another_iterable)"

    KlassOne = type('KlassOne', (object,), {})
    KlassTwo = type('KlassTwo', (object,), {})
    one = [
        ("/1", KlassOne),
        ("/2", KlassTwo),
    ]

    two = [
        ("/1", KlassOne),
        ("/2", KlassTwo),
    ]

    assert that(one).matches(two)
    assert that(one).equals(two)

    def fail_1():
        assert that(range(1)).matches(xrange(2))

    class Fail2(object):
        def __init__(self):
            assert that(xrange(1)).matches(range(2))

    class Fail3(object):
        def __call__(self):
            assert that(xrange(1)).matches(range(2))

    assert that(fail_1).raises('X is a list and Y is a xrange instead')
    assert that(Fail2).raises('X is a xrange and Y is a list instead')
    assert that(Fail3()).raises('X is a xrange and Y is a list instead')
开发者ID:e0ne,项目名称:sure,代码行数:32,代码来源:test_old_api.py

示例7: test_tempo_should_descrever_quando_difereca_de_tempo_ocorreu_ha_1_hora_atras

def test_tempo_should_descrever_quando_difereca_de_tempo_ocorreu_ha_1_hora_atras():
    u"TempoRelativo deveria descrever quando difereça de tempo ocorreu ha 1 hora atras"
    relative_time = datetime.now() - timedelta(minutes=60)
    decorrido = TempoRelativo(relative_time)
    assert that(decorrido.ha).equals(u"há 1 hora")
    assert that(decorrido.atras).equals(u"1 hora atrás")
    assert that(unicode(decorrido)).equals(u"há 1 hora")
开发者ID:wpjunior,项目名称:vargas,代码行数:7,代码来源:tests.py

示例8: test_tempo_should_descrever_quando_difereca_de_tempo_ocorreu_ha_4_dias_atras

def test_tempo_should_descrever_quando_difereca_de_tempo_ocorreu_ha_4_dias_atras():
    u"TempoRelativo deveria descrever quando difereça de tempo ocorreu ha 4 dias atras"
    relative_time = datetime.now() - timedelta(minutes=(60 * 24) * 4)
    decorrido = TempoRelativo(relative_time)
    assert that(decorrido.ha).equals(u"há 4 dias")
    assert that(decorrido.atras).equals(u"4 dias atrás")
    assert that(unicode(decorrido)).equals(u"há 4 dias")
开发者ID:wpjunior,项目名称:vargas,代码行数:7,代码来源:tests.py

示例9: select_by_id

def select_by_id(context):
    "selecting by id"
    dom = DOM(context.html)

    body = dom.find("#firstp").first()
    assert that(body).is_a(Element)
    assert that(body.attribute['id']).equals("firstp")
开发者ID:eroh92,项目名称:dominic,代码行数:7,代码来源:test_selectors.py

示例10: test_that_something_iterable_matches_another

def test_that_something_iterable_matches_another():
    "sure.that(something_iterable).matches(another_iterable)"

    KlassOne = type('KlassOne', (object,), {})
    KlassTwo = type('KlassTwo', (object,), {})
    one = [
        ("/1", KlassOne),
        ("/2", KlassTwo),
    ]

    two = [
        ("/1", KlassOne),
        ("/2", KlassTwo),
    ]

    assert that(one).matches(two)
    assert that(one).equals(two)

    def fail_1():
        assert that(range(1)).matches(xrange(2))

    class Fail2(object):
        def __init__(self):
            assert that(xrange(1)).equals(range(2))

    class Fail3(object):
        def __call__(self):
            assert that(xrange(1)).equals(range(2))

    assert that(fail_1).raises('[0] has 1 item, but xrange(2) has 2 items')
    assert that(Fail2).raises('xrange(1) has 1 item, but [0, 1] has 2 items')
    assert that(Fail3()).raises('xrange(1) has 1 item, but [0, 1] has 2 items')
开发者ID:pjdelport,项目名称:sure,代码行数:32,代码来源:test_sure.py

示例11: test_second_authentication_step_takes_code_and_makes_a_request

def test_second_authentication_step_takes_code_and_makes_a_request(context):
    "github.API's second authentication step is a redirect"

    class MyStore(github.TokenStore):
        data = {}

        def set(self, k, v):
            self.data[k] = v

        def get(self, k):
            return self.data.get(k)

    simple = MyStore()
    api = github.API("app-id-here", "app-secret-here", store=simple)

    HTTPretty.register_uri(
        HTTPretty.POST,
        "https://github.com/login/oauth/access_token",
        body='{"access_token": "this-is-the-access-token"}',
        status=200,
    )

    result = api.authenticate(code="visitor-code")
    assert that(result).is_a(github.API)

    last_request = HTTPretty.last_request
    assert that(last_request.headers).has("Authentication")
开发者ID:gabrielfalcao,项目名称:github-py,代码行数:27,代码来源:test_usage.py

示例12: test_have_property_with_value

def test_have_property_with_value():
    (u"this(instance).should.have.property(property_name).being or "
     ".with_value should allow chain up")

    class Person(object):
        name = "John Doe"

        def __repr__(self):
            return ur"Person()"

    jay = Person()

    assert this(jay).should.have.property("name").being.equal("John Doe")
    assert this(jay).should.have.property("name").not_being.equal("Foo")

    def opposite():
        assert this(jay).should.have.property("name").not_being.equal(
            "John Doe")

    def opposite_not():
        assert this(jay).should.have.property("name").being.equal(
            "Foo")

    assert that(opposite).raises(AssertionError)
    assert that(opposite).raises(
        "'John Doe' should differ to 'John Doe', but is the same thing")

    assert that(opposite_not).raises(AssertionError)
    assert that(opposite_not).raises(
        "X is 'John Doe' whereas Y is 'Foo'")
开发者ID:vrutkovs,项目名称:sure,代码行数:30,代码来源:test_assertion_builder.py

示例13: test_assertion_builder_synonyms

def test_assertion_builder_synonyms():
    (u"this, it, these and those are all synonyms")

    assert that(it).is_a(AssertionBuilder)
    assert that(this).is_a(AssertionBuilder)
    assert that(these).is_a(AssertionBuilder)
    assert that(those).is_a(AssertionBuilder)
开发者ID:vrutkovs,项目名称:sure,代码行数:7,代码来源:test_assertion_builder.py

示例14: test_have_property

def test_have_property():
    (u"this(instance).should.have.property(property_name)")

    class Person(object):
        name = "John Doe"

        def __repr__(self):
            return ur"Person()"

    jay = Person()

    assert this(jay).should.have.property("name")
    assert this(jay).should_not.have.property("age")

    def opposite():
        assert this(jay).should_not.have.property("name")

    def opposite_not():
        assert this(jay).should.have.property("age")

    assert that(opposite).raises(AssertionError)
    assert that(opposite).raises(
        "Person() should not have the property `name`, but it is 'John Doe'")

    assert that(opposite_not).raises(AssertionError)
    assert that(opposite_not).raises(
        "Person() should have the property `age` but doesn't")
开发者ID:vrutkovs,项目名称:sure,代码行数:27,代码来源:test_assertion_builder.py

示例15: select_html

def select_html(context):
    "selecting html"
    dom = DOM(context.html)

    html = dom.get("html")
    assert that(html).is_a(Element)
    assert that(html.attribute['id']).equals("html")
开发者ID:eroh92,项目名称:dominic,代码行数:7,代码来源:test_selectors.py


注:本文中的sure.that函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。