Skip to content

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

@ovianao

Description

@ovianao

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions