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

pathlib.Path are not shown #98

Open
buhtz opened this issue May 25, 2023 · 1 comment
Open

pathlib.Path are not shown #98

buhtz opened this issue May 25, 2023 · 1 comment

Comments

@buhtz
Copy link

buhtz commented May 25, 2023

Because pytest don't support subtests I have to use this addon here. I'm not sure if I do something wrong?

In short: Using a pathlib.Path object as argument in unittest.subTest() the string representation of that object isn't used. I just see (<subtest>) in the output for each subtest.

This is a snippet of an unittest of mine:

expect_folder = pathlib.Path.cwd() / 'Beverly'
expect = [
    expect_folder / '_Elke.pickle',
    expect_folder / '_Foo.pickle',
    expect_folder / 'Bar.pickle',
    expect_folder / 'Wurst.pickle',
]
for fp in expect:
    with self.subTest(fp):
        self.assertTrue(fp.exists())

That is the output for each subtest FolderModeFS.test_build_container (<subtest>) .

When I wrap fp in str() like this

with self.subTest(str(fp)):

The output looks like this

FolderModeFS.test_build_container [/Beverly/Wurst.pickle]
@nicoddemus
Copy link
Member

Hi,

self.subTest is meant for use with unittest.TestCase, how does that output look like if you execute something similar (a MWE) using the unittest runner instead o pytest?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants