本文整理汇总了Python中expecter.expect函数的典型用法代码示例。如果您正苦于以下问题:Python expect函数的具体用法?Python expect怎么用?Python expect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了expect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_can_be_pickled
def test_can_be_pickled(self):
obj = [1, 2, 3]
delegator = SimpleDelegator(obj)
pickled = pickle.dumps(delegator)
del delegator
unpickled_delegator = pickle.loads(pickled)
expect(get_delegated(unpickled_delegator)) == obj
示例2: is_returned_when_file_exists
def is_returned_when_file_exists(template):
template.root = "my_root"
with patch('pathlib.Path.is_file', Mock(return_value=True)):
path = template.path
expect(path) == Path("my_root/abc/default.png")
示例3: should_be_sigmoid_of_sum_of_incoming_values
def should_be_sigmoid_of_sum_of_incoming_values(self):
incoming = StubSynapse(1.0)
neuron = Neuron()
neuron.add_incoming(incoming)
neuron.add_incoming(incoming)
neuron.fire()
expect(neuron.activation) == sigmoid(2.0)
示例4: test_display_non_verbose
def test_display_non_verbose(self, stdout):
locs = NumberedPoints(['Home', '52.168;0.040'],
config_locations={'Home': (52.015, -0.221)})
locs.format = 'locator'
locs.verbose = False
locs.display('extsquare')
expect(stdout.getvalue()) == 'IO92va33\nJO02ae40\n'
示例5: it_expects_greater_than_or_equal
def it_expects_greater_than_or_equal(self):
expect(1) >= 1
expect(2) >= 1
def _fails(): expect(1) >= 2
assert_raises(AssertionError, _fails)
assert fail_msg(_fails) == (
'Expected something greater than or equal to 2 but got 1')
示例6: when_off_ci
def when_off_ci(monkeypatch):
monkeypatch.delenv('CI', raising=False)
monkeypatch.delenv('CONTINUOUS_INTEGRATION', raising=False)
monkeypatch.delenv('TRAVIS', raising=False)
monkeypatch.delenv('APPVEYOR', raising=False)
expect(services.detected()) == False
示例7: it_expects_containment
def it_expects_containment(self):
expect([1]).contains(1)
def _fails():
expect([2]).contains(1)
assert_raises(AssertionError, _fails)
assert fail_msg(_fails) == (
"Expected [2] to contain 1 but it didn't")
示例8: test___repr__
def test___repr__(self):
expect(repr(Cell(4, 52.015, -0.221, 21, 46, 40000, 10, 0, 1,
datetime.datetime(2008, 4, 15, 15, 21, 35),
datetime.datetime(2008, 4, 15, 15, 28, 49)))) == \
('Cell(4, 52.015, -0.221, 21, 46, 40000, 10, 0, 1, '
'datetime.datetime(2008, 4, 15, 15, 21, 35), '
'datetime.datetime(2008, 4, 15, 15, 28, 49))')
示例9: test_relevant_changes
def test_relevant_changes(self):
ok = SprinterChange(pk=1, component='Forms')
not_ok = SprinterChange(pk=2, component='ORM')
achievement = Achievement(component='Forms')
changes = [ok, not_ok]
filtered = achievement.relevant_changes(changes)
expect(filtered) == [ok]
示例10: test_get
def test_get(self, outbox_class):
outbox_class.return_value.get.return_value = self.mail
response = self.client.get(self._reverse())
expect(response.status_code) == 200
expect(response.context['mail']) == self.mail
示例11: test_import_locations
def test_import_locations(self):
trackpoints = Trackpoints(open("tests/data/gpx_tracks"))
data = list(map(str, sorted(trackpoints[0], key=lambda x: x.name)))
expect(data[0]) == """Home (52°00'54"N, 000°13'15"W on 2008-07-26T00:00:00+00:00) [My place]"""
expect(
data[1]
) == """MSR (52°10'01"N, 000°23'24"E on 2008-07-27T00:00:00+00:00) [Microsoft Research, Cambridge]"""
示例12: it_redirects_to_lose_alt_when_bad_url
def it_redirects_to_lose_alt_when_bad_url(client):
url = "http:invalid"
response = client.get("/sad-biden/hello.jpg?alt=" + url)
expect(response.status_code) == 302
expect(load(response, as_json=False)).contains(
'<a href="/sad-biden/hello.jpg">')
示例13: it_redirects_to_lose_alt_when_unknown_url
def it_redirects_to_lose_alt_when_unknown_url(client):
url = "http://example.com/not/a/real/image.jpg"
response = client.get("/sad-biden/hello.jpg?alt=" + url)
expect(response.status_code) == 302
expect(load(response, as_json=False)).contains(
'<a href="/sad-biden/hello.jpg">')
示例14: test_can_read_from_properties
def test_can_read_from_properties(self):
class C(SimpleDelegator):
@property
def prop(self):
return 123
c = C(mock.Mock())
expect(c.prop) == 123
示例15: it_can_compare_bytes
def it_can_compare_bytes(self):
null = bytes((0,))
expect(null) == null
data = bytes(range(9, 32))
def _fails():
expect(data) == data + null
assert_raises(AssertionError, _fails)