问题列表 - 第317989页

Python 3.11。异步测试运行器

决定将 Python 版本从3.10升级到3.11,之前我们已经使用了asynctest.TestCase和setUp方法tearDown并支持异步代码的测试。

我已经检查过unittest.IsolatedAsyncioTestCase,但它为每个测试使用不同的事件循环,这导致使用我们现在无法承受的不同会话。

我们使用async setUp /asyncSetUp来初始化依赖项并创建测试数据,因此需要此功能。

有类似物吗?或者您使用什么来使用 python 3.11 / 3.12 测试复杂系统?

asynctest.TestCase3.11+ 不支持ps

我想知道是否有使用 python 3.11/3.12 测试异步代码的专业知识。也许有人也面临着我的问题。

python python-unittest python-3.11 python-3.12

6
推荐指数
1
解决办法
396
查看次数

Haskell 中的递归和无限循环问题

我在 Haskell 中有三个函数。所有这些都旨在基于 n 次迭代的初始猜测来执行 \xe2\x88\x9a2 。

\n
    \n
  1. \n
    squareRootTwo :: Double -> Integer -> Double\nsquareRootTwo guess n\n| n == 0 = guess\n| otherwise = squareRootTwo ((guess + 2/guess) / 2) (n-1)\n
    Run Code Online (Sandbox Code Playgroud)\n
  2. \n
  3. \n
    squareRootTwoA :: Double -> Integer -> Double\nsquareRootTwoA guess n\n| n == 0 = guess\n| otherwise = squareRootTwoA ((guess + 2/guess) / 2) (n-1) where n=n\n
    Run Code Online (Sandbox Code Playgroud)\n
  4. \n
  5. \n
    squareRootTwoB :: Double -> Integer -> Double\nsquareRootTwoB guess n\n| n == 0 = guess\n| otherwise = …
    Run Code Online (Sandbox Code Playgroud)

recursion haskell infinite-loop

3
推荐指数
1
解决办法
125
查看次数

Perl 模块 Tie::子例程中的文件

我的 Perl 脚本早期就有这样的内容:

tie my @y2015, 'Tie::File', "y2015.dat" or die "Can't read file: $!\n";
tie my @y2016, 'Tie::File', "y2016.dat" or die "Can't read file: $!\n";
tie my @y2017, 'Tie::File', "y2017.dat" or die "Can't read file: $!\n";
tie my @y2018, 'Tie::File', "y2018.dat" or die "Can't read file: $!\n";
tie my @y2019, 'Tie::File', "y2019.dat" or die "Can't read file: $!\n";
tie my @y2020, 'Tie::File', "y2020.dat" or die "Can't read file: $!\n";
tie my @y2021, 'Tie::File', "y2021.dat" or die "Can't read file: $!\n"; …
Run Code Online (Sandbox Code Playgroud)

perl

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

升级 10.4 - 11.5 后,TYPO3 登录加载 404?

我刚刚将 TYPO3 从 升级10.4到11.5

当我尝试登录后端时,登录表单提交会将我带到 404 页面。

mysite.com/typo3/login?loginProvider=1433416747

前端似乎正在运行,并且安装工具正在运行。

如果我运行vendor/bin/typo3cms它会告诉我:

TYPO3 Console 7.1.6
TYPO3 CMS 11.5.33 (Application Context: Production)

TYPO3 is not fully set up.
Command list is reduced to only show low level commands.
Not listed commands will not work until TYPO3 is set up.
Run "vendor/bin/typo3cms --all" to list all commands.

Some commands could not be configured and are missing in this list:
Command name: "scheduler:run", error: "The requested database connection named "Default" …
Run Code Online (Sandbox Code Playgroud)

typo3 typo3-11.x

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

clojure.core apply 函数的宏形式

其中clojure.core有一个apply函数,以多重数量风格编写(大概是为了效率)。

但是我问是否有这样的实现:

(defmacro apply [f coll] (conj (seq coll) f))

不会更好。

我知道宏的效率低于函数,但它真的有这么大的区别吗?

或者,是否不可能将此宏编写为函数(我尝试过但失败了,但这并不能证明,因为我没有编写宏的经验)?

macros performance clojure apply

3
推荐指数
1
解决办法
88
查看次数

C++ - 当 std::less 是参数之一时,为模板函数的显式实例化提供什么类型?

例如。函数头是:

template <class comparison_function, class iterator_type, class size_type>
bool F(comparison_function compare, iterator_type it)
Run Code Online (Sandbox Code Playgroud)

调用采用iterator_type和comparison_function参数,但不采用 size_type。因此,函数调用必须是显式的,例如:

F<?, std::vector<int>::iterator, long int>(std::less<int>(), it);
Run Code Online (Sandbox Code Playgroud)

会是什么??

c++ templates

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

如何将 std::variant&lt;int, string&gt; 转换为字符串

我有一个std::variant<int, std::string>。不管它代表的是int还是字符串,我都想将它转换为字符串。int从到 的转换string很简单std::to_string(int)。

目前,我使用:


get_if<int> int_ptr{&v};  // v is a std::variant<int, std::string> and we don't know before hand which it is

string res;
if (int_ptr == nullptr) {
  res = *get_if<string>{&v};
} else {
  res = to_string(*int_ptr);
}

Run Code Online (Sandbox Code Playgroud)

有没有更短的方法?

c++ string variant

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

为什么Java中的构造函数没有返回类型?

我读过,创建对象时会自动调用构造函数,但我想更深入地解释为什么它们在这方面与常规方法不同。任何示例或附加细节来说明其背后的推理将不胜感激。

我一直在使用 Java,并注意到构造函数没有返回类型,这与常规方法不同。我知道构造函数用于初始化对象,但我很好奇这种设计选择背后的具体原因。有人可以深入了解为什么 Java 构造函数没有返回类型吗?不允许构造函数指定返回类型的理由是什么?这种设计如何有助于语言的原则和一致性?

java constructor

-4
推荐指数
1
解决办法
103
查看次数

Spring Boot应用程序中server.port=0的默认端口范围是多少?

server.port=0Spring Boot 应用程序的默认端口范围是多少?

我正在使用 spring-boot 2.7 (使用默认的 tomcat 服务器)并使用 java 11。

或者范围因操作系统而异?

java httpserver spring-boot

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

BX 与 x86 中的 EBX 具有相同的值吗?

假设我们有下面的代码,其中 val1、val2 和 sum 是 32 位,BX 是 BX 寄存器。

sum = (val1 + BX) - val2
Run Code Online (Sandbox Code Playgroud)

在编写代码并使用BX寄存器时,我们可以EBX直接使用而不是使用吗movzx EBX, BX?

x86 assembly

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