我正在尝试在Python 2.6中使用behave 1.2.5。 不幸的是,我暂时停留在这个版本的Python上。
使用参数定义处理程序时,例如
@given('我们已经安装了{x}') def step_impl(context,x): ...
我收到以下错误消息
package main
import (
"encoding/json"
"fmt"
)
type Foo struct {
Bar Bar `json:"bar,omitempty"`
A *int `json:"a,omitempty"` //Does not get omitted when a = 0
B *bool `json:"b,omitempty"` //Does not get omitted when b = false
}
type Bar struct {
X *int `json:"x,omitempty"` //Gets omitted when x = 0
Y *bool `json:"y,omitempty"` //Gets omitted when y = false
}
func main() {
var obj Foo
a := 0 // a will not be not empty, it's set to 0
obj.A = &a
b, _ := json.MarshalIndent(obj, "", " ")
fmt.Println(string(b))
var obj2 Foo
// a and everything else will be empty, nothing is set
b, _ = json.MarshalIndent(obj2, "", " ")
fmt.Println(string(b))
}
对我来说,这表明正在调用步骤处理程序 一个字典,其中键是unicode字符串而不是常规字符串。
如果是这种情况,是否有解决方案?
库尔特
答案 0 :(得分:1)
您应该在步骤定义中的括号中包含双引号。它应该是:
@given('we have behave "{x}" installed')