Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow tests to be marked as requiring a system/platform/etc pattern file suffix #22

Closed
zaufi opened this issue Mar 1, 2024 · 4 comments
Assignees

Comments

@zaufi
Copy link
Owner

zaufi commented Mar 1, 2024

I.e., in the situation when some (not all!) pattern files have some system-specific content (e.g., different EOL styles).

Smth like this:

def generic_test(capfd, expected_out):
    ...
    stdout, _ = capfd.readouterr()
    # Get content from `<base-dir>/.../generic_test.out`
    assert expected_out == stdout

@pytest.mark.expect_system_suffix
def system_specific_test(capfd, expected_out):
    ...
    stdout, _ = capfd.readouterr()
    # Get content from `<base-dir>/.../system_specific_test-Linux.out`
    assert expected_out == stdout
@zaufi zaufi changed the title Allow tests being marked as requires a system/platform/etc pattern file suffix Allow tests to be marked as requiring a system/platform/etc pattern file suffix Mar 1, 2024
@zaufi
Copy link
Owner Author

zaufi commented Mar 1, 2024

Actually, it could be almost anything:

@pytest.mark.expect_suffix(
    suffix=platform.system()
  )
def system_specific_test(capfd, expected_out):
    ...
    stdout, _ = capfd.readouterr()
    # Get content from `<base-dir>/.../system_specific-Linux.out`
    assert expected_out == stdout

@pytest.mark.expect_suffix(
    suffix=f'py{sys.version_info.major}.{sys.version_info.minor}'
  )
def python_specific_test(capfd, expected_out):
    ...
    stdout, _ = capfd.readouterr()
    # Get content from `<base-dir>/.../python_specific_test-py3.12.out`
    assert expected_out == stdout

@zaufi
Copy link
Owner Author

zaufi commented Mar 1, 2024

@xymaxim Ping ;-)

zaufi added a commit that referenced this issue Mar 1, 2024
A test can be marked with `@pytest.mark.expect_suffix([args..., suffix=<arg>])`
to have an arbitrary suffix in the pattern filenames.
The `pm-pattern-file-fmt` format string should have the `{suffix}` placeholder
to make it work.
@xymaxim
Copy link
Collaborator

xymaxim commented Mar 1, 2024

I like how it's flexible!

zaufi added a commit that referenced this issue Mar 1, 2024
A test can be marked with `@pytest.mark.expect_suffix([args..., suffix=<arg>])`
to have an arbitrary suffix in the pattern filenames.
The `pm-pattern-file-fmt` format string should have the `{suffix}` placeholder
to make it work.
zaufi added a commit that referenced this issue Mar 2, 2024
A test can be marked with `@pytest.mark.expect_suffix([args..., suffix=<arg>])`
to have an arbitrary suffix in the pattern filenames.
The `pm-pattern-file-fmt` format string should have the `{suffix}` placeholder
to make it work.
zaufi added a commit that referenced this issue Mar 2, 2024
A test can be marked with `@pytest.mark.expect_suffix([args...,
suffix=<arg>])` to have an arbitrary suffix in the pattern filenames.
The `pm-pattern-file-fmt` format string should have the `{suffix}`
placeholder to make it work.
@zaufi zaufi self-assigned this Mar 2, 2024
@zaufi
Copy link
Owner Author

zaufi commented Mar 2, 2024

Implemented in PR #23

@zaufi zaufi closed this as completed Mar 2, 2024
zaufi added a commit that referenced this issue Mar 2, 2024
A test can be marked with `@pytest.mark.expect_suffix([args...,
suffix=<arg>])` to have an arbitrary suffix in the pattern filenames.
The `pm-pattern-file-fmt` format string should have the `{suffix}`
placeholder to make it work.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants