Brownie framework FileNotFoundError: Cannot find tests/test_simple_storage.py

Brownie framework FileNotFoundError: Cannot find tests/test_simple_storage.py

我正在根据参考学习solidity(https://www.youtube.com/watch?v=M576WGiDBdQ&t=25510s)

当我尝试在 Brownie 框架下编写 运行 测试时,遇到一个错误,提示找不到文件。

ganache-cli 工作正常。 使用 Macbook Pro,intel 而不是 Apple M1 CPU。

正在寻找 help.Thanks。

这是 brownie 测试文件夹中的测试脚本文件。

from brownie import SimpleStorage, accounts

# Arrange
account = accounts[0]
print(account)
# Act
simple_storage = SimpleStorage.deploy({"from": account})
starting_value = simple_storage.retrieve()
expected = 0
# Assert
assert starting_value == expected


错误信息。

(base) liwei@liweideMacBook-Pro Brownie_Simple_Storage % brownie run tests/test_simple_storage.py
Brownie v1.17.2 - Python development framework for Ethereum

BrownieSimpleStorageProject is the active project.
Attached to local RPC client listening at '127.0.0.1:8545'...
  File "brownie/_cli/__main__.py", line 64, in main
    importlib.import_module(f"brownie._cli.{cmd}").main()
  File "brownie/_cli/run.py", line 46, in main
    path, _ = _get_path(args["<filename>"])
  File "brownie/project/scripts.py", line 130, in _get_path
    raise FileNotFoundError(f"Cannot find {path_str}")
FileNotFoundError: Cannot find tests/test_simple_storage.py
(base) liwei@liweideMacBook-Pro Brownie_Simple_Storage % 


这是 Brownie 脚本文件夹中的 deploy.py 文件

import os


def deploy_simple_storage():

    # load from you set encrypted , not from ganache-cli which is brownie automated connceted to
    # account = accounts.load("MG515-account")
    # print(account)

    # add private key use enviroment variables
    # account = accounts.add(os.getenv("PRIVATE_KEY"))
    # print(account)

    # .deploy() , always need a "from"key in a dictinary when making a transaction
    account = accounts.add(config["wallets"]["from_key"])
    simple_storage = SimpleStorage.deploy({"from": account})
    stored_value = simple_storage.retrieve()
    print("Current stored value is :")
    print(stored_value)
    print("Updating Contract...")
    transaction = simple_storage.store(15, {"from": account})
    transaction.wait(1)
    updated_store_value = simple_storage.retrieve()
    print("Current stored value is :")
    print(updated_store_value)


def main():
    deploy_simple_storage()

你检查过你的文件路径和文件名了吗?

FileNotFoundError: Cannot find tests/test_simple_storage.py

应该有 tests 文件夹和名为“test_simple_storage.py”的测试脚本文件。