VSCode Python 测试的自定义图标

Custom Icon for VSCode Python Tests

我希望 Python 测试与 VSCode 中的常规 Python 文件具有不同的图标,以便轻松区分代码和测试。所以一个图标代表 *.py,另一个图标代表 test*.py。看起来很容易做,但到目前为止运气不好。

默认情况下 VSCode 未内置 - https://github.com/microsoft/vscode/issues/12493。您可以将文件模式与不同的语言相关联,例如:明文更改文件图标但随后会破坏测试的 linting 等:

    "files.associations": {
        "*.py": "python",
        "*_test.py": "plaintext"
    },

Material 图标主题不支持 globbing。 https://github.com/PKief/vscode-material-icon-theme/issues/330#issuecomment-428258408。 IE 以下内容不起作用:

    "material-icon-theme.files.associations": {
        "*.py": "python",
        "*_test.py": "python-misc"
    }

vscode-图标也不支持通配:https://github.com/vscode-icons/vscode-icons/issues/2617

Material Iconvscode-icons 开发人员解释说 VSCode does NOT support glob naming for icon themes 阻止他们支持此功能。

所以我用 VSCode-icons 试过了:

  "vsicons.associations.files": [
    { "icon": "pyret",  "extensions": ["test.py"], "filename": false, "format": "svg"},
  ],

可以更改a.test.py这样的文件的图标,保留a.py和python的图标。

但问题是测试框架无法发现名称为 a.test.py 的测试,即使这样 a..py.

太可惜了。也许我们应该等待它的支持。