Skip to content

Conversation

@Fefer-Ivan
Copy link

@Fefer-Ivan Fefer-Ivan commented Dec 4, 2025

To write tests for applications, that use CpuTime, it is very useful to mock CpuTime values to see how tested applications behave, depending on CPU load.

Because CpuTime have a private field tps and private from_str constructor function, the only way to mock it currently is to create a temporary file and actually write cpu time-like strings into a file and later read this file.

This makes using mocking libraries like mockall hard or impossible and complicates testing code that now have a state to cleanup (e.g. temporary file with mock data).

Adding a public constructor will help simplify it.

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

Successfully merging this pull request may close these issues.

1 participant