From 8c836aeecfb9cc96bf80ea1c516a5a508c6faa02 Mon Sep 17 00:00:00 2001 From: Harutaka Kawamura Date: Sat, 7 Jan 2023 12:55:24 +0900 Subject: [PATCH] Add more backticks to flake8-pytest-style error messages (#1707) --- README.md | 10 +++++----- src/registry.rs | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 9f4ce269af..0b1bd6406b 100644 --- a/README.md +++ b/README.md @@ -918,20 +918,20 @@ For more, see [flake8-pytest-style](https://pypi.org/project/flake8-pytest-style | PT005 | IncorrectFixtureNameUnderscore | Fixture `...` returns a value, remove leading underscore | | | PT006 | ParametrizeNamesWrongType | Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple` | 🛠 | | PT007 | ParametrizeValuesWrongType | Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple` | | -| PT008 | PatchWithLambda | Use `return_value=` instead of patching with lambda | | -| PT009 | UnittestAssertion | Use a regular assert instead of unittest-style '...' | | +| PT008 | PatchWithLambda | Use `return_value=` instead of patching with `lambda` | | +| PT009 | UnittestAssertion | Use a regular `assert` instead of unittest-style `...` | | | PT010 | RaisesWithoutException | set the expected exception in `pytest.raises()` | | | PT011 | RaisesTooBroad | `pytest.raises(...)` is too broad, set the `match` parameter or use a more specific exception | | | PT012 | RaisesWithMultipleStatements | `pytest.raises()` block should contain a single simple statement | | | PT013 | IncorrectPytestImport | Found incorrect import of pytest, use simple `import pytest` instead | | | PT015 | AssertAlwaysFalse | Assertion always fails, replace with `pytest.fail()` | | | PT016 | FailWithoutMessage | No message passed to `pytest.fail()` | | -| PT017 | AssertInExcept | Found assertion on exception ... in except block, use pytest.raises() instead | | +| PT017 | AssertInExcept | Found assertion on exception `...` in except block, use `pytest.raises()` instead | | | PT018 | CompositeAssertion | Assertion should be broken down into multiple parts | | -| PT019 | FixtureParamWithoutValue | Fixture ... without value is injected as parameter, use @pytest.mark.usefixtures instead | | +| PT019 | FixtureParamWithoutValue | Fixture `...` without value is injected as parameter, use `@pytest.mark.usefixtures` instead | | | PT020 | DeprecatedYieldFixture | `@pytest.yield_fixture` is deprecated, use `@pytest.fixture` | | | PT021 | FixtureFinalizerCallback | Use `yield` instead of `request.addfinalizer` | | -| PT022 | UselessYieldFixture | No teardown in fixture ..., use `return` instead of `yield` | 🛠 | +| PT022 | UselessYieldFixture | No teardown in fixture `...`, use `return` instead of `yield` | 🛠 | | PT023 | IncorrectMarkParenthesesStyle | Use `@pytest.mark....` over `@pytest.mark....()` | 🛠 | | PT024 | UnnecessaryAsyncioMarkOnFixture | `pytest.mark.asyncio` is unnecessary for fixtures | | | PT025 | ErroneousUseFixturesOnFixture | `pytest.mark.usefixtures` has no effect on fixtures | | diff --git a/src/registry.rs b/src/registry.rs index 244b88cbb4..32b38b7460 100644 --- a/src/registry.rs +++ b/src/registry.rs @@ -3526,10 +3526,10 @@ impl CheckKind { ) } CheckKind::PatchWithLambda => { - "Use `return_value=` instead of patching with lambda".to_string() + "Use `return_value=` instead of patching with `lambda`".to_string() } CheckKind::UnittestAssertion(assertion) => { - format!("Use a regular assert instead of unittest-style '{assertion}'") + format!("Use a regular `assert` instead of unittest-style `{assertion}`") } CheckKind::RaisesWithoutException => { "set the expected exception in `pytest.raises()`".to_string() @@ -3552,7 +3552,7 @@ impl CheckKind { CheckKind::FailWithoutMessage => "No message passed to `pytest.fail()`".to_string(), CheckKind::AssertInExcept(name) => { format!( - "Found assertion on exception {name} in except block, use pytest.raises() \ + "Found assertion on exception `{name}` in except block, use `pytest.raises()` \ instead" ) } @@ -3561,8 +3561,8 @@ impl CheckKind { } CheckKind::FixtureParamWithoutValue(name) => { format!( - "Fixture {name} without value is injected as parameter, use \ - @pytest.mark.usefixtures instead" + "Fixture `{name}` without value is injected as parameter, use \ + `@pytest.mark.usefixtures` instead" ) } CheckKind::DeprecatedYieldFixture => { @@ -3572,7 +3572,7 @@ impl CheckKind { "Use `yield` instead of `request.addfinalizer`".to_string() } CheckKind::UselessYieldFixture(name) => { - format!("No teardown in fixture {name}, use `return` instead of `yield`") + format!("No teardown in fixture `{name}`, use `return` instead of `yield`") } CheckKind::IncorrectMarkParenthesesStyle(mark_name, expected_parens, actual_parens) => { format!(