AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / coding / 问题

问题[pytest](coding)

Martin Hope
Gelsengamer
Asked: 2025-04-22 20:37:39 +0800 CST

文件名中允许使用哪些字符(焦点等于“=”)?

  • 5

我想将一个文件夹作为 Bazel 中 py_test 的依赖项传递。该文件夹包含带有特殊字符“=”的文件名,例如“equal=.txt”。我收到终端打印信息,提示“zipper.exe”无法找到该文件。这是一个简单的例子。

BUID文件:

py_test(
    name = "bazel_char_test",
    srcs = ["bazel_char_test.py"],
    data = ["equal.txt"]+["equal = .txt"],
)

错误信息:

错误:C:/path/BUILD:31:8:构建 Python zip://project_path:bazel_char_test 失败:(退出 -1):zipper.exe 失败:执行 PythonZipper 命令时出错(来自目标//project_path:bazel_char_test)external\bazel_tools\tools\zip\zipper\zipper.exe cC bazel-out/x64_windows-fastbuild/bin/project_path/bazel_char_test.zip...(跳过剩余 1 个参数)文件 .txt=project_path/equal = .txt 似乎不存在。目标//project_path:bazel_char_test 构建失败

我检查了一下,文件确实存在。如果我把字符“=”改成“+”,就能找到文件,测试就开始了。

因此,执行“zipper.exe / PythonZipper 命令”时会发生故障。假设我将文件名与目标名称和包名称等同起来,这应该符合BAZEL 文档的规定,它应该处理带有等号的文件名。“目标名称必须完全由 a–z、A–Z、0–9 和标点符号 !%-@^_"#$&'() -+,;<=>?[]{|}~/..*” 中的字符组成。似乎 = 符号的存在本身就会导致错误。它前后是否有空格似乎无关紧要。

有人知道这里发生了什么/我做错了什么吗?我正在使用 Bazel 7.5.0。当然,一种解决方法是更改​​文件名(我认为用等号作为文件名不是最好的选择),但如果它们能保持不变就更好了。

pytest
  • 1 个回答
  • 51 Views
Martin Hope
ibexy
Asked: 2024-05-04 13:01:46 +0800 CST

未找到步骤定义错误 - 仅适用于给定步骤 - pytest-bdd

  • 5

为什么以下 pytest-bdd 代码会抛出错误:

pytest_bdd.exceptions.StepDefinitionNotFoundError:找不到步骤定义:给出“我有一个空的购物车

这是功能文件:

Feature: Shopping Cart
              As a customer
              I want to add products to my shopping cart
  So that I can purchase them later

        Scenario Outline: Add products to the shopping cart
            Given I have an empty shopping cart
             When I add <product> to the cart
             Then the cart should contain <product> and shelf number is <shelf_num>

        Examples:
                  | product | shelf_num |
                  | Apples  | 5         |
                  | Bananas | 24        |
                  | Oranges | 11        |

以下是步骤:

scenarios('scenario_example_demo.feature') 

@pytest.fixture
def shopping_cart():
    return []

@given('I have an empty shopping cart')
def empty_shopping_cart(shopping_cart):
    assert len(shopping_cart) == 0

@when(parsers.parse('I add {product} to the cart'))
def add_product(shopping_cart, product):
    shopping_cart.append(product)

@then(parsers.parse('the cart should contain {product} and shelf number is {shelf_num}'))
def verify_cart_contents(shopping_cart, product,shelf_num):
    assert product in shopping_cart and int(shelf_num)>0

奇怪的是,当我将功能文件中的“Given”更改为“When”并在步骤代码中执行相同操作时,代码有效。

代码来源:来自 Medium (Ramkumar R)

pytest
  • 1 个回答
  • 17 Views
Martin Hope
Dinesh
Asked: 2024-01-04 01:40:39 +0800 CST

Pytest Parameterize From file Library - 是否有任何可能的单个 Pytest 脚本,可以传递多个配置文件(.yml)

  • 5

Pytest Parameterize From file Library 完全满足我的要求,但我需要对同一组测试条件使用多个配置文件(.yml)。

示例:test_stage.py(所有测试条件都存在)

test_01_stage.yml test_02_stage.yml 同样需要在同一个 .py 脚本中传递多个参数文件

请分享如何借助 Parameterize From file Library 在 pytest 中实现的步骤

我需要让单个 pytest 脚本并行执行多个配置文件(.YML)如何实现它

pytest
  • 1 个回答
  • 23 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    重新格式化数字,在固定位置插入分隔符

    • 6 个回答
  • Marko Smith

    为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会?

    • 2 个回答
  • Marko Smith

    VScode 自动卸载扩展的问题(Material 主题)

    • 2 个回答
  • Marko Smith

    Vue 3:创建时出错“预期标识符但发现‘导入’”[重复]

    • 1 个回答
  • Marko Smith

    具有指定基础类型但没有枚举器的“枚举类”的用途是什么?

    • 1 个回答
  • Marko Smith

    如何修复未手动导入的模块的 MODULE_NOT_FOUND 错误?

    • 6 个回答
  • Marko Smith

    `(表达式,左值) = 右值` 在 C 或 C++ 中是有效的赋值吗?为什么有些编译器会接受/拒绝它?

    • 3 个回答
  • Marko Smith

    在 C++ 中,一个不执行任何操作的空程序需要 204KB 的堆,但在 C 中则不需要

    • 1 个回答
  • Marko Smith

    PowerBI 目前与 BigQuery 不兼容:Simba 驱动程序与 Windows 更新有关

    • 2 个回答
  • Marko Smith

    AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String”

    • 1 个回答
  • Martin Hope
    Fantastic Mr Fox msvc std::vector 实现中仅不接受可复制类型 2025-04-23 06:40:49 +0800 CST
  • Martin Hope
    Howard Hinnant 使用 chrono 查找下一个工作日 2025-04-21 08:30:25 +0800 CST
  • Martin Hope
    Fedor 构造函数的成员初始化程序可以包含另一个成员的初始化吗? 2025-04-15 01:01:44 +0800 CST
  • Martin Hope
    Petr Filipský 为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会? 2025-03-23 21:39:40 +0800 CST
  • Martin Hope
    Catskul C++20 是否进行了更改,允许从已知绑定数组“type(&)[N]”转换为未知绑定数组“type(&)[]”? 2025-03-04 06:57:53 +0800 CST
  • Martin Hope
    Stefan Pochmann 为什么 {2,3,10} 和 {x,3,10} (x=2) 的顺序不同? 2025-01-13 23:24:07 +0800 CST
  • Martin Hope
    Chad Feller 在 5.2 版中,bash 条件语句中的 [[ .. ]] 中的分号现在是可选的吗? 2024-10-21 05:50:33 +0800 CST
  • Martin Hope
    Wrench 为什么双破折号 (--) 会导致此 MariaDB 子句评估为 true? 2024-05-05 13:37:20 +0800 CST
  • Martin Hope
    Waket Zheng 为什么 `dict(id=1, **{'id': 2})` 有时会引发 `KeyError: 'id'` 而不是 TypeError? 2024-05-04 14:19:19 +0800 CST
  • Martin Hope
    user924 AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String” 2024-03-20 03:12:31 +0800 CST

热门标签

python javascript c++ c# java typescript sql reactjs html

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve