小编and*_*dms的帖子

在 Golang 中使用不同的值多次运行单元测试

我正在尝试使用 Golang 中的测试模块使用不同的值多次测试一个函数 - 有谁知道如何做到这一点?我知道如何用一个值来做到这一点。

应用程序.go

package main

func main () {
    value := add(1, 2)
}

func add(a int, b int) int {
    return a + b
}
Run Code Online (Sandbox Code Playgroud)

但想做类似的事情:

app_test.go

package main
import (
    "testing"
)

TestAdd1(t *test.T) {
    res := add(1, 2)
    if(res != 3) {
        t.Error("Got: %d, want: %d", res, 3)
    }
}


TestAdd2(t *test.T) {
    res := add(2, 2)
    if(res != 4) {
        t.Error("Got: %d, want: %d", res, 4)
    }
}
Run Code Online (Sandbox Code Playgroud)

testing unit-testing go

5
推荐指数
1
解决办法
9510
查看次数

超链接 <div> 元素的集合

当我尝试超链接下面的代码时,它似乎弄乱了图像的包装并且只链接了图标而不是整个 flex-container。我试过尝试<span>元素,但没有任何成功。

.flex-container {
  padding: 0;
  margin: 0;
  list-style: none;
  display: -webkit-box;
  display: -moz-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-flow: row;
  transition: opacity .2s ease-in-out;
  flex-wrap: nowrap
}

.flex-item {
  text-align: center;
  text-decoration: none;
  color: #ffffff;
  font-family: verdana;
  width: 100%;
  display: flex;
  flex-shrink: 1;
  justify-content: center;
  align-items: center;
  font-size: calc(8px + (26 - 18) * ((100vw - 300px) / (1600 - 300)));
  z-index: 10;
  flex-wrap: nowrap
}

.flex-item:before {
  content: '';
  float: left;
  padding-top: 100%;
}

.red-box …
Run Code Online (Sandbox Code Playgroud)

html css css-animations

2
推荐指数
1
解决办法
76
查看次数

Django AUTH_PASSWORD_VALIDATORS 检查符号和其他要求

是否可以验证密码要求,例如:

  • 一个大写字母
  • 两个符号

使用 Django 内置的密码管理?例如这些:

django.contrib.auth.password_validation.UserAttributeSimilarityValidator
django.contrib.auth.password_validation.MinimumLengthValidator
django.contrib.auth.password_validation.CommonPasswordValidator
django.contrib.auth.password_validation.NumericPasswordValidator
Run Code Online (Sandbox Code Playgroud)

我发现以下 Python 包可以实现我想要的功能,但我想知道它是否可以在本地完成:

https://pypi.org/project/django-password-validators/

谢谢!

python passwords django web-applications

0
推荐指数
1
解决办法
3508
查看次数