本文整理汇总了Python中sure.this函数的典型用法代码示例。如果您正苦于以下问题:Python this函数的具体用法?Python this怎么用?Python this使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了this函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_receive_addresses
def test_receive_addresses(self):
HTTPretty.register_uri(HTTPretty.GET, "https://coinbase.com/api/v1/account/receive_address",
body='''{"address" : "1DX9ECEF3FbGUtzzoQhDT8CG3nLUEA2FJt"}''',
content_type='text/json')
this(self.account.receive_address).should.equal(u'1DX9ECEF3FbGUtzzoQhDT8CG3nLUEA2FJt')
示例2: go
def go(self, account):
rates = account.exchange_rates
this(last_request_params()).should.equal({})
this(rates['gbp_to_usd']).should.be.equal(Decimal('1.648093'))
this(rates['usd_to_btc']).should.be.equal(Decimal('0.002'))
this(rates['btc_to_usd']).should.be.equal(Decimal('499.998'))
this(rates['bdt_to_btc']).should.be.equal(Decimal('0.000026'))
示例3: test_sell_price_10
def test_sell_price_10(self):
HTTPretty.register_uri(HTTPretty.GET, "https://coinbase.com/api/v1/prices/sell?qty=1",
body='''{"amount":"630.31","currency":"USD"}''',
content_type='text/json')
sell_price_10 = self.account.sell_price(10)
this(sell_price_10).should.be.greater_than(100)
示例4: 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 r"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")
expect(opposite).when.called.to.throw(AssertionError)
expect(opposite).when.called.to.throw(compat_repr(
"Person() should not have the property `name`, but it is 'John Doe'"))
expect(opposite_not).when.called.to.throw(AssertionError)
expect(opposite_not).when.called.to.throw(
"Person() should have the property `age` but does not")
示例5: test_api_key_balance
def test_api_key_balance(self):
HTTPretty.register_uri(HTTPretty.GET, "https://coinbase.com/api/v1/account/balance",
body='''{"amount":"1.00000000","currency":"BTC"}''',
content_type='text/json')
this(self.account.balance).should.equal(1.0)
示例6: test_be
def test_be():
("this(X).should.be(X) when X is a reference to the same object")
d1 = {}
d2 = d1
d3 = {}
assert isinstance(this(d2).should.be(d1), bool)
assert this(d2).should.be(d1)
assert this(d3).should_not.be(d1)
def wrong_should():
return this(d3).should.be(d1)
def wrong_should_not():
return this(d2).should_not.be(d1)
wrong_should_not.when.called.should.throw(
AssertionError,
'{} should not be the same object as {}, but it is',
)
wrong_should.when.called.should.throw(
AssertionError,
'{} should be the same object as {}, but it is not',
)
示例7: test_transactions
def test_transactions(self):
self.account.send(amount=CoinbaseAmount('.5', 'BTC'),
to_address='[email protected]')
self.account.send(amount=CoinbaseAmount('.8', 'BTC'),
to_address='[email protected]')
this([tx.recipient_address for tx in self.account.transactions()]) \
.should.equal(['[email protected]', '[email protected]'])
示例8: test_match_contain
def test_match_contain():
(u"expect('some string').to.contain('tri')")
assert this("some string").should.contain("tri")
assert this("some string").should_not.contain('foo')
def opposite():
assert this("some string").should.contain("bar")
def opposite_not():
assert this("some string").should_not.contain(r"string")
expect(opposite).when.called.to.throw(AssertionError)
if PY3:
expect(opposite).when.called.to.throw(
"'bar' should be in 'some string'")
else:
expect(opposite).when.called.to.throw(
"u'bar' should be in u'some string'")
expect(opposite_not).when.called.to.throw(AssertionError)
if PY3:
expect(opposite_not).when.called.to.throw(
"'string' should NOT be in 'some string'")
else:
expect(opposite_not).when.called.to.throw(
"u'string' should NOT be in u'some string'")
示例9: 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 r"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")
expect(opposite).when.called.to.throw(AssertionError)
expect(opposite).when.called.to.throw(compat_repr(
"'John Doe' should differ to 'John Doe', but is the same thing"))
expect(opposite_not).when.called.to.throw(AssertionError)
expect(opposite_not).when.called.to.throw(compat_repr(
"X is 'John Doe' whereas Y is 'Foo'"))
示例10: test_alloc_all_the_bridges
def test_alloc_all_the_bridges(self):
"""Set the needed number of bridges to the default"""
needed = '*'
distname = "test-distributor"
bucket = Bucket.BucketData(distname, needed)
this(bucket.name).should.be.equal(distname)
this(bucket.needed).should.be.equal(Bucket.BUCKET_MAX_BRIDGES)
示例11: test_alloc_some_of_the_bridges
def test_alloc_some_of_the_bridges(self):
"""Set the needed number of bridges"""
needed = 10
distname = "test-distributor"
bucket = Bucket.BucketData(distname, needed)
this(bucket.name).should.be.equal(distname)
this(bucket.needed).should.be.equal(needed)
示例12: test_order_callback
def test_order_callback():
"""
The example from the callbacks doc
https://coinbase.com/docs/merchant_tools/callbacks
"""
this(CoinbaseOrder.parse_callback(callback_body)) \
.should.be.equal(expected_order)
示例13: 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")
示例14: test_missingPrefix
def test_missingPrefix(self):
"""Changed to allow a missing 'a' prefix in branch
``hotfix/9462B-netstatus-returns-None``.
"""
self.line = '%s:1234' % self.oraddr
ip, port = networkstatus.parseALine(self.line)
this(ip).should.be.a(basestring)
this(port).should.be(None)
示例15: test_invalidNicknameNonAlphanumeric
def test_invalidNicknameNonAlphanumeric(self):
"""Test a line with a non-alphanumeric router nickname."""
self.makeRLine(nick='abcdef/*comment*/')
fields = networkstatus.parseRLine(self.line)
nick, ident, desc = fields[:3]
this(nick).should.be(None)
the(ident).should.be.a(basestring)
the(desc).should.be(None)