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


Python DummyRequest.addArg方法代码示例

本文整理汇总了Python中twisted.web.test.test_web.DummyRequest.addArg方法的典型用法代码示例。如果您正苦于以下问题:Python DummyRequest.addArg方法的具体用法?Python DummyRequest.addArg怎么用?Python DummyRequest.addArg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.web.test.test_web.DummyRequest的用法示例。


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

示例1: test_everything

# 需要导入模块: from twisted.web.test.test_web import DummyRequest [as 别名]
# 或者: from twisted.web.test.test_web.DummyRequest import addArg [as 别名]
def test_everything():
    postPath = ["first argument", "second argument"]
    request = DummyRequest(postPath)
    request.addArg("foo", "hello")
    request.addArg("bar", "world")
    eCon = ExtendedController()
    actuals = eCon.everything(request)    
    assert actuals['u_first'] == postPath[0]
    assert actuals['u_second'] == postPath[1]
    assert actuals['a_foo'] == "hello"
    assert actuals['a_bar'] == "world"
开发者ID:devdave,项目名称:txWeb,代码行数:13,代码来源:test_smartcontroller.py

示例2: testMustSucceedsWithListForArg1

# 需要导入模块: from twisted.web.test.test_web import DummyRequest [as 别名]
# 或者: from twisted.web.test.test_web.DummyRequest import addArg [as 别名]
    def testMustSucceedsWithListForArg1(self):
        @Must(arg1=(list, float))
        def testMethod(request, params):
            self.assertTrue("arg1" in params)
            self.assertTrue(len(params["arg1"]) == 2)
            self.assertTrue(isinstance(params["arg1"][0], float))
            pass

        request = DummyRequest([""])
        request.addArg("arg1", ["123.5", "678.9"])

        response = testMethod(request)
开发者ID:devdave,项目名称:PyProxy,代码行数:14,代码来源:test_util_smart.py

示例3: testMustSucceeds

# 需要导入模块: from twisted.web.test.test_web import DummyRequest [as 别名]
# 或者: from twisted.web.test.test_web.DummyRequest import addArg [as 别名]
    def testMustSucceeds(self):

        expectedArg = "hello"

        @Must(arg1=str)
        def testMethod(request, params):
            self.assertTrue("arg1" in params)
            self.assertEqual(params["arg1"], expectedArg)

        request = DummyRequest([""])
        request.addArg("arg1", expectedArg)

        testMethod(request)
开发者ID:devdave,项目名称:PyProxy,代码行数:15,代码来源:test_util_smart.py

示例4: test_defaultArgumentsWorksAsExpected

# 需要导入模块: from twisted.web.test.test_web import DummyRequest [as 别名]
# 或者: from twisted.web.test.test_web.DummyRequest import addArg [as 别名]
def test_defaultArgumentsWorksAsExpected(testController = None):
    testClass = testController or ExampleController
    emptyRequest = DummyRequest([])
    populatedRequest = DummyRequest([50])
    populatedRequest.addArg("name", "John Doe")
    
    controller = testClass()
    actuals1 = controller.defaultArguments(emptyRequest)
    actuals2 = controller.defaultArguments(populatedRequest)
    assert actuals1['u_number'] == 10, "%s is not equal to %s" % (actuals1['u_number'], 10)
    assert actuals1['a_name'] == "Unknown", "%s is not equal to %s" % (actuals1['a_name'], "Unkown")
    assert actuals2['u_number'] == 50, "%s is not equal to %s" % (actuals2['u_number'], 50)
    assert actuals2['a_name'] == "John Doe", "%s is not equal to %s" % (actuals2['a_name'], "John Doe")
开发者ID:devdave,项目名称:txWeb,代码行数:15,代码来源:test_smartcontroller.py

示例5: test_argshandlingLogic

# 需要导入模块: from twisted.web.test.test_web import DummyRequest [as 别名]
# 或者: from twisted.web.test.test_web.DummyRequest import addArg [as 别名]
def test_argshandlingLogic(testController = None):
    testClass = testController or ExampleController
    
    request = DummyRequest([])
    firstArgument = "Hello"
    secondArgument = "World"
    thirdArgument = None
    
    request.addArg("first", firstArgument)
    request.addArg("second", secondArgument)
    
    eCon = testClass()    
    expected = {"self": eCon, "a_first" : firstArgument, "a_second" : secondArgument, "a_third" : None}
    actual = eCon.args(request)
    for key in expected.keys():
        assert actual.get(key, ['unique object']) == expected[key], "Missing expected key %s in %r" % (key, actual)
开发者ID:devdave,项目名称:txWeb,代码行数:18,代码来源:test_smartcontroller.py

示例6: testMustSucceedsMultipleArgs

# 需要导入模块: from twisted.web.test.test_web import DummyRequest [as 别名]
# 或者: from twisted.web.test.test_web.DummyRequest import addArg [as 别名]
    def testMustSucceedsMultipleArgs(self):

        expectedArg1 = "hello"
        expectedArg2 = 123.4

        @Must(arg1=str, arg2=float)
        def testMethod(request, params):
            self.assertTrue("arg1" in params)
            self.assertTrue("arg2" in params)
            self.assertEqual(params["arg1"], expectedArg1)
            self.assertEqual(params["arg2"], expectedArg2)

        request = DummyRequest([""])
        request.addArg("arg1", expectedArg1)
        request.addArg("arg2", expectedArg2)

        testMethod(request)
开发者ID:devdave,项目名称:PyProxy,代码行数:19,代码来源:test_util_smart.py


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