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

String formatting doesn't seem to be fully supported when using log.subpath #1069

Open
ovianao opened this issue Mar 31, 2023 · 0 comments
Open

Comments

@ovianao
Copy link

ovianao commented Mar 31, 2023

When using log.subpath, https://slash.readthedocs.io/en/master/configuration.html#conf-log-subpath, formatting isn't working as I would expect, specifically when trying to trim strings. For example, in .slashrc, set the following to create a session id folder, and within it, folders named after the test class for each test:

slash.config.root.log.subpath = "/".join([
"{context.session.id}",
"{context.test_classname:.3}",
"debug.log"
])

I would expect that the test class name would be trimmed to just 3 characters, and be used as the parent folder name of debug.log
Instead, we get this error: "Session error caught -- <Error: TypeError: unsupported format string passed to _NormalizedObject.format>"

If we omit the ":.3" part, everything works fine.

I believe this is because we're relying on object's default format method:

class _NormalizedObject(object):

It would be ideal to be able to trim these, since in Windows, long path names can play a role in whether we are or are not successful at creating these paths. Especially since the test class name or even the test method name can be any arbitrary length. Limiting the number of characters helps me to identify the appropriate test for which this log belongs, while also respecting a finite number of characters in the folder structure.

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

1 participant