本文整理汇总了Python中aspen.testing.fsfix.mk函数的典型用法代码示例。如果您正苦于以下问题:Python mk函数的具体用法?Python mk怎么用?Python mk使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mk函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_socket_can_shake_hands
def test_socket_can_shake_hands():
mk(('echo.sock', ''))
socket = make_socket()
response = socket.shake_hands()
expected = '15:10:xhr-polling'
actual = response.body.split(':', 1)[1]
assert actual == expected, actual
示例2: test_can_put_onto_buffer
def test_can_put_onto_buffer():
mk(('echo.sock.spt', 'socket.send(socket.recv())'))
buffer = Buffer(make_socket(), 'foo')
expected = [FFFD+'4'+FFFD+'1:::']
buffer.put(Message.from_bytes('1:::'))
actual = list(buffer.flush())
assert actual == expected, actual
示例3: test_root_defaults_to_cwd
def test_root_defaults_to_cwd():
mk()
c = Configurable()
c.configure([])
expected = os.getcwd()
actual = c.root
assert actual == expected, actual
示例4: test_redirect_has_only_location
def test_redirect_has_only_location():
mk(('index.html.spt', "from aspen import Response\n[---]\nrequest.redirect('http://elsewhere', code=304)\n[---]\n"))
actual = handle()
assert actual.code == 304
headers = actual.headers
assert len(headers) == 1, headers
assert headers.get('Location') is not None, headers
示例5: test_unavailable_knob_works
def test_unavailable_knob_works():
mk( '.aspen'
, ('.aspen/foo.py', 'bar = "baz"')
, ('index.html', "import fooGreetings, {{ foo.bar }}!")
)
actual = handle('/', '--unavailable=1').code
assert actual == 503, actual
示例6: test_configurable_sees_root_option
def test_configurable_sees_root_option():
mk()
c = Configurable()
c.configure(['--root', FSFIX])
expected = os.getcwd()
actual = c.root
assert actual == expected, actual
示例7: test_www_root_defaults_to_cwd
def test_www_root_defaults_to_cwd():
mk()
c = Configurable()
c.configure([])
expected = os.path.realpath(os.getcwd())
actual = c.www_root
assert actual == expected, actual
示例8: test_can_put_onto_buffer
def test_can_put_onto_buffer():
mk(("echo.sock", "socket.send(socket.recv())"))
buffer = Buffer(make_socket(), "foo")
expected = [FFFD + "4" + FFFD + "1:::"]
buffer.put(Message.from_bytes("1:::"))
actual = list(buffer.flush())
assert actual == expected, actual
示例9: test_resources_can_import_from_dot_aspen
def test_resources_can_import_from_dot_aspen():
mk( '.aspen'
, ('.aspen/foo.py', 'bar = "baz"')
, ('index.html', "import fooGreetings, {{ foo.bar }}!")
)
expected = "Greetings, baz!"
actual = handle('/', '--project_root=.aspen').body
assert actual == expected, actual
示例10: make_transport
def make_transport(content='', state=0):
mk(('echo.sock', content))
socket = make_socket()
transport = XHRPollingTransport(socket)
transport.timeout = 0.05 # for testing, could screw up the test
if state == 1:
transport.respond(Request(uri='/echo.sock'))
return transport
示例11: test_channel_can_have_sockets_added_to_it
def test_channel_can_have_sockets_added_to_it():
mk(('echo.sock', 'channel.send(channel.recv())'))
socket = make_socket()
channel = Channel('foo', ThreadedBuffer)
channel.add(socket)
expected = [socket]
actual = list(channel)
assert actual == expected, actual
示例12: test_two_sockets_are_instantiable
def test_two_sockets_are_instantiable():
mk(('echo.sock', ''))
socket1 = make_socket()
socket2 = make_socket()
expected = (Socket, Socket)
actual = (socket1.__class__, socket2.__class__)
assert actual == expected, actual
示例13: test_unavailable_knob_sets_retry_after_on_website
def test_unavailable_knob_sets_retry_after_on_website():
mk( '.aspen'
, ('.aspen/foo.py', 'bar = "baz"')
, ('index.html', "import fooGreetings, {{ foo.bar }}!")
)
actual = handle('/', '--unavailable=10').headers['Retry-After']
expected = datetime.datetime.utcnow().strftime('%a, %d %b %Y')
assert actual.startswith(expected), actual
assert actual.endswith(' +0000'), actual
示例14: test_path_part_params_are_available
def test_path_part_params_are_available():
mk(('/foo/index.html.spt', """
if 'b' in path.parts[0].params:
a = path.parts[0].params['a']
[---]
%(a)s"""))
expected = "3"
actual = handle('/foo;a=1;b;a=3/').body
assert actual == expected, actual + " isn't " + expected
示例15: test_resources_can_import_from_dot_aspen
def test_resources_can_import_from_dot_aspen():
mk( '.aspen'
, ('.aspen/foo.py', 'bar = "baz"')
, ('index.html.spt', "from foo import bar\n[---]\nGreetings, %(bar)s!")
)
expected = "Greetings, baz!"
project_root = os.path.join(FSFIX, '.aspen')
actual = handle('/', '--project_root='+project_root).body
assert actual == expected, actual