如何解决VSCode pytest测试发现失败?
由于某些原因,VSCode无法获取我的“ test_ *”文件?
代码如下:
COPY --from=builder /usr/local/share/ca-certificates/myCA.crt /usr/local/share/ca-certificates/myCA.crt
RUN apk add ca-certificates && apk update && update-ca-certificates
我尝试使用CTRL + SHIFT + P并配置测试,但这也失败了,它说:import java.net.*;
import java.io.*;
import java.util.Properties;
public class Test {
public static void main(String[] args) throws Exception {
new Test().connect();
}
public void connect() {
try {
String url = "https://antoshka.ua/ua/nabir-lakiv-dlya-nigtiv-make-it-real-rusalonka-3-sht6282464.html",proxy = "proxy.mydomain.com",port = "8080";
URL server = new URL(url);
Properties systemProperties = System.getProperties();
systemProperties.setProperty("http.proxyHost",proxy);
systemProperties.setProperty("http.proxyPort",port);
HttpURLConnection connection = (HttpURLConnection)server.openConnection();
connection.connect();
InputStream in = connection.getInputStream();
readResponse(in);
} catch(Exception e) {
e.printStackTrace();
}
}
public void readResponse(InputStream is) throws IOException {
BufferedInputStream bis = new BufferedInputStream(is);
ByteArrayOutputStream buf = new ByteArrayOutputStream();
int result = bis.read();
while(result != -1) {
byte b = (byte)result;
buf.write(b);
result = bis.read();
}
System.out.println(buf.toString());
}
}
和import pytest
import requests
import responses
@responses.activate
def test_simple(api_key: str,url: str):
"""Test"""
responses.add(responses.GET,url=url+api_key,json={"error": "not found"},status=404)
resp = requests.get(url+api_key)
assert resp.json() == {"error": "not found"}
在我的设置中,唯一与pytest相关的是:Test discovery failed
。
这是怎么回事?我的文件以“ test”开头,因此在该文件中我的功能也可以吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。