|
7 | 7 | # |
8 | 8 | ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## |
9 | 9 | """Tests for filename container""" |
| 10 | +import pathlib |
10 | 11 |
|
11 | 12 | import pytest |
12 | 13 |
|
13 | | -from ..filename_parser import TypesFilenamesError, parse_filename, splitext_addext, types_filenames |
| 14 | +from ..filename_parser import TypesFilenamesError, parse_filename, splitext_addext, types_filenames, _stringify_path |
14 | 15 |
|
15 | 16 |
|
16 | 17 | def test_filenames(): |
@@ -123,3 +124,26 @@ def test_splitext_addext(): |
123 | 124 | assert res == ('..', '', '') |
124 | 125 | res = splitext_addext('...') |
125 | 126 | assert res == ('...', '', '') |
| 127 | + |
| 128 | + |
| 129 | +def test__stringify_path(): |
| 130 | + current_directory = pathlib.Path.cwd() |
| 131 | + res = _stringify_path('') |
| 132 | + assert res == str(current_directory) |
| 133 | + res = _stringify_path('fname.ext.gz') |
| 134 | + assert res == str(current_directory / 'fname.ext.gz') |
| 135 | + res = _stringify_path(pathlib.Path('fname.ext.gz')) |
| 136 | + assert res == str(current_directory / 'fname.ext.gz') |
| 137 | + |
| 138 | + home = pathlib.Path.home() |
| 139 | + res = _stringify_path(pathlib.Path('~/fname.ext.gz')) |
| 140 | + assert res == str(home) + '/fname.ext.gz' |
| 141 | + |
| 142 | + res = _stringify_path(pathlib.Path('./fname.ext.gz')) |
| 143 | + assert res == str(current_directory / 'fname.ext.gz') |
| 144 | + res = _stringify_path(pathlib.Path('../fname.ext.gz')) |
| 145 | + assert res == str(current_directory.parent / 'fname.ext.gz') |
| 146 | + |
| 147 | + |
| 148 | + |
| 149 | + |
0 commit comments