| 1 |
# THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE. |
| 2 |
# Copyright (C) NIWA & British Crown (Met Office) & Contributors. |
| 3 |
# |
| 4 |
# This program is free software: you can redistribute it and/or modify |
| 5 |
# it under the terms of the GNU General Public License as published by |
| 6 |
# the Free Software Foundation, either version 3 of the License, or |
| 7 |
# (at your option) any later version. |
| 8 |
# |
| 9 |
# This program is distributed in the hope that it will be useful, |
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
# GNU General Public License for more details. |
| 13 |
# |
| 14 |
# You should have received a copy of the GNU General Public License |
| 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
"""Tests to ensure the tests are working - very meta. |
| 17 |
|
| 18 |
https://github.com/cylc/cylc-flow/pull/2740#discussion_r206086008 |
| 19 |
|
| 20 |
And yes, these are unit-tests inside a functional test framework thinggy. |
| 21 |
|
| 22 |
""" |
| 23 |
|
| 24 |
from pathlib import Path |
| 25 |
|
| 26 |
from . import ( |
| 27 |
_rm_if_empty, |
| 28 |
) |
| 29 |
|
| 30 |
|
| 31 |
def test_rm_if_empty(tmp_path): |
| 32 |
"""It should remove dirs if empty and suppress exceptions otherwise.""" |
| 33 |
path1 = Path(tmp_path, 'foo') |
| 34 |
path2 = Path(path1, 'bar') |
| 35 |
path2.mkdir(parents=True) |
| 36 |
_rm_if_empty(path1) |
| 37 |
assert path2.exists() |
| 38 |
_rm_if_empty(path2) |
| 39 |
assert not path2.exists() |
| 40 |
_rm_if_empty(path1) |
| 41 |
assert not path1.exists() |