-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cc51073
commit 9d18239
Showing
2 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright 2022 MosaicML Composer authors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
"""Unit tests for string helpers.""" | ||
|
||
from composer.utils.string_helpers import partial_format | ||
|
||
|
||
def test_partial_format(): | ||
# Keyword args | ||
assert partial_format('{foo} {bar}', foo='Hello') == 'Hello {bar}' | ||
assert partial_format('{foo} {bar}', foo='Hello', bar='World') == 'Hello World' | ||
|
||
# Positional args | ||
assert partial_format('{} {}', 'Hello') == 'Hello {}' | ||
assert partial_format('{} {}', 'Hello', 'World') == 'Hello World' | ||
|
||
# Positional and keyword args | ||
assert partial_format('{foo} {}', 'World') == '{foo} World' | ||
assert partial_format('{foo} {}', foo='Hello') == 'Hello {}' | ||
assert partial_format('{foo} {}', 'World', foo='Hello') == 'Hello World' |